- Notifications
You must be signed in to change notification settings - Fork230
temporalio/sdk-go
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Temporal is a distributed, scalable, durable, and highly available orchestration engine used to execute asynchronous long-running business logic in a scalable and resilient way.
"Temporal Go SDK" is the framework for authoring workflows and activities using Go language.
Clone this repo into the preferred location.
git clone https://github.com/temporalio/sdk-go.git
Seesamples to get started.
Documentation is availablehere.You can also find the API documentationhere.
If using Go version 1.21+ the Go SDK provides built in integration with the standardslog package.
package mainimport ("log/slog""os""go.temporal.io/sdk/client""go.temporal.io/sdk/log""go.temporal.io/sdk/worker")funcmain() {clientOptions:= client.Options{Logger:log.NewStructuredLogger(slog.New(slog.NewJSONHandler(os.Stdout,&slog.HandlerOptions{AddSource:true,Level:slog.LevelDebug,}))),}temporalClient,err:=client.Dial(clientOptions)// ...}
Seecontrib/tools/workflowcheck for a tool to detect non-determinism in Workflow Definitions.
We'd love your help in making the Temporal Go SDK great. Please review ourcontribution guidelines.
Go SDK version v1.26.0 switched from usinghttps://github.com/gogo/protobuf tohttps://github.com/golang/protobuf. While this migration is mostly internal there are a few user visible changes to be aware of:
time.Time
in proto structs will now betimestamppb.Timestamptime.Duration
will now bedurationpb.Duration- V2-generated structs embed locks, so you cannot dereference them.
Proto enums will, when formatted to JSON, now be in SCREAMING_SNAKE_CASE rather than PascalCase.* If trying to deserialize old JSON with PascalCase to proto usego.temporal.io/api/temporalproto.
If users used Temporal proto types in their Workflows, such as for activity output, users may need to modify the default data converter to handle these payloads.
converter.NewProtoJSONPayloadConverterWithOptions(converter.ProtoJSONPayloadConverterOptions{LegacyTemporalProtoCompat:true,}),
While upgrading from Go SDK version< 1.26.0
to a version>= 1.26.0
users may want to also bias towards usingproto binary to avoid any potential incompatibilities due to having clients serialize messages with incompatibleproto/json
format.
On clients running Go SDK< 1.26.0
converter.NewCompositeDataConverter(converter.NewNilPayloadConverter(),converter.NewByteSlicePayloadConverter(),converter.NewProtoPayloadConverter(),converter.NewProtoJSONPayloadConverterWithOptions(),converter.NewJSONPayloadConverter(),)
On clients running Go SDK>= 1.26.0
converter.NewCompositeDataConverter(converter.NewNilPayloadConverter(),converter.NewByteSlicePayloadConverter(),converter.NewProtoPayloadConverter(),converter.NewProtoJSONPayloadConverterWithOptions(converter.ProtoJSONPayloadConverterOptions{LegacyTemporalProtoCompat:true,}),converter.NewJSONPayloadConverter(),)
Note: Payloads encoded withproto/binary
will not be readable in the Temporal web UI.
MIT License, please seeLICENSE for details.
About
Temporal Go SDK