Git Product home page Git Product logo

etcd-py's Introduction

etcd-py

A python client to etcd (https://github.com/coreos/etcd)

Getting Started

Set, Get, Delete

>>> import etcd
>>> e = etcd.Etcd()
>>> e.set("message", "Hello, World!")
set(index=48, newKey=True, prevValue=None, expiration=None)
>>> e.get("message")
get(index=48, value=u'Hello, World!')
>>> e.delete("message")
delete(index=49, prevValue=u'Hello, World!')

Setting a key with a TTL of 3 seconds and watching it with an optional timeout of 5 seconds

>>> set("message", "HELLO WORLD!!", 3)
set(index=35, newKey=True, prevValue=None, expiration=u'2013-09-05T05:57:33.922332303Z')
>>> print e.watch("message", timeout=5)
watch(action=u'DELETE', value=None, key=u'/message', index=35, newKey=False)

Test and set

>>> e.testandset("message", "hello world", "goodbye world")
testandset(index=37, key=u'/message', prevValue=u'hello world', expiration=None)

Servers

>>> e.machines()
[u'https://127.0.0.1:4001']
>>> e.leader()
http://127.0.0.1:7001

Client certificates

>>> e = etcd.Etcd(ssl_cert="mycert.pem")
or
>>> e = etcd.Etcd(ssl_cert="my.crt", ssl_key="my.key")

TODO

  • optionally start watching from last seen index
  • recover from a failed node by testing trying the next known node
  • error handling of http calls
  • optionally do not follow redirects
  • proper unit tests
  • a CI machine

Author

etcd-py is developed and maintained by Kris Foster ([email protected])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.