Temporal.io Dynamic Worker Spawner (TDWS) is a temporal worker that downloads workflows and activities from a remote git repository and loads them into the worker.
We wanted a tool that could spawn a worker but use different workflows and activities based on the environment. Since this would require us to write a separate worker for each environment, we decided to write a tool that could spawn a worker and download the workflows and activities from a remote git repository, convert them into plugins and then load them into the worker.
- TDWS is started with a configuration file that contains the "modules" that the worker should load. A module is a git repository that contains workflows and activities. (If you don't have a git repository, you can place the modules in the storage directory that is specified in the configuration file (default is ./tdws-storage))
- TDWS clones the git repository and builds a plugin out of main.go in the repository.
- TDWS loads the plugin and calls the TdwsRegister function with the worker as an argument.
- The TdwsRegister function registers the workflows and activities with the worker.
- TDWS then starts the worker.
TDWS is configured using a configuration file. The configuration file is a json file called tdws.json, but this can be set using the TDWS_CONFIG_FILE environment variable. See config.go for the configuration struct.
See tdws-demo-module-go for example and information.
go build -o tdws cmd/tdws/main.go