Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jlegrone/temporal-sdk-go-generics
A go1.18 wrapper to provide a generics based API for Temporal.
https://github.com/jlegrone/temporal-sdk-go-generics
Last synced: about 1 month ago
JSON representation
A go1.18 wrapper to provide a generics based API for Temporal.
- Host: GitHub
- URL: https://github.com/jlegrone/temporal-sdk-go-generics
- Owner: jlegrone
- License: mit
- Created: 2021-12-29T01:05:53.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-12-30T22:17:45.000Z (about 3 years ago)
- Last Synced: 2024-10-14T18:37:19.475Z (3 months ago)
- Language: Go
- Size: 45.9 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# temporal-sdk-go-generics
A go1.18 wrapper to provide a generics based API for Temporal.## Project Status
This module is strictly a thought experiment and is unlikely to be maintained. Please don't develop dependencies on it.
## Why
### Before Generics
This compiles, but will error at runtime:
```go
package helloworldimport (
"context""go.temporal.io/sdk/workflow"
)func Workflow(ctx workflow.Context) (string, error) {
var result string
// The activity should be passed a string, not an integer.
err := workflow.ExecuteActivity(ctx, Activity, 42).Get(ctx, &result)
if err != nil {
return "", err
}
return result, nil
}func Activity(ctx context.Context, name string) (string, error) {
return "Hello " + name + "!", nil
}
```### After Generics
This will fail to compile with a human readable error:
```
helloworld.go:11:55: cannot use 42 (untyped int constant) as string value in argument to workflow.NewActivityClient(Activity).Run
```The code to get the activity's return value can also now be more terse.
```go
package helloworldimport (
"context""github.com/jlegrone/temporal-sdk-go-generics/workflow"
)func Workflow(ctx workflow.Context) (string, error) {
// The activity should be passed a string, not an integer.
return workflow.NewActivityClient(Activity).Run(ctx, 42)
}func Activity(ctx context.Context, name string) (string, error) {
return "Hello " + name + "!", nil
}
```