Yohohohohohooho | Sanrei Aya
Sanrei Aya


Server : LiteSpeed
System : Linux barito.iixcp.rumahweb.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64
User : elvh3918 ( 1528)
PHP Version : 8.2.31
Disable Function : mail
Directory :  /usr/local/lib/python3.9/site-packages/celery/backends/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/local/lib/python3.9/site-packages/celery/backends/__pycache__/consul.cpython-39.pyc
a

��Sh��@s�dZddlmZddlmZddlmZddlmZddl	m
Z
zddlZWneybdZYn0e
e
�ZdZd	ZGd
d�de�ZdS)z�Consul result store backend.

- :class:`ConsulBackend` implements KeyValueStoreBackend to store results
    in the key-value store of Consul.
�)�bytes_to_str)�	parse_url)�KeyValueStoreBackend)�ImproperlyConfigured)�
get_loggerN)�
ConsulBackendz^You need to install the python-consul library in order to use the Consul result store backend.csheZdZdZeZdZdZdZ�fdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�Zdd�Z�ZS)rz'Consul.io K/V store backend for Celery.TZ
consistentNcsDt�j|i|��|jdur$tt��d|_|jfit|j���dS�N)	�super�__init__�consulr�CONSUL_MISSING�
one_client�_init_from_paramsr�url)�self�args�kwargs��	__class__��@/usr/local/lib/python3.9/site-packages/celery/backends/consul.pyr
%s

zConsulBackend.__init__cKs:t�d||�||_||_||_|�dd�r6|��|_dS)Nz,Setting on Consul client to connect to %s:%dr
)�logger�debug�path�hostname�port�get�clientr
)rrrZvirtual_host�paramsrrrr3s�zConsulBackend._init_from_paramscCs|jptj|j|j|jd�S)N)�hostr�consistency)r
rZConsulrrr )rrrrrAs�zConsulBackend.clientcCs&t|�}|jdur|S|j�d|��S)N�/)rr�r�keyrrr�_key_to_consul_keyFsz ConsulBackend._key_to_consul_keycCsL|�|�}t�d|�z|��j�|�\}}|dWStyFYn0dS)Nz"Trying to fetch key %s from Consul�Value)r$rrr�kvr�	TypeError)rr#�_�datarrrrJs

zConsulBackend.getccs|D]}|�|�VqdSr)r)r�keysr#rrr�mgetSszConsulBackend.mgetcCsht|�}|�|�}t�d||j�|��}|jj|d|jd�}t�d|�t�d|�|jj	|||d�S)aMSet a key in Consul.

        Before creating the key it will create a session inside Consul
        where it creates a session with a TTL

        The key created afterwards will reference to the session's ID.

        If the session expires it will remove the key so that results
        can auto expire from the K/V store
        z.Trying to create Consul session %s with TTL %d�delete)�nameZbehaviorZttlzCreated Consul session %szWriting key %s to Consul)r#�value�acquire)
rr$rr�expiresr�session�creater&�put)rr#r.Zsession_namerZ
session_idrrr�setWs
��zConsulBackend.setcCs&|�|�}t�d|�|��j�|�S)NzRemoving key %s from Consul)r$rrrr&r,r"rrrr,qs
zConsulBackend.delete)�__name__�
__module__�__qualname__�__doc__rZsupports_autoexpirer rr
rrr$rr+r4r,�
__classcell__rrrrrs	r)r8Zkombu.utils.encodingrZkombu.utils.urlrZcelery.backends.baserZcelery.exceptionsrZcelery.utils.logrr�ImportErrorr5r�__all__rrrrrr�<module>s


Yohohohohohooho | Sanrei Aya