Etcd
Etcd services support.
Capabilities
This service can be used to:
- stat
- read
- write
- create_dir
- delete
- copy
- rename
-
list -
presign - blocking
Configuration
root
: Set the working directory ofOpenDAL
endpoints
: Set the network address of etcd serversusername
: Set the username of Etcdpassword
: Set the password for authenticationca_path
: Set the ca path to the etcd connectioncert_path
: Set the cert path to the etcd connectionkey_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
- Rust
- Node.js
- Python
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(())
}
import { Operator } from "opendal";
async function main() {
const op = new Operator("etcd", {
root: "/path/to/dir",
endpoint: "http://127.0.0.1:2379",
username: "your_username",
password: "your_password",
});
}
import opendal
op = opendal.Operator("etcd",
root="/path/to/dir",
endpoint="http://127.0.0.1:2379",
username="your_username",
password="your_password",
)