Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Feat/cluster #155

Closed
wants to merge 48 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
2192217
feat(dubbo): add unix feature
yang20150702 Dec 7, 2022
ea06ca1
Rft: replace feature with target_os cfg
yang20150702 Dec 8, 2022
f172c25
Merge branch 'apache:main' into main
yang20150702 Dec 8, 2022
d40ea72
Merge branch 'apache:main' into main
yang20150702 Dec 9, 2022
5f5b31f
Rft(dubbo): add ClientBuilder for client
yang20150702 Dec 9, 2022
176cb57
Rftï(dubbo-build): add build api for client
yang20150702 Dec 9, 2022
b4db021
style(examples): cargo fmt
yang20150702 Dec 9, 2022
e9e0a67
Rft: move connection from client to transport mod
yang20150702 Dec 20, 2022
e67e59e
Rft(dubbo): add default timeout for client
yang20150702 Dec 26, 2022
7ab187f
Merge branch 'apache:main' into main
yang20150702 Dec 26, 2022
6e8c95e
Merge branch 'apache:main' into main
yang20150702 Dec 27, 2022
e066505
Ftr: add serverBuilder for Server, support multiple ways to start server
yang20150702 Dec 27, 2022
bd4be4e
Rft(examples): update yaml
yang20150702 Dec 27, 2022
80f3502
refactor(dubbo): update invoker trait
yang20150702 Jan 16, 2023
1022b8e
Merge branch 'main' into main
yang20150702 Jan 20, 2023
f403481
Merge branch 'apache:main' into main
yang20150702 Jan 28, 2023
fb6d30c
Merge branch 'apache:main' into main
yang20150702 Feb 9, 2023
00a90ff
Merge branch 'apache:main' into main
yang20150702 Feb 15, 2023
25903fa
Merge branch 'apache:main' into main
yang20150702 Feb 16, 2023
a03b0b5
Merge branch 'apache:main' into main
yang20150702 Feb 20, 2023
41d2ddd
Merge branch 'apache:main' into main
yang20150702 Apr 11, 2023
cfd1652
Merge branch 'apache:main' into main
yang20150702 May 10, 2023
0fcb29f
refactor(cluster): add Cluster MockImpl
yang20150702 May 11, 2023
2cd76b6
refactor(triple): use ClientBuilder to init Cluster ability
yang20150702 May 11, 2023
3cba7dc
Update builder.rs
yang20150702 May 16, 2023
1e7285e
Update triple.rs
yang20150702 May 16, 2023
2c567a7
Update mod.rs
yang20150702 May 16, 2023
695a880
refactor(triple): rm unused var in clientBuilder
yang20150702 May 16, 2023
e9a9935
refactor(dubbo): delete some codes
yang20150702 May 16, 2023
1c79aee
refactor(cluster): rm some duplicate codes
yang20150702 May 18, 2023
06cb969
refactor(registry): rm unused import
yang20150702 May 18, 2023
18a6140
refactor(triple): use two build func for different usage
yang20150702 May 18, 2023
86de421
Merge branch 'main' into feat/cluster
yang20150702 May 18, 2023
7dbe5f3
style: cargo fmt --all
yang20150702 May 18, 2023
58c6f7d
refactor(cluster): rm registryWrapper
yang20150702 May 19, 2023
157b6c4
refactor(cluster): delete print
yang20150702 May 19, 2023
aa554fe
chore(dubbo): upgrade hyper version in cargo.toml
yang20150702 May 20, 2023
254fe59
refactor(cluster): comment the logic of clone body
yang20150702 May 22, 2023
b24e730
Rft(triple): remove Clone of Invoker
yang20150702 Jul 29, 2023
6999bbb
Rft(cluster): use ready_cache to manage Invokers, add ready_cache in …
yang20150702 Jul 29, 2023
0a5ee22
Rft(protocol): use interface Inheritance to redesign Invoker
yang20150702 Jul 29, 2023
ebfe5c1
Merge branch 'apache:main' into main
yang20150702 Jul 29, 2023
29f83c4
Merge branch 'main' into feat/cluster
yang20150702 Jul 29, 2023
b2e829c
Feat(cluster): Cluster Policy Impl (#146)
yang20150702 Aug 1, 2023
4eff1ad
Merge branch 'apache:feat/cluster' into feat/cluster
yang20150702 Aug 16, 2023
df0e0e5
chore(github): rm workflow_dispatch in workflow (#149)
yang20150702 Aug 16, 2023
c07b96d
feat: Add Router Module(#144) (#153)
AdachiAndShimamura Sep 1, 2023
556d8b7
Ftr: failover cluster (#156)
onewe Sep 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
pull_request:
branches: ["*"]

workflow_dispatch:

jobs:
check:
Expand Down
35 changes: 34 additions & 1 deletion application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,37 @@ dubbo:
references:
GreeterClientImpl:
url: tri://localhost:20000
protocol: tri
protocol: tri
routers:
consumer:
- service: "org.apache.dubbo.sample.tri.Greeter"
url: triple://localhost:20000
protocol: triple
nacos:
addr: "127.0.0.1:8848"
namespace: ""
app: ""
conditions:
- scope: "service"
force: false
runtime: true
enabled: true
key: "org.apache.dubbo.sample.tri.Greeter"
conditions:
- method=greet => port=8889
- scope: "service"
force: true
runtime: true
enabled: true
key: "user.UserService"
conditions:
- method=get_s => port=2003
tags:
force: true
enabled: true
key: shop-detail
tags:
- name: gray
matches:
- key: env
value: gray
6 changes: 5 additions & 1 deletion config/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

use std::{collections::HashMap, env, path::PathBuf};

use crate::{protocol::Protocol, registry::RegistryConfig};
use crate::{protocol::Protocol, registry::RegistryConfig, router::RouterConfig};
use dubbo_logger::tracing;
use dubbo_utils::yaml_util::yaml_file_parser;
use once_cell::sync::OnceCell;
Expand All @@ -44,6 +44,9 @@ pub struct RootConfig {
#[serde(default)]
pub registries: HashMap<String, RegistryConfig>,

#[serde(default)]
pub routers: RouterConfig,

#[serde(default)]
pub data: HashMap<String, String>,
}
Expand All @@ -63,6 +66,7 @@ impl RootConfig {
protocols: HashMap::new(),
registries: HashMap::new(),
provider: ProviderConfig::new(),
routers: RouterConfig::default(),
data: HashMap::new(),
}
}
Expand Down
1 change: 1 addition & 0 deletions config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ pub mod config;
pub mod protocol;
pub mod provider;
pub mod registry;
pub mod router;
pub mod service;
67 changes: 67 additions & 0 deletions config/src/router.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, PartialEq, Clone, Default)]
pub struct ConditionRouterConfig {
pub scope: String,
pub force: bool,
pub runtime: bool,
pub enabled: bool,
pub key: String,
pub conditions: Vec<String>,
}

#[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq)]
pub struct TagRouterConfig {
pub force: bool,
pub enabled: bool,
pub key: String,
pub tags: Vec<Tag>,
}

#[derive(Serialize, Deserialize, Clone, PartialEq, Default, Debug)]
pub struct ConsumerConfig {
pub service: String,
pub url: String,
pub protocol: String,
}

#[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq)]
pub struct Tag {
pub name: String,
pub matches: Vec<TagMatchRule>,
}

#[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq)]
pub struct TagMatchRule {
pub key: String,
pub value: String,
}

impl ConditionRouterConfig {
pub fn new(config: &String) -> Self {
serde_yaml::from_str(config).expect("parse error")
}
}

#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct EnableAuth {
pub auth_username: String,
pub auth_password: String,
}

