etcd_client

Last updated:

0 purchases

etcd_client Image
etcd_client Images
Add to Cart

Description:

etcd client

WIP!!! #
ETCD Dart Client #
A Dart package for interacting with etcd, a distributed key-value store.
Installation #
Add etcd_client to your pubspec.yaml:
dependencies:
etcd_client: ^0.0.3-beta // Use latest version
copied to clipboard
Run dart pub get to fetch the package.
Usage
Import and initialize EtcdClient with your etcd server URL and optional credentials (username and password). Use the provided methods (put, get, update, delete) to interact with etcd.
Copy code
import 'package:etcd_client/etcd_client.dart';

void main() async {
final etcdUrl = 'http://localhost:2379'; // Replace with your etcd server URL
final etcdClient = EtcdClient(
etcdUrl: etcdUrl,
username: 'your_username',
password: 'your_password',
);

// Example of putting a key-value pair
try {
await etcdClient.put('/my/key', 'Hello, etcd!');
print('Key-value pair added successfully.');
} catch (e) {
print('Failed to add key-value pair: $e');
}

// Example of getting a value for a key
try {
final value = await etcdClient.get('/my/key');
print('Value for key /my/key: $value');
} catch (e) {
print('Failed to get value for key /my/key: $e');
}

// Example of updating a key-value pair
try {
await etcdClient.update('/my/key', 'Updated value');
print('Key-value pair updated successfully.');
} catch (e) {
print('Failed to update key-value pair: $e');
}

// Example of deleting a key
try {
await etcdClient.delete('/my/key');
print('Key deleted successfully.');
} catch (e) {
print('Failed to delete key: $e');
}

// Close the client when done
etcdClient.close();
}
copied to clipboard
API Reference #
EtcdClient class
Constructors
EtcdClient({String etcdUrl, String username, String password}): Creates a new etcd client instance.
Methods #
Future<void> put(String key, String value): Stores a key-value pair in etcd.
Future<String> get(String key): Retrieves the value associated with a key from etcd.
Future<void> update(String key, String value): Updates the value for a key in etcd.
Future<void> delete(String key): Deletes a key from etcd.
void close(): Closes the HTTP client when done.
Notes #
Replace your_username and your_password with your etcd credentials.
Ensure your etcd server URL (etcdUrl) is correct and accessible.
Handle errors and exceptions gracefully in your application.
Consider security best practices for handling credentials securely.
Contributing
Contributions are welcome! For major changes, please open an issue first to discuss what you would like to change.
License #
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments #
Thank you to the Dart community and contributors who have helped improve this package.

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.