@@ -1514,10 +1514,10 @@ class AuthenticationPlugin(Plugin):
15141514 def __init__(self, api_key: str):
15151515 self.api_key = api_key
15161516
1517- def on_create_client (self, config: ClientConfig) -> ClientConfig:
1517+ def configure_client (self, config: ClientConfig) -> ClientConfig:
15181518 # Modify client configuration
15191519 config["namespace"] = "my-secure-namespace"
1520- return super().on_create_client (config)
1520+ return super().configure_client (config)
15211521
15221522 async def connect_service_client(
15231523 self, config: temporalio.service.ConnectConfig
@@ -1548,12 +1548,12 @@ class MonitoringPlugin(Plugin):
15481548 def __init__ (self ):
15491549 self .logger = logging.getLogger(__name__ )
15501550
1551- def on_create_worker (self , config : WorkerConfig) -> WorkerConfig:
1551+ def configure_worker (self , config : WorkerConfig) -> WorkerConfig:
15521552 # Modify worker configuration
15531553 original_task_queue = config[" task_queue" ]
15541554 config[" task_queue" ] = f " monitored- { original_task_queue} "
15551555 self .logger.info(f " Worker created for task queue: { config[' task_queue' ]} " )
1556- return super ().on_create_worker (config)
1556+ return super ().configure_worker (config)
15571557
15581558 async def run_worker (self , worker : Worker) -> None :
15591559 self .logger.info(" Starting worker execution" )
@@ -1575,36 +1575,38 @@ worker = Worker(
15751575For plugins that need to work with both clients and workers, you can implement both interfaces in a single class:
15761576
15771577``` python
1578- from temporalio.client import Plugin as ClientPlugin
1579- from temporalio.worker import Plugin as WorkerPlugin
1578+ from temporalio.client import Plugin as ClientPlugin, ClientConfig
1579+ from temporalio.worker import Plugin as WorkerPlugin, WorkerConfig
1580+
15801581
15811582class UnifiedPlugin (ClientPlugin , WorkerPlugin ):
1582- def on_create_client (self , config : ClientConfig) -> ClientConfig:
1583- # Client-side customization
1584- config[" namespace" ] = " unified-namespace"
1585- return super ().on_create_client (config)
1583+ def configure_client (self , config : ClientConfig) -> ClientConfig:
1584+ # Client-side customization
1585+ config[" namespace" ] = " unified-namespace"
1586+ return super ().configure_client (config)
15861587
1587- def on_create_worker (self , config : WorkerConfig) -> WorkerConfig:
1588- # Worker-side customization
1589- config[" max_cached_workflows" ] = 500
1590- return super ().on_create_worker(config)
1588+ def configure_worker (self , config : WorkerConfig) -> WorkerConfig:
1589+ # Worker-side customization
1590+ config[" max_cached_workflows" ] = 500
1591+ return super ().configure_worker(config)
1592+
1593+ async def run_worker (self , worker : Worker) -> None :
1594+ print (" Starting unified worker" )
1595+ await super ().run_worker(worker)
15911596
1592- async def run_worker (self , worker : Worker) -> None :
1593- print (" Starting unified worker" )
1594- await super ().run_worker(worker)
15951597
15961598# Create client with the unified plugin
15971599client = await Client.connect(
1598- " localhost:7233" ,
1599- plugins = [UnifiedPlugin()]
1600+ " localhost:7233" ,
1601+ plugins = [UnifiedPlugin()]
16001602)
16011603
16021604# Worker will automatically inherit the plugin from the client
16031605worker = Worker(
1604- client,
1605- task_queue = " my-task-queue" ,
1606- workflows = [MyWorkflow],
1607- activities = [my_activity]
1606+ client,
1607+ task_queue = " my-task-queue" ,
1608+ workflows = [MyWorkflow],
1609+ activities = [my_activity]
16081610)
16091611```
16101612
0 commit comments