#[derive(Serialize, Deserialize, Debug, Default, Clone, PartialEq)]
pub struct NacosConfig {
pub addr: String,
pub namespace: String,
pub app: String,
pub enable_auth: Option<EnableAuth>,
pub enable_auth_plugin_http: Option<bool>,
}

#[derive(Serialize, Deserialize, Debug, PartialEq, Clone, Default)]
pub struct RouterConfig {
pub consumer: Option<Vec<ConsumerConfig>>,
pub nacos: Option<NacosConfig>,
pub conditions: Option<Vec<ConditionRouterConfig>>,
pub tags: Option<TagRouterConfig>,
}
8 changes: 7 additions & 1 deletion dubbo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ hyper = { version = "0.14.26", features = ["full"] }
http = "0.2"
tower-service.workspace = true
http-body = "0.4.4"
tower = { workspace = true, features = ["timeout"] }
tower = { workspace = true, features = ["timeout", "ready-cache"] }
futures-util = "0.3.23"
futures-core ="0.3.23"
argh = "0.1"
Expand All @@ -40,8 +40,14 @@ urlencoding.workspace = true
lazy_static.workspace = true
dubbo-base.workspace = true
dubbo-logger.workspace = true
once_cell.workspace = true

dubbo-config = { path = "../config", version = "0.3.0" }

#对象存储
state = { version = "0.5", features = ["tls"] }

thiserror = "1.0.48"
regex = "1.9.1"
nacos-sdk = { version = "0.3.0", features = ["default"] }
serde_yaml = "0.9.22"
10 changes: 4 additions & 6 deletions dubbo/src/cluster/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use std::{

use crate::{
codegen::TripleInvoker,
invocation::{Invocation, RpcInvocation},
protocol::BoxInvoker,
registry::{memory_registry::MemoryNotifyListener, BoxRegistry},
};
Expand All @@ -51,7 +50,7 @@ impl StaticDirectory {
panic!("http uri parse error: {}, host: {}", err, host)
}
};
StaticDirectory { uri: uri }
StaticDirectory { uri }
}

pub fn from_uri(uri: &http::Uri) -> StaticDirectory {
Expand All @@ -60,12 +59,12 @@ impl StaticDirectory {
}

impl Directory for StaticDirectory {
fn list(&self, invocation: Arc<RpcInvocation>) -> Vec<BoxInvoker> {
fn list(&self, service_name: String) -> Vec<BoxInvoker> {
let url = Url::from_url(&format!(
"tri://{}:{}/{}",
self.uri.host().unwrap(),
self.uri.port().unwrap(),
invocation.get_target_service_unique_name(),
service_name,
))
.unwrap();
let invoker = Box::new(TripleInvoker::new(url));
Expand All @@ -89,8 +88,7 @@ impl RegistryDirectory {
}

impl Directory for RegistryDirectory {
fn list(&self, invocation: Arc<RpcInvocation>) -> Vec<BoxInvoker> {
let service_name = invocation.get_target_service_unique_name();
fn list(&self, service_name: String) -> Vec<BoxInvoker> {

let url = Url::from_url(&format!(
"triple://{}:{}/{}",
Expand Down
Loading
Loading