A python client for Etcd https://github.com/coreos/etcd This module will only work correctly with the etcd server version 2.3.x or later.
Project description
k3etcd
A python client for Etcd https://github.com/coreos/etcd This module will only work correctly with the etcd server version 2.3.x or later.
k3etcd is a component of pykit3 project: a python3 toolkit set.
Description
A python client for Etcd https://github.com/coreos/etcd
This module will only work correctly with the etcd server version 2.3.x or later.
Install
pip install k3etcd
Synopsis
import k3etcd
hosts=(
('192.168.0.100', 2379),
('192.168.0.101', 2379),
('192.168.0.102', 2379),
)
try:
c = k3etcd.Client(host=hosts)
c.set('test_key', 'test_val')
res = c.get('test_key')
# type(res) is EtcdKeysResult
# res.key == 'test_key'
# res.value == 'test_val'
# res.dir == False
# ...
# c.st_leader
# out type is `dict`
# {
# "leader": "991200c666cc4678",
# "followers":{
# "183ebbe2e22ee250": {
# "latency": {
# "current": 0.00095,
# "average": 0.09798531413612557,
# "standardDeviation": 1.3282931634902915,
# "minimum": 0.000635,
# "maximum": 18.407235
# },
# "counts": {
# "fail": 0,
# "success": 191
# }
# },
# "291578612bc6deb": {
# "latency": {
# "current": 0.000949,
# "average": 0.001928250000000001,
# "standardDeviation": 0.0018525034545722491,
# "minimum": 0.000876,
# "maximum": 0.017505
# },
# "counts": {
# "fail": 0,
# "success": 188
# }
# },
# }
# }
# c.st_self
# out type is `dict`
# {
# "name": "node_1",
# "id": "991200c666cc4678",
# "state": "StateLeader",
# "startTime": "2017-06-14T05:20:04.334273309Z",
# "leaderInfo": {
# "leader": "991200c666cc4678",
# "uptime": "4h41m55.43860796s",
# "startTime": "2017-06-14T05:20:04.477688456Z"
# },
# "recvAppendRequestCnt": 0,
# "sendAppendRequestCnt": 736
# }
# c.st_store
# out type is `dict`
# {
# "getsSuccess": 4,
# "getsFail": 7,
# "setsSuccess": 53,
# "setsFail": 0,
# "deleteSuccess": 24,
# "deleteFail": 2,
# "updateSuccess": 2,
# "updateFail": 0,
# "createSuccess": 7,
# "createFail": 1,
# "compareAndSwapSuccess": 3,
# "compareAndSwapFail": 1,
# "compareAndDeleteSuccess": 0,
# "compareAndDeleteFail": 0,
# "expireCount": 3,
# "watchers": 0
# }
n = c.names
# get names of etcd servers
# n=['node1', 'node2', 'node3']
ids = c.ids
# get ids of etcd servers
# ids=['fca771384ed46928', '991200c666cc4678', '4768ce54ee212c95']
peerurls = ['http://192.168.0.103:2380']
c.add_member(*peerurls)
# only register new node
# after it, start the server
peerurls = ['http://192.168.0.102:4380']
c.change_peerurls('fca771384ed46928', *peerurls)
except k3etcd.EtcdException as e:
print(repr(e))
Author
Zhang Yanpo (张炎泼) drdr.xp@gmail.com
Copyright and License
The MIT License (MIT)
Copyright (c) 2015 Zhang Yanpo (张炎泼) drdr.xp@gmail.com
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file k3etcd-0.1.0.tar.gz
.
File metadata
- Download URL: k3etcd-0.1.0.tar.gz
- Upload date:
- Size: 15.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54867a182cec357feeac3588077f88443b134264fbce968560fcfe45bfa7b5ae |
|
MD5 | bac45eda07239dc8c2694a3bcfa80d46 |
|
BLAKE2b-256 | f1bdb36e5b9b0570530ae5b066ca125d3ee9521d41cf9b83f1d4e229a56df48e |
File details
Details for the file k3etcd-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: k3etcd-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3716ff42e9838db88dba6ba26f9b3b95d10e36c4bd62f4890fd7086a1bd68300 |
|
MD5 | 3f7d3554b924ef71dd7726e458f7ad8e |
|
BLAKE2b-256 | c4d1e0b10658554fa6a438dc7c850c97d63c9e2defb6005077fae47086aea8f3 |