{ "info": { "author": "Matthias Urlichs", "author_email": "matthias@urlichs.de", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3", "Topic :: Database :: Front-Ends", "Topic :: Software Development :: Libraries", "Topic :: System :: Distributed Computing" ], "description": "python-aio-etcd documentation\n=============================\n\nA python client for Etcd https://github.com/coreos/etcd\n\nOfficial documentation: http://python-aio-etcd.readthedocs.org/\n\n.. image:: https://travis-ci.org/M-o-a-T/python-aio-etcd.png?branch=master\n :target: https://travis-ci.org/M-o-a-T/python-aio-etcd\n\n.. image:: https://coveralls.io/repos/M-o-a-T/python-aio-etcd/badge.svg?branch=master&service=github\n :target: https://coveralls.io/github/M-o-a-T/python-aio-etcd?branch=master\n\nInstallation\n------------\n\nPre-requirements\n~~~~~~~~~~~~~~~~\n\nThis version of python-etcd will only work correctly with the etcd server version 2.0.x or later. If you are running an older version of etcd, please use python-etcd 0.3.3 or earlier.\n\nThis client is known to work with python 3.5. It will not work in older versions of python due to ist use of \"async def\" syntax.\n\nPython 2 is not supported.\n\nFrom source\n~~~~~~~~~~~\n\n.. code:: bash\n\n $ python setup.py install\n\nUsage\n-----\n\nThe basic methods of the client have changed compared to previous versions, to reflect the new API structure; however a compatibility layer has been maintained so that you don't necessarily need to rewrite all your existing code.\n\nCreate a client object\n~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n import aio_etcd as etcd\n\n client = etcd.Client() # this will create a client against etcd server running on localhost on port 4001\n client = etcd.Client(port=4002)\n client = etcd.Client(host='127.0.0.1', port=4003)\n client = etcd.Client(host=(('127.0.0.1', 4001), ('127.0.0.1', 4002), ('127.0.0.1', 4003)))\n client = etcd.Client(host='127.0.0.1', port=4003, allow_redirect=False) # wont let you run sensitive commands on non-leader machines, default is true\n # If you have defined a SRV record for _etcd._tcp.example.com pointing to the clients\n client = etcd.Client(srv_domain='example.com', protocol=\"https\")\n\n # create a client against https://api.example.com:443/etcd\n client = etcd.Client(host='api.example.com', protocol='https', port=443, version_prefix='/etcd')\n\nWrite a key\n~~~~~~~~~~~\n\n.. code:: python\n\n await client.write('/nodes/n1', 1)\n # with ttl\n\n await client.set('/nodes/n1', 1)\n # Equivalent, for compatibility reasons.\n\n await client.write('/nodes/n2', 2, ttl=4)\n # sets the ttl to 4 seconds\n\nRead a key\n~~~~~~~~~~\n\n.. code:: python\n\n (await client.read('/nodes/n2')).value\n # read a value\n\n (await client.get('/nodes/n2')).value\n # Equivalent, for compatibility reasons.\n\n await client.read('/nodes', recursive = True)\n # get all the values of a directory, recursively.\n\n # raises etcd.EtcdKeyNotFound when key not found\n try:\n client.read('/invalid/path')\n except etcd.EtcdKeyNotFound:\n # do something\n print \"error\"\n\n\nDelete a key\n~~~~~~~~~~~~\n\n.. code:: python\n\n await client.delete('/nodes/n1')\n\nAtomic Compare and Swap\n~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n await client.write('/nodes/n2', 2, prevValue = 4)\n # will set /nodes/n2 's value to 2 only if its previous value was 4\n\n await client.write('/nodes/n2', 2, prevExist = False)\n # will set /nodes/n2 's value to 2 only if the key did not exist before\n\n await client.write('/nodes/n2', 2, prevIndex = 30)\n # will set /nodes/n2 's value to 2 only if the key was last modified at index 30\n\n await client.test_and_set('/nodes/n2', 2, 4)\n #equivalent to client.write('/nodes/n2', 2, prevValue = 4)\n\nYou can also atomically update a result:\n\n.. code:: python\n\n await client.write('/foo','bar')\n result = await client.read('/foo')\n print(result.value) # bar\n result.value += u'bar'\n updated = await client.update(result)\n # if any other client wrote to '/foo' in the meantime this will fail\n\n print(updated.value) # barbar\n\nWatch a key\n~~~~~~~~~~~\n\n.. code:: python\n\n result = await client.read('/nodes/n1')\n # start from a known initial value\n\n result = await client.read('/nodes/n1', wait = True, waitIndex = result.modifiedIndex+1)\n # will wait till the key is changed, and return once it's changed\n\n result = await client.read('/nodes/n1', wait = True, waitIndex = 10)\n # get all changes on this key starting from index 10\n\n result = await client.watch('/nodes/n1')\n # equivalent to client.read('/nodes/n1', wait = True)\n\n result = await client.watch('/nodes/n1', index = result.modifiedIndex+1)\n\nIf you want to time out the read() call, wrap it in `asyncio.wait_for`:\n\n.. code:: python\n\n result = await asyncio.wait_for(client.read('/nodes/n1', wait=True), timeout=30)\n\nRefreshing key TTL\n~~~~~~~~~~~~~~~~~~\n\n(Since etcd 2.3.0) Keys in etcd can be refreshed without notifying current watchers.\n\nThis can be achieved by setting the refresh to true when updating a TTL.\n\nYou cannot update the value of a key when refreshing it.\n\n.. code:: python\n\n client.write('/nodes/n1', 'value', ttl=30) # sets the ttl to 30 seconds\n client.refresh('/nodes/n1', ttl=600) # refresh ttl to 600 seconds, without notifying current watchers\n\nLocking module\n~~~~~~~~~~~~~~\n\n.. code:: python\n\n # Initialize the lock object:\n # NOTE: this does not acquire a lock\n from aio_etcd.lock import Lock\n client = etcd.Client()\n # Or you can custom lock prefix, default is '/_locks/' if you are using HEAD\n client = etcd.Client(lock_prefix='/my_etcd_root/_locks')\n lock = etcd.Lock(client, 'my_lock_name')\n\n # Use the lock object:\n await lock.acquire(blocking=True, # will block until the lock is acquired\n lock_ttl=None) # lock will live until we release it\n lock.is_acquired # True\n await lock.acquire(lock_ttl=60) # renew a lock\n await lock.release() # release an existing lock\n lock.is_acquired # False\n\n # The lock object may also be used as a context manager:\n async with Lock(client, 'customer1') as my_lock:\n do_stuff()\n my_lock.is_acquired # True\n await my_lock.acquire(lock_ttl=60)\n my_lock.is_acquired # False\n\n\nGet machines in the cluster\n~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n machines = await client.machines()\n\nGet leader of the cluster\n~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n leaderinfo = await client.leader()\n\nGenerate a sequential key in a directory\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n x = await client.write(\"/dir/name\", \"value\", append=True)\n print(\"generated key: \" + x.key)\n # actually the whole path\n print(\"stored value: \" + x.value)\n\nList contents of a directory\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n.. code:: python\n\n #stick a couple values in the directory\n await client.write(\"/dir/name\", \"value1\", append=True)\n await client.write(\"/dir/name\", \"value2\", append=True)\n\n directory = await client.get(\"/dir/name\")\n\n # loop through a directory's children\n for result in directory.children:\n print(result.key + \": \" + result.value)\n\n # or just get the first child value\n print(directory.next(children).value)\n\nDevelopment setup\n-----------------\n\nThe usual setuptools commands are available.\n\n.. code:: bash\n\n $ python3 setup.py install\n\nTo test, you should have etcd available in your system path:\n\n.. code:: bash\n\n $ python3 setup.py test\n\nto generate documentation,\n\n.. code:: bash\n\n $ cd docs\n $ make\n\nRelease HOWTO\n-------------\n\nTo make a release\n\n 1) Update release date/version in NEWS.txt and setup.py\n 2) Run 'python setup.py sdist'\n 3) Test the generated source distribution in dist/\n 4) Upload to PyPI: 'python setup.py sdist register upload'\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/M-o-a-T/aio-etcd", "keywords": "etcd raft distributed log api client", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "aio_etcd", "package_url": "https://pypi.org/project/aio_etcd/", "platform": "", "project_url": "https://pypi.org/project/aio_etcd/", "project_urls": { "Homepage": "http://github.com/M-o-a-T/aio-etcd" }, "release_url": "https://pypi.org/project/aio_etcd/0.4.6.1/", "requires_dist": null, "requires_python": "", "summary": "An asynchronous python client for etcd", "version": "0.4.6.1" }, "last_serial": 4022947, "releases": { "0.4.3": [ { "comment_text": "", "digests": { "md5": "aceda2530abd0c931366c03b66543b75", "sha256": "1ddd47438808dfaafdb160567513280856ec15101baf5f64442e3ebe43c3d34c" }, "downloads": -1, "filename": "aio_etcd-0.4.3.tar.gz", "has_sig": false, "md5_digest": "aceda2530abd0c931366c03b66543b75", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16988, "upload_time": "2015-12-12T12:05:03", "url": "https://files.pythonhosted.org/packages/73/5b/ee3137a6949a21f9c9982785aacac083aede28ef7c37a2cec18806a34c35/aio_etcd-0.4.3.tar.gz" } ], "0.4.3.1": [ { "comment_text": "", "digests": { "md5": "354c0f18be3df7bfec956a67dde673f3", "sha256": "010ba5632c36ab29d10e9436678218cd7559adb83d891a62b984469b8ff367c2" }, "downloads": -1, "filename": "aio_etcd-0.4.3.1.tar.gz", "has_sig": false, "md5_digest": "354c0f18be3df7bfec956a67dde673f3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17359, "upload_time": "2015-12-17T22:27:57", "url": "https://files.pythonhosted.org/packages/49/54/d6ca8b9453962894c5ccf35fe6a91cd663bb1acc45f57427a7be93433fd0/aio_etcd-0.4.3.1.tar.gz" } ], "0.4.5.0": [ { "comment_text": "", "digests": { "md5": "8bc5bacce6395562e98a44df1583d51a", "sha256": "4e47c2d87bb183e50a5594106c816aaad7da6343a4c9d75526bb4d7878c71720" }, "downloads": -1, "filename": "aio_etcd-0.4.5.0.tar.gz", "has_sig": false, "md5_digest": "8bc5bacce6395562e98a44df1583d51a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20315, "upload_time": "2017-03-31T06:53:04", "url": "https://files.pythonhosted.org/packages/12/15/4689c1f321454bc598e1732bd8198772efe89090c79afa21eaf85fd84a29/aio_etcd-0.4.5.0.tar.gz" } ], "0.4.6.1": [ { "comment_text": "", "digests": { "md5": "ad6e4731de650237ff81fe533582730b", "sha256": "fb32e36bb1059fc8bd006436cec6f8c246deb1461b1d052cf3ec7929fb18d88f" }, "downloads": -1, "filename": "aio_etcd-0.4.6.1.tar.gz", "has_sig": false, "md5_digest": "ad6e4731de650237ff81fe533582730b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19339, "upload_time": "2018-07-02T13:35:50", "url": "https://files.pythonhosted.org/packages/0c/25/56c6c5d6ae1a892354eda8ecd7416dbffa731d1526f8daa3b1fd19ba0fc4/aio_etcd-0.4.6.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "ad6e4731de650237ff81fe533582730b", "sha256": "fb32e36bb1059fc8bd006436cec6f8c246deb1461b1d052cf3ec7929fb18d88f" }, "downloads": -1, "filename": "aio_etcd-0.4.6.1.tar.gz", "has_sig": false, "md5_digest": "ad6e4731de650237ff81fe533582730b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 19339, "upload_time": "2018-07-02T13:35:50", "url": "https://files.pythonhosted.org/packages/0c/25/56c6c5d6ae1a892354eda8ecd7416dbffa731d1526f8daa3b1fd19ba0fc4/aio_etcd-0.4.6.1.tar.gz" } ] }