etcd_client 0.0.1-beta copy "etcd_client: ^0.0.1-beta" to clipboard
etcd_client: ^0.0.1-beta copied to clipboard

client for etcd db

example/etcd_client_example.dart

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();
}
0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

client for etcd db

License

unknown (license)

Dependencies

http

More

Packages that depend on etcd_client