diff options
author | Alex Auvolat <alex@adnab.me> | 2023-02-02 15:47:20 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2023-02-02 15:47:20 +0100 |
commit | d0f40c02b9b74e6e6b852036865ad2b0c0e9370c (patch) | |
tree | cbaea0947e0bc3c6979c6015fd5166ffdfa626ac /src/lib.rs | |
parent | db1d4411a904bec2d1c2a1c4735ad09cc7f98632 (diff) | |
download | df-consul-d0f40c02b9b74e6e6b852036865ad2b0c0e9370c.tar.gz df-consul-d0f40c02b9b74e6e6b852036865ad2b0c0e9370c.zip |
Documentate
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 19 |
1 files changed, 14 insertions, 5 deletions
@@ -1,6 +1,6 @@ -mod catalog; +pub mod catalog; +pub mod locking; mod kv; -mod locking; mod with_index; use std::fs::File; @@ -10,14 +10,23 @@ use anyhow::{bail, Result}; pub use with_index::WithIndex; -pub struct ConsulConfig { +/// Configuration parameters to talk to a Consul server +pub struct Config { + /// HTTP address of the Consul server, with `http://` or `https://` prefix pub addr: String, + /// CA certificate of the Consul CA, when using TLS pub ca_cert: Option<String>, - pub tls_skip_verify: bool, + /// Client certificate for client auth when using TLS pub client_cert: Option<String>, + /// Client key for client auth when using TLS pub client_key: Option<String>, + /// Skip verification of consul server TLS certificates + pub tls_skip_verify: bool, } +/// Client used to talk to a Consul server. +/// All calls to the key/value API are automatically prefixed with an arbitrary string +/// that is constructed at client creation. #[derive(Clone)] pub struct Consul { client: reqwest::Client, @@ -27,7 +36,7 @@ pub struct Consul { } impl Consul { - pub fn new(config: ConsulConfig, kv_prefix: &str) -> Result<Self> { + pub fn new(config: Config, kv_prefix: &str) -> Result<Self> { let client = match (&config.client_cert, &config.client_key) { (Some(client_cert), Some(client_key)) => { let mut client_cert_buf = vec![]; |