Skip to main content

k3etcd

Action-CI Documentation Status Package

A python client for the Etcd v2 API https://github.com/coreos/etcd It works with the etcd server version 2.3.x to 3.5.x.

k3etcd is a component of pykit3 project: a python3 toolkit set.

Python client for the etcd v2 API. It works with etcd server 2.3.x to 3.5.x.

etcd 3.4 and 3.5 serve the v2 API when started with --enable-v2. etcd 3.6 removed the v2 API.

Use protocol="https" with basic_auth_account, so that the account is encrypted on the network.

See: https://github.com/coreos/etcd

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

Metadata

Release files for k3etcd 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for k3etcd 0.2.2
File Size Uploaded
k3etcd-0.2.2.tar.gz 23.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for k3etcd 0.2.2
File Interpreter ABI Platform
k3etcd-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 39.6 kB

Release files / k3etcd-0.2.2.tar.gz

Download URL k3etcd-0.2.2.tar.gz
Size 23.7 kB
Tags Source
SHA-256 checksum
How to use checksums
1d79a33d85f907afdc6ba50034c0f5214a09545e6ec8939d11bdc402aa6d41fa
BLAKE2b-256 checksum
How to use checksums
6ba8644d6da5695ad9ecc876143346284a6f0b2b54d8790b200268a0a13e72c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / k3etcd-0.2.2-py3-none-any.whl

Download URL k3etcd-0.2.2-py3-none-any.whl
Size 15.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9197546da1874387b08ae90de45931b00cf20d6f43eae7e8bd8ebc258aeda7a2
BLAKE2b-256 checksum
How to use checksums
bd0d1f563dcdd80a00983f86822da5217031d3a2552013aa22e64ebf0d8c7011
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release history Release notifications | RSS feed

0.2.3

2 release files

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page