
    >i*                         d Z ddlZddlZddlmZ ddlmZmZ ddlm	Z	 ddl
mZ  ed      Zd	Zd
ZdZ  e	de      ej"                        ZdZd Zd ZddZd Zd Zd ZddZ eedd      ZddZy)zWorker name utilities.    N)partial)ExchangeQueue   )memoize)simple_formatzC.dq2z{hostname}.dq2@celery)Cache)worker_directgethostnamenodenameanon_nodename	nodesplitdefault_nodenamenode_formathost_formatc                 p    t        | t              r| S t        t        j                  |       t        |       S )a5  Return the :class:`kombu.Queue` being a direct route to a worker.

    Arguments:
        hostname (str, ~kombu.Queue): The fully qualified node name of
            a worker (e.g., ``w1@example.com``).  If passed a
            :class:`kombu.Queue` instance it will simply return
            that instead.
    hostname)
isinstancer   WORKER_DIRECT_QUEUE_FORMATformatWORKER_DIRECT_EXCHANGEr   s    r/var/www/html/wine-match-dev/backend/winematch-backend/venv/lib/python3.12/site-packages/celery/utils/nodenames.pyr   r      s7     (E""))8)<     c                 0    t         j                  | |f      S )z)Create node name from name/hostname pair.)NODENAME_SEPjoin)namer   s     r   r   r   1   s    dH-..r   c           	          t        dj                  |t        t        j                               g      | xs
 t                     S )zsReturn the nodename for this process (not a worker).

    This is used for e.g. the origin task message field.
     )r   r   strosgetpidr   )r   prefixs     r   r   r   6   s6    
 BGGVS%567-/ /r   c                 \    | j                  t        d      }t        |      dk(  rd|d   fS |S )z,Split node name into tuple of name/hostname.r   Nr   )splitr   len)r    partss     r   r   r   ?   s0    JJ|Q'E
5zQU1X~Lr   c                 f    t        | xs d      \  }}t        |xs t        |xs
 t                     S )z-Return the default nodename for this process.r"   )r   r   NODENAME_DEFAULTr   )r   r    hosts      r   r   r   G   s.    8>r*JD$D,,d.CkmDDr   c                 N    t        |      \  }}t        | ||xs t        fd|i|S )z(Format worker node name (name@host.com).p)r   r   r,   )sr    extra	shortnamer-   s        r   r   r   M   s=    oOIt	4..A26A:?A Ar   r"   c                 0    ddl m}  |       }|r|  | S |S )Nr   )current_process_index)logr4   )r&   defaultr4   indexs       r   _fmt_process_indexr8   T   s#    *!#E!&fXeW3G3r   -c                     |xs
 t               }|j                  d      \  }}}|xs |}t        |||t        t        dfi |}t        | |      S )zFormat host %x abbreviations..)hndiI)r   	partitiondictr8   _fmt_process_index_with_prefixr   )r0   r-   r    r1   hname_domainkeyss           r   r   r   ]   sa     ;=D~~c*E1f=5D6&D  
D D!!r   )Ngen)r"   0)NN)__doc__r$   socket	functoolsr   kombu.entityr   r   
functionalr   textr   r   r   r   r,   rB   r   __all__r   r   r   r   r   r   r8   rC   r    r   r   <module>rR      s     	   (   "'*  .   $gat$V%7%78$/
/EA4 "));S"!E 	"r   