File: usage.rst

package info (click to toggle)
python-etcd3 0.12.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 640 kB
  • sloc: python: 2,111; makefile: 165
file content (62 lines) | stat: -rw-r--r-- 1,150 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
=========
API Usage
=========

To use python-etcd3 in a project:

.. code-block:: python

    import etcd3

and create a client:

.. code-block:: python

    etcd = etcd3.client()

This defaults to localhost, but you can specify the host and port:

.. code-block:: python

    etcd = etcd3.client(host='etcd-host-01', port=2379)

If you would like to specify options for the underlying GRPC connection, you can also pass it as a parameter:

.. code-block:: python

    etcd = etcd3.client(grpc_options={
                            'grpc.http2.true_binary': 1,
                            'grpc.http2.max_pings_without_data': 0,
                        }.items())

Putting values into etcd
------------------------

Values can be stored with the ``put`` method:

.. code-block:: python

    etcd.put('/key', 'dooot')

You can check this has been stored correctly by testing with etcdctl:

.. code-block:: bash

    $ ETCDCTL_API=3 etcdctl get /key
    /key
    dooot

API
===

.. autoclass:: etcd3.Etcd3Client
    :members:

.. autoclass:: etcd3.Member
    :members:

.. autoclass:: etcd3.Lease
    :members:

.. autoclass:: etcd3.Lock
    :members: