Skip to main content

Etcd

Etcd services support.

Capabilities

This service can be used to:

  • stat
  • read
  • write
  • create_dir
  • delete
  • copy
  • rename
  • list
  • scan
  • presign
  • blocking

Configuration

  • root: Set the working directory of OpenDAL
  • endpoints: Set the network address of etcd servers
  • username: Set the username of Etcd
  • password: Set the password for authentication
  • ca_path: Set the ca path to the etcd connection
  • cert_path: Set the cert path to the etcd connection
  • key_path: Set the key path to the etcd connection

You can refer to [EtcdBuilder]'s docs for more information

Example

Via Builder

use anyhow::Result;
use opendal::services::Etcd;
use opendal::Operator;

#[tokio::main]
async fn main() -> Result<()> {
let mut builder = Etcd::default();

// this will build a Operator accessing etcd which runs on http://127.0.0.1:2379
let op: Operator = Operator::new(builder)?.finish();
Ok(())
}

Via Config

use anyhow::Result;
use opendal::Operator;
use opendal::Scheme;
use std::collections::HashMap;

#[tokio::main]
async fn main() -> Result<()> {
let mut map = HashMap::new();
map.insert("root".to_string(), "/path/to/dir".to_string());
map.insert("endpoints".to_string(), "http://127.0.0.1:2379".to_string());
map.insert("username".to_string(), "your_username".to_string());
map.insert("password".to_string(), "your_password".to_string());

let op: Operator = Operator::via_map(Scheme::Etcd, map)?;
Ok(())
}