clia-nacos-api

A personal temporary Nacos API, forked from Squbirreland/nacos-api.

NACOS API

Supported

service

configs

How To Use

register current instance

```rust use nacos_api::{NacosClient, NacosConfig, ServerConfig};

[tokio::main]

async fn main() { let nacos = NacosConfig::new("http", "192.168.0.132", 8848); let client = NacosClient::new( &nacos, ServerConfig::new("127.0.0.1", 8080, "test"), );

client.register(&None).await;
loop {}

} ```

try got other server address

```rust pub async fn tryreqserver() { use nacos_api::{NacosClient, NacosConfig, ServerConfig};

let nacos = NacosConfig::new("http", "192.168.0.132", 8848);
let client = NacosClient::new(
    &nacos,
    ServerConfig::new("127.0.0.1", 8080, "test"),
);

let addr = client.get_addr_simple("test").await?;
assert!("http://127.0.0.1:8080", addr.as_str());

} ```

listen configs center

```rust use nacos_api::{NacosConfigClient, NacosConfigApi, DeployConfig, NacosConfig};

[tokio::main]

async fn main() { let client = NacosConfigClient::new("testdata", "testgrep", None); let nacosconfig = NacosConfig::new("http", "192.168.0.132", 8848); // listen the nacos configs center client.listenconfig( &nacos_config, |s| { println!(" perceive the configs changed to > {}", s) }, 10 ).await; // make the program keep alive loop {} } ```

Declaration

development by nacos v2.0.1