Skip to content

Commit 6992b2d

Browse files
authored
Merge pull request apache#52 from robberphex/ci
add ci for example
2 parents 320c207 + a0d76d4 commit 6992b2d

File tree

7 files changed

+125
-146
lines changed

7 files changed

+125
-146
lines changed

.github/workflows/github-actions.yml

+48-13
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ name: CI
44

55
on:
66
push:
7-
branches: [ main ]
7+
branches: ["*"]
88
pull_request:
9-
branches: [ main ]
9+
branches: ["*"]
1010

1111
workflow_dispatch:
1212

1313
jobs:
14-
check:
14+
check:
1515
name: check dubbo-rust project
1616
runs-on: ${{ matrix.os }}
1717
strategy:
@@ -21,28 +21,63 @@ jobs:
2121

2222
env:
2323
RUSTFLAGS: "-D warnings"
24-
24+
2525
steps:
26-
- uses: actions/checkout@main
27-
- uses: actions-rs/toolchain@v1
28-
with:
26+
- uses: actions/checkout@main
27+
- uses: actions-rs/toolchain@v1
28+
with:
2929
toolchain: ${{ matrix.rust }}
30-
- name: Install Protoc
31-
uses: arduino/setup-protoc@v1
32-
- run: cargo check
33-
34-
fmt:
30+
- name: Install Protoc
31+
uses: arduino/setup-protoc@v1
32+
with:
33+
repo-token: ${{ secrets.GITHUB_TOKEN }}
34+
- run: cargo check
35+
36+
fmt:
3537
name: Rustfmt
3638
runs-on: ${{ matrix.os }}
3739
strategy:
3840
matrix:
3941
os: [ubuntu-latest, macOS-latest, windows-latest]
4042
rust: [stable]
41-
43+
4244
steps:
4345
- uses: actions/checkout@main
4446
- uses: actions-rs/toolchain@v1
4547
with:
4648
toolchain: ${{ matrix.rust }}
4749
- run: rustup component add rustfmt
4850
- run: cargo fmt --all -- --check
51+
52+
example-greeter:
53+
name: example/greeter
54+
runs-on: ubuntu-latest
55+
steps:
56+
- uses: actions/checkout@main
57+
- uses: actions-rs/toolchain@v1
58+
with:
59+
toolchain: stable
60+
- name: Install Protoc
61+
uses: arduino/setup-protoc@v1
62+
with:
63+
repo-token: ${{ secrets.GITHUB_TOKEN }}
64+
- name: Set up cargo cache
65+
uses: actions/cache@v3
66+
continue-on-error: false
67+
with:
68+
path: |
69+
~/.cargo/bin/
70+
~/.cargo/registry/index/
71+
~/.cargo/registry/cache/
72+
~/.cargo/git/db/
73+
target/
74+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
75+
restore-keys: ${{ runner.os }}-cargo-
76+
- run: cargo build
77+
working-directory: examples/greeter
78+
- name: example greeter
79+
run: |
80+
../../target/debug/greeter-server &
81+
sleep 1s ;
82+
../../target/debug/greeter-client
83+
working-directory: examples/greeter

config/src/config.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,14 @@ lazy_static! {
3737
pub struct RootConfig {
3838
pub name: String,
3939

40-
#[serde(skip_serializing, skip_deserializing)]
40+
#[serde(default)]
4141
pub service: HashMap<String, ServiceConfig>,
4242
pub protocols: HashMap<String, ProtocolConfig>,
43+
44+
#[serde(default)]
4345
pub registries: HashMap<String, String>,
4446

47+
#[serde(default)]
4548
pub provider: ProviderConfig,
4649

4750
#[serde(skip_serializing, skip_deserializing)]

config/src/provider.rs

+2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ use super::service::ServiceConfig;
2323

2424
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
2525
pub struct ProviderConfig {
26+
#[serde(default)]
2627
pub registry_ids: Vec<String>,
2728

29+
#[serde(default)]
2830
pub protocol_ids: Vec<String>,
2931

3032
pub services: HashMap<String, ServiceConfig>,

config/src/service.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub struct ServiceConfig {
3232
pub registry: String,
3333
pub serializer: String,
3434

35-
// #[serde(skip_serializing, skip_deserializing)]
35+
#[serde(default)]
3636
pub protocol_configs: HashMap<String, ProtocolConfig>,
3737
}
3838

dubbo/src/framework.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl Dubbo {
6565
.insert(name.to_string(), Url::from_url(url).unwrap());
6666
}
6767

68-
for (_, c) in conf.provider.services.iter() {
68+
for (service_name, c) in conf.provider.services.iter() {
6969
let u = if c.protocol_configs.is_empty() {
7070
let protocol = match conf.protocols.get(&c.protocol) {
7171
Some(v) => v.to_owned(),
@@ -74,7 +74,8 @@ impl Dubbo {
7474
continue;
7575
}
7676
};
77-
let protocol_url = format!("{}/{}", protocol.to_url(), c.name.clone(),);
77+
let protocol_url =
78+
format!("{}/{}/{}", protocol.to_url(), c.name.clone(), service_name);
7879
Url::from_url(&protocol_url)
7980
} else {
8081
let protocol = match c.protocol_configs.get(&c.protocol) {
@@ -84,7 +85,8 @@ impl Dubbo {
8485
continue;
8586
}
8687
};
87-
let protocol_url = format!("{}/{}", protocol.to_url(), c.name.clone(),);
88+
let protocol_url =
89+
format!("{}/{}/{}", protocol.to_url(), c.name.clone(), service_name);
8890
Url::from_url(&protocol_url)
8991
};
9092
tracing::info!("url: {:?}", u);

0 commit comments

Comments
 (0)