summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-02-02 15:47:20 +0100
committerAlex Auvolat <alex@adnab.me>2023-02-02 15:47:20 +0100
commitd0f40c02b9b74e6e6b852036865ad2b0c0e9370c (patch)
treecbaea0947e0bc3c6979c6015fd5166ffdfa626ac /src/lib.rs
parentdb1d4411a904bec2d1c2a1c4735ad09cc7f98632 (diff)
downloaddf-consul-d0f40c02b9b74e6e6b852036865ad2b0c0e9370c.tar.gz
df-consul-d0f40c02b9b74e6e6b852036865ad2b0c0e9370c.zip
Documentate
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 6326fa0..c320936 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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![];