File: //var/opt/nydus/ops/primordial/__pycache__/zkconfig.cpython-39.pyc
a
�,�hw � @ s� d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlm Z m
Z
mZ d dlm
Z
d dlmZ d dlmZ G d d
� d
e�ZdS )� N)�deque)�Any)�KazooClient)�ConnectionLoss�NoNodeError�ZookeeperError)�KazooTimeoutError)�Config)�
retry_thisc @ s� e Zd ZdZdZe�d�Zedd�dd�Z dd � Z
d
d� Zee
eejeefd�d
d� �Zdd� Zdd� Zdeeed�dd�ZdS )�ZKConfigzFConfig class that loads configuration options from a ZooKeeper clusterz/configz\s*(\S+?)\s*=\s*(\S+)\s*N)�hosts�returnc C s t |dd�| _i | _| �� d S )NT)r Z read_only)r �_client�_config�load_config)�selfr � r �D/opt/nydus/tmp/pip-target-wkfpz8uv/lib/python/primordial/zkconfig.py�__init__ s zZKConfig.__init__c C s | j �� | j S )z�
This turns this class/object into a context manager for connections to the zookeeper cluster.
This starts up the connection and returns the client as the resource being managed.
)r �start)r r r r � __enter__ s
zZKConfig.__enter__c C s0 z| j �� | j �� W n ty* Y n0 dS )ze
This method takes care of releasing the client connection to the zookeeper cluster.
N)r �stop�close� Exception)r Z _exc_typeZ_exc_valZ_exc_tbr r r �__exit__&