Documentation
¶
Overview ¶
Package temporal provides a thin wrapper around the Temporal Go SDK for dialling a client and building activity options with sensible defaults.
Connecting ¶
c, err := temporal.NewClient("default", "localhost", 7233)
if err != nil {
log.Fatal(err)
}
defer c.Close()
Activity options ¶
DefaultActivityOpts returns activity options with a 1 h StartToClose timeout and a capped exponential-backoff retry policy (3 attempts, 5 s initial interval, 1 min cap). Pass functional options to override specific fields.
opts := temporal.DefaultActivityOpts(
temporal.WithStartToCloseTimeout(30 * time.Minute),
temporal.WithMaximumAttempts(5),
)
ctx = workflow.WithActivityOptions(ctx, opts)
workflow.ExecuteActivity(ctx, myActivity, input)
Config struct ¶
TemporalConfig carries the four connection parameters and is intended for use with the config package (mapstructure tags are included for Viper).
var cfg temporal.TemporalConfig // populate from Viper / env ... c, err := temporal.NewClient(cfg.Namespace, cfg.Host, cfg.Port)
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrEmptyHost = errors.New("temporal host cannot be empty") ErrEmptyNamespace = errors.New("temporal namespace cannot be empty") )
Sentinel errors returned when dialing the Temporal client.
Functions ¶
func DefaultActivityOpts ¶
func DefaultActivityOpts(opts ...ActivityOption) workflow.ActivityOptions
DefaultActivityOpts returns activity options with sensible defaults: a 1h StartToClose timeout and a capped exponential-backoff retry policy. Pass options to customize specific fields, e.g.:
opts := temporal.DefaultActivityOpts(
temporal.WithTaskQueue("audit"),
temporal.WithStartToCloseTimeout(30*time.Minute),
)
Types ¶
type ActivityOption ¶
type ActivityOption func(*workflow.ActivityOptions)
ActivityOption customizes the activity options produced by DefaultActivityOpts. Options are applied in order.
func WithMaximumAttempts ¶
func WithMaximumAttempts(n int32) ActivityOption
WithMaximumAttempts overrides the retry policy's maximum attempts. A value of 0 means unlimited retries, per the Temporal SDK.
func WithRetryPolicy ¶
func WithRetryPolicy(p *temporal.RetryPolicy) ActivityOption
WithRetryPolicy replaces the entire retry policy.
func WithScheduleToCloseTimeout ¶
func WithScheduleToCloseTimeout(d time.Duration) ActivityOption
WithScheduleToCloseTimeout sets the ScheduleToClose timeout (unset by default).
func WithStartToCloseTimeout ¶
func WithStartToCloseTimeout(d time.Duration) ActivityOption
WithStartToCloseTimeout overrides the StartToClose timeout.
func WithTaskQueue ¶
func WithTaskQueue(taskQueue string) ActivityOption
WithTaskQueue routes the activity to a specific task queue. An empty value leaves the workflow's default task queue in place.