o
    i'                     @  sz   d dl mZ d dlZd dlmZ d dlmZmZmZm	Z	 d dl
mZ er2d dlmZmZmZmZmZ G dd dejZdS )	    )annotationsN)AbstractAsyncContextManager)TYPE_CHECKINGAsyncIterator	AwaitableCallable)WorkflowHistory)ReplayerReplayerConfigWorkerWorkerConfigWorkflowReplayResultc                   @  sZ   e Zd ZdZdddZejddd	ZejdddZejd ddZ	ejd!ddZ
dS )"Pluginak  Base class for worker plugins that can intercept and modify worker behavior.

    Plugins allow customization of worker creation and execution processes
    through a chain of responsibility pattern. Each plugin can modify the worker
    configuration or intercept worker execution.

    WARNING: This is an experimental feature and may change in the future.
    returnstrc                 C  s   t | jd t | j S )zGet the qualified name of this plugin. Can be overridden if desired to provide a more appropriate name.

        Returns:
            The fully qualified name of the plugin class (module.classname).
        .)type
__module____qualname__)self r   _/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/temporalio/worker/_plugin.pyname   s   zPlugin.nameconfigr   c                 C     dS )a  Hook called when creating a worker to allow modification of configuration.

        This method is called during worker creation and allows plugins to modify
        the worker configuration before the worker is fully initialized. Plugins
        can modify task queue names, adjust concurrency settings, add interceptors,
        or change other worker settings.

        Args:
            config: The worker configuration dictionary to potentially modify.

        Returns:
            The modified worker configuration.
        Nr   r   r   r   r   r   configure_worker%       zPlugin.configure_workerworkerr   next#Callable[[Worker], Awaitable[None]]Nonec                   s   dS )a  Hook called when running a worker to allow interception of execution.

        This method is called when the worker is started and allows plugins to
        intercept or wrap the worker execution. Plugins can add monitoring,
        custom lifecycle management, or other execution-time behavior.

        Args:
            worker: The worker instance to run.
            next: Callable to continue the worker execution.
        Nr   )r   r   r   r   r   r   
run_worker5   s    zPlugin.run_workerr
   c                 C  r   )a  Hook called when creating a replayer to allow modification of configuration.

        This should be used to configure anything in ReplayerConfig needed to make execution match
        the worker and client config. This could include interceptors, DataConverter, workflows, and more.

        Args:
            config: The replayer configuration dictionary to potentially modify.

        Returns:
            The modified replayer configuration.
        Nr   r   r   r   r   configure_replayerD   r   zPlugin.configure_replayerreplayerr	   	historiesAsyncIterator[WorkflowHistory]vCallable[[Replayer, AsyncIterator[WorkflowHistory]], AbstractAsyncContextManager[AsyncIterator[WorkflowReplayResult]]]@AbstractAsyncContextManager[AsyncIterator[WorkflowReplayResult]]c                 C  r   )zGHook called when running a replayer to allow interception of execution.Nr   )r   r$   r%   r   r   r   r   run_replayerR   r   zPlugin.run_replayerN)r   r   )r   r   r   r   )r   r   r   r    r   r!   )r   r
   r   r
   )r$   r	   r%   r&   r   r'   r   r(   )__name__r   r   __doc__r   abcabstractmethodr   r"   r#   r)   r   r   r   r   r      s    
	r   )
__future__r   r,   
contextlibr   typingr   r   r   r   temporalio.clientr   temporalio.workerr	   r
   r   r   r   ABCr   r   r   r   r   <module>   s    	