From 02ba9016ab6eca5bb4964549de002573d5a3a07a Mon Sep 17 00:00:00 2001 From: Roberto Hidalgo Date: Fri, 5 May 2023 16:18:24 -0600 Subject: register consul services against local agent instead of catalog api --- src/util/config.rs | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/util') diff --git a/src/util/config.rs b/src/util/config.rs index 95835bbb..4b32f8ba 100644 --- a/src/util/config.rs +++ b/src/util/config.rs @@ -56,6 +56,9 @@ pub struct Config { /// Configuration for automatic node discovery through Consul #[serde(default)] pub consul_discovery: Option, + /// Configuration for automatic node discovery through Consul + #[serde(default)] + pub consul_service_discovery: Option, /// Configuration for automatic node discovery through Kubernetes #[serde(default)] pub kubernetes_discovery: Option, @@ -152,6 +155,24 @@ pub struct ConsulDiscoveryConfig { pub tls_skip_verify: bool, } +#[derive(Deserialize, Debug, Clone)] +pub struct ConsulServiceConfig { + /// Consul http or https address to connect to to discover more peers + pub consul_http_addr: String, + /// Token to use for connecting to consul + pub consul_http_token: Option, + /// Consul service name to use + pub service_name: String, + /// CA TLS certificate to use when connecting to Consul + pub ca_cert: Option, + // Additional tags to add to the service + #[serde(default)] + pub tags: Vec, + /// Skip TLS hostname verification + #[serde(default)] + pub tls_skip_verify: bool, +} + #[derive(Deserialize, Debug, Clone)] pub struct KubernetesDiscoveryConfig { /// Kubernetes namespace the service discovery resources are be created in @@ -344,7 +365,7 @@ mod tests { replication_mode = "3" rpc_bind_addr = "[::]:3901" rpc_secret_file = "{}" - + [s3_api] s3_region = "garage" api_bind_addr = "[::]:3900" @@ -388,7 +409,7 @@ mod tests { rpc_bind_addr = "[::]:3901" rpc_secret= "dummy" rpc_secret_file = "dummy" - + [s3_api] s3_region = "garage" api_bind_addr = "[::]:3900" -- cgit v1.2.3 From bd6485565e78c0bbb9ee830c4e5b114c6248dc97 Mon Sep 17 00:00:00 2001 From: Roberto Hidalgo Date: Mon, 8 May 2023 19:29:47 -0600 Subject: allow additional ServiceMeta, docs --- src/util/config.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/util') diff --git a/src/util/config.rs b/src/util/config.rs index 4b32f8ba..84a8e34f 100644 --- a/src/util/config.rs +++ b/src/util/config.rs @@ -168,6 +168,9 @@ pub struct ConsulServiceConfig { // Additional tags to add to the service #[serde(default)] pub tags: Vec, + // Additional service metadata to add + #[serde(default)] + pub meta: Option>, /// Skip TLS hostname verification #[serde(default)] pub tls_skip_verify: bool, -- cgit v1.2.3 From fd7dbea5b86ed8757e76e1114e2154538c5a3c16 Mon Sep 17 00:00:00 2001 From: Roberto Hidalgo Date: Wed, 10 May 2023 13:20:39 -0600 Subject: follow feedback, fold into existing feature --- src/util/config.rs | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'src/util') diff --git a/src/util/config.rs b/src/util/config.rs index 84a8e34f..632d22ef 100644 --- a/src/util/config.rs +++ b/src/util/config.rs @@ -56,9 +56,6 @@ pub struct Config { /// Configuration for automatic node discovery through Consul #[serde(default)] pub consul_discovery: Option, - /// Configuration for automatic node discovery through Consul - #[serde(default)] - pub consul_service_discovery: Option, /// Configuration for automatic node discovery through Kubernetes #[serde(default)] pub kubernetes_discovery: Option, @@ -138,8 +135,23 @@ pub struct AdminConfig { pub trace_sink: Option, } +#[derive(Deserialize, Debug, Clone)] +pub enum ConsulDiscoveryMode { + #[serde(rename_all = "lowercase")] + Node, + Service, +} +impl ConsulDiscoveryMode { + fn default() -> Self { + ConsulDiscoveryMode::Node + } +} + #[derive(Deserialize, Debug, Clone)] pub struct ConsulDiscoveryConfig { + /// Mode of consul operation: either `node` (the default) or `service` + #[serde(default = "ConsulDiscoveryMode::default")] + pub mode: ConsulDiscoveryMode, /// Consul http or https address to connect to to discover more peers pub consul_http_addr: String, /// Consul service name to use @@ -150,30 +162,17 @@ pub struct ConsulDiscoveryConfig { pub client_cert: Option, /// Client TLS key to use when connecting to Consul pub client_key: Option, + /// /// Token to use for connecting to consul + pub consul_http_token: Option, /// Skip TLS hostname verification #[serde(default)] pub tls_skip_verify: bool, -} - -#[derive(Deserialize, Debug, Clone)] -pub struct ConsulServiceConfig { - /// Consul http or https address to connect to to discover more peers - pub consul_http_addr: String, - /// Token to use for connecting to consul - pub consul_http_token: Option, - /// Consul service name to use - pub service_name: String, - /// CA TLS certificate to use when connecting to Consul - pub ca_cert: Option, - // Additional tags to add to the service + /// Additional tags to add to the service #[serde(default)] pub tags: Vec, - // Additional service metadata to add + /// Additional service metadata to add #[serde(default)] pub meta: Option>, - /// Skip TLS hostname verification - #[serde(default)] - pub tls_skip_verify: bool, } #[derive(Deserialize, Debug, Clone)] -- cgit v1.2.3 From 6b69404f1a53b927b4ce3cabdbb41f58e832a963 Mon Sep 17 00:00:00 2001 From: Roberto Hidalgo Date: Wed, 10 May 2023 20:11:14 -0600 Subject: rename mode to consul_http_api --- src/util/config.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/util') diff --git a/src/util/config.rs b/src/util/config.rs index 632d22ef..8b723e47 100644 --- a/src/util/config.rs +++ b/src/util/config.rs @@ -136,22 +136,22 @@ pub struct AdminConfig { } #[derive(Deserialize, Debug, Clone)] -pub enum ConsulDiscoveryMode { +pub enum ConsulDiscoveryAPI { #[serde(rename_all = "lowercase")] - Node, - Service, + Catalog, + Agent, } -impl ConsulDiscoveryMode { +impl ConsulDiscoveryAPI { fn default() -> Self { - ConsulDiscoveryMode::Node + ConsulDiscoveryAPI::Catalog } } #[derive(Deserialize, Debug, Clone)] pub struct ConsulDiscoveryConfig { - /// Mode of consul operation: either `node` (the default) or `service` - #[serde(default = "ConsulDiscoveryMode::default")] - pub mode: ConsulDiscoveryMode, + /// The consul api to use when registering: either `catalog` (the default) or `agent` + #[serde(default = "ConsulDiscoveryAPI::default")] + pub consul_http_api: ConsulDiscoveryAPI, /// Consul http or https address to connect to to discover more peers pub consul_http_addr: String, /// Consul service name to use -- cgit v1.2.3 From b7705041268e49f2a5ba9a719372048f85c3de83 Mon Sep 17 00:00:00 2001 From: Roberto Hidalgo Date: Mon, 15 May 2023 16:15:56 -0600 Subject: simplify code according to feedback --- src/util/config.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/util') diff --git a/src/util/config.rs b/src/util/config.rs index 8b723e47..647c2659 100644 --- a/src/util/config.rs +++ b/src/util/config.rs @@ -135,23 +135,18 @@ pub struct AdminConfig { pub trace_sink: Option, } -#[derive(Deserialize, Debug, Clone)] +#[derive(Deserialize, Debug, Clone, Default)] +#[serde(rename_all = "lowercase")] pub enum ConsulDiscoveryAPI { - #[serde(rename_all = "lowercase")] + #[default] Catalog, Agent, } -impl ConsulDiscoveryAPI { - fn default() -> Self { - ConsulDiscoveryAPI::Catalog - } -} #[derive(Deserialize, Debug, Clone)] pub struct ConsulDiscoveryConfig { /// The consul api to use when registering: either `catalog` (the default) or `agent` - #[serde(default = "ConsulDiscoveryAPI::default")] - pub consul_http_api: ConsulDiscoveryAPI, + pub api: ConsulDiscoveryAPI, /// Consul http or https address to connect to to discover more peers pub consul_http_addr: String, /// Consul service name to use @@ -163,7 +158,7 @@ pub struct ConsulDiscoveryConfig { /// Client TLS key to use when connecting to Consul pub client_key: Option, /// /// Token to use for connecting to consul - pub consul_http_token: Option, + pub token: Option, /// Skip TLS hostname verification #[serde(default)] pub tls_skip_verify: bool, -- cgit v1.2.3 From ef8a7add0865b593836736af64b8577c5375d531 Mon Sep 17 00:00:00 2001 From: Roberto Hidalgo Date: Sat, 20 May 2023 21:25:57 -0600 Subject: set default for [consul-services] api --- src/util/config.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/util') diff --git a/src/util/config.rs b/src/util/config.rs index 647c2659..1da95b2f 100644 --- a/src/util/config.rs +++ b/src/util/config.rs @@ -146,6 +146,7 @@ pub enum ConsulDiscoveryAPI { #[derive(Deserialize, Debug, Clone)] pub struct ConsulDiscoveryConfig { /// The consul api to use when registering: either `catalog` (the default) or `agent` + #[serde(default)] pub api: ConsulDiscoveryAPI, /// Consul http or https address to connect to to discover more peers pub consul_http_addr: String, -- cgit v1.2.3