Skip to content

Commit c0f82e6

Browse files
committed
INIT
0 parents  commit c0f82e6

File tree

12 files changed

+805
-0
lines changed

12 files changed

+805
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
tdws.json
2+
/tdws
3+
tdws-storage

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Temporal.io Dynamic Worker Spawner (TDWS)
2+
3+
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.
4+
5+
## Content
6+
7+
- [Reason for TDWS](#reason-for-tdws)
8+
- [How it works](#how-it-works)
9+
- [Configuration](#configuration)
10+
- [Build a module](#build-a-module)
11+
- [Build the TDWS binary](#build-the-tdws-binary)
12+
13+
## Reason for TDWS
14+
15+
We wanted a tool that could spawn a worker but use different workflows and activities based on the environment.
16+
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.
17+
18+
## How it works
19+
20+
1. 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))
21+
2. TDWS clones the git repository and builds a plugin out of main.go in the repository.
22+
3. TDWS loads the plugin and calls the TdwsRegister function with the worker as an argument.
23+
4. The TdwsRegister function registers the workflows and activities with the worker.
24+
5. TDWS then starts the worker.
25+
26+
## Configuration
27+
28+
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.
29+
See [config.go](internal/config/config.go) for the configuration struct.
30+
31+
## Build a module
32+
33+
See [tdws-demo-module-go](https://github.com/codekuu/tdws-demo-module-go) for example and information.
34+
35+
## Build the TDWS binary (Will be provided in each release in the future)
36+
37+
`go build -o tdws cmd/tdws/main.go`

cmd/tdws/main.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package main
2+
3+
import (
4+
"github.com/codekuu/tdws/internal/config"
5+
"github.com/codekuu/tdws/internal/download"
6+
"github.com/codekuu/tdws/internal/workers"
7+
)
8+
9+
func main() {
10+
// Load the configuration
11+
cfg := config.LoadConfig()
12+
13+
// Download the Workflows and Activities
14+
download.WorkflowsActivities(cfg)
15+
16+
// Start the workers
17+
workers.Start(cfg)
18+
}

go.mod

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
module github.com/codekuu/tdws
2+
3+
go 1.22.2
4+
5+
require (
6+
github.com/go-git/go-git/v5 v5.12.0
7+
github.com/rs/zerolog v1.33.0
8+
go.temporal.io/sdk v1.28.1
9+
)
10+
11+
require (
12+
dario.cat/mergo v1.0.0 // indirect
13+
github.com/Microsoft/go-winio v0.6.1 // indirect
14+
github.com/ProtonMail/go-crypto v1.0.0 // indirect
15+
github.com/cloudflare/circl v1.3.7 // indirect
16+
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
17+
github.com/davecgh/go-spew v1.1.1 // indirect
18+
github.com/emirpasic/gods v1.18.1 // indirect
19+
github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a // indirect
20+
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
21+
github.com/go-git/go-billy/v5 v5.5.0 // indirect
22+
github.com/gogo/protobuf v1.3.2 // indirect
23+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
24+
github.com/golang/mock v1.6.0 // indirect
25+
github.com/google/uuid v1.6.0 // indirect
26+
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect
27+
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
28+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
29+
github.com/kevinburke/ssh_config v1.2.0 // indirect
30+
github.com/mattn/go-colorable v0.1.13 // indirect
31+
github.com/mattn/go-isatty v0.0.19 // indirect
32+
github.com/nexus-rpc/sdk-go v0.0.9 // indirect
33+
github.com/pborman/uuid v1.2.1 // indirect
34+
github.com/pjbgf/sha1cd v0.3.0 // indirect
35+
github.com/pmezard/go-difflib v1.0.0 // indirect
36+
github.com/robfig/cron v1.2.0 // indirect
37+
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
38+
github.com/skeema/knownhosts v1.2.2 // indirect
39+
github.com/stretchr/objx v0.5.2 // indirect
40+
github.com/stretchr/testify v1.9.0 // indirect
41+
github.com/xanzy/ssh-agent v0.3.3 // indirect
42+
go.temporal.io/api v1.36.0 // indirect
43+
golang.org/x/crypto v0.25.0 // indirect
44+
golang.org/x/exp v0.0.0-20231127185646-65229373498e // indirect
45+
golang.org/x/mod v0.17.0 // indirect
46+
golang.org/x/net v0.27.0 // indirect
47+
golang.org/x/sync v0.7.0 // indirect
48+
golang.org/x/sys v0.22.0 // indirect
49+
golang.org/x/text v0.16.0 // indirect
50+
golang.org/x/time v0.3.0 // indirect
51+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
52+
google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d // indirect
53+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240711142825-46eb208f015d // indirect
54+
google.golang.org/grpc v1.65.0 // indirect
55+
google.golang.org/protobuf v1.34.2 // indirect
56+
gopkg.in/warnings.v0 v0.1.2 // indirect
57+
gopkg.in/yaml.v3 v3.0.1 // indirect
58+
)

0 commit comments

Comments
 (0)