I have a use case which requires to spin a new Worker on every Activity execution.
Is there any recommended pattern to do so?
My idea was to start an activity which sets up the worker and then call another Activity to run on it. Once the activity is completed the worker is closed.
This should work fine. You want to have a separate task queue for that specific worker. If you describe your use case in more detail we might provide more concrete feedback.
In the use case I run a bunch of activities from one Workflow. The Workflow may be run for different inputs which require separated configuration in that one ActivityWorker which I need to start and shutdown.
Everything runs on K8S cluster and Workers are executed as separated pods.