etha.kvstore.etcd
=================

.. py:module:: etha.kvstore.etcd

.. autoapi-nested-parse::

   EtcdStore implementation using etcd3 library.



Attributes
----------

.. autoapisummary::

   etha.kvstore.etcd.logger


Classes
-------

.. autoapisummary::

   etha.kvstore.etcd.EtcdStore


Module Contents
---------------

.. py:class:: EtcdStore(host: str = 'localhost', port: int = 2379, timeout: float | None = None, cleanup: bool = False, namespace: str = 'default', component: str = 'tensorbus')

   Bases: :py:obj:`etha.kvstore.base.KVStore`


   KVStore implementation backed by etcd.

   Uses etcd's watch mechanism for efficient waiting.

   Initialize EtcdStore.

   :param host: etcd server host
   :param port: etcd server port
   :param timeout: Connection timeout in seconds
   :param cleanup: If True, delete all keys in this namespace on init (should only be True for rank 0)
   :param namespace: Namespace for key isolation
   :param component: Default component name


   .. py:method:: close(cleanup: bool = True) -> None

      Close the etcd client.



   .. py:method:: delete(key: str, *, component: str | None = None) -> bool

      Delete a key.



   .. py:method:: exists(key: str, *, component: str | None = None) -> bool

      Check if a key exists.



   .. py:method:: get(key: str, *, component: str | None = None) -> bytes | None

      Get value for a key.



   .. py:method:: get_bytes(key: str, *, component: str | None = None) -> bytes | None

      Retrieve binary data directly.



   .. py:method:: set(key: str, value: str, *, component: str | None = None) -> None

      Set a key-value pair.



   .. py:method:: set_bytes(key: str, data: bytes, *, component: str | None = None) -> None

      Store binary data directly.



   .. py:method:: wait_for_key(key: str, timeout: float = 3600.0, *, component: str | None = None) -> bytes

      Wait for a key to exist and return its value.



   .. py:method:: wait_for_keys(key_pattern: str, expected_count: int, value: str = '1', timeout: float = 3600.0, candidate_keys: list[str] | None = None, *, component: str | None = None) -> list[str]

      Wait for keys matching pattern using etcd watch.



   .. py:method:: wait_for_value(key: str, expected: str, timeout: float = 3600.0, *, component: str | None = None) -> bytes

      Wait for a key to have a specific value.



   .. py:attribute:: host
      :value: 'localhost'



   .. py:attribute:: port
      :value: 2379



.. py:data:: logger

