Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from hubertshelley/develop
添加前端项目
- Loading branch information
Showing
10 changed files
with
230 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "luoshu-frontend"] | ||
path = luoshu-frontend | ||
url = https://github.com/hubertshelley/luoshu-frontend |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<div align="center"> | ||
<h1>洛书客户端</h1> | ||
</div> | ||
|
||
### 安装洛书 | ||
|
||
```shell | ||
cargo install luoshu | ||
``` | ||
|
||
### 运行洛书 | ||
不开放管理web接口 | ||
```shell | ||
luoshu | ||
``` | ||
开放管理web接口 | ||
```shell | ||
luoshu --web | ||
``` | ||
|
||
|
||
### 洛书客户端使用 | ||
|
||
引入洛书客户端 | ||
```toml | ||
[workspace.dependencies] | ||
# ... | ||
luoshu_rust_client = "0.1.0" | ||
# ... | ||
``` | ||
订阅配置信息,并注册服务到洛书并编写业务代码 | ||
```rust | ||
use std::thread::sleep; | ||
use luoshu_rust_client::LuoshuClient; | ||
#[derive(Debug, Serialize, Deserialize, Clone)] | ||
struct Config { | ||
test1: String, | ||
test2: Vec<usize>, | ||
} | ||
#[tokio::test] | ||
async fn it_works() -> LuoshuClientResult<()> { | ||
let mut client = LuoshuClient::new(15666, "test_rust_server".to_string(), None).await; | ||
client | ||
.subscribe_config( | ||
"test_config2".to_string(), | ||
|config: Config| println!("config changed:{:#?}", config), | ||
None, | ||
) | ||
.await?; | ||
tokio::spawn(async move { | ||
client.registry().await.expect("TODO: panic message"); | ||
}); | ||
|
||
// 此处使用无限循环模拟服务的持续运行 | ||
loop { | ||
println!("sleep"); | ||
sleep(Duration::from_secs(10)) | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule luoshu-frontend
added at
09e2a6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters