Skip to content

Commit 9d45579

Browse files
authored
Merge pull request #409 from cschleiden/document-backend-options
Document backend options
2 parents b22d828 + f590e7b commit 9d45579

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

backend/options.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,54 +70,74 @@ var DefaultOptions Options = Options{
7070

7171
type BackendOption func(*Options)
7272

73+
// WithStickyTimeout sets the sticky timeout duration for workflow executions.
74+
// This determines how long a worker will hold onto a workflow execution context
75+
// before releasing it back to the task queue.
7376
func WithStickyTimeout(timeout time.Duration) BackendOption {
7477
return func(o *Options) {
7578
o.StickyTimeout = timeout
7679
}
7780
}
7881

82+
// WithLogger sets a custom logger for the backend.
83+
// If not set, slog.Default() will be used.
7984
func WithLogger(logger *slog.Logger) BackendOption {
8085
return func(o *Options) {
8186
o.Logger = logger
8287
}
8388
}
8489

90+
// WithMetrics sets a custom metrics client for collecting workflow execution metrics.
91+
// If not set, a no-op metrics client will be used.
8592
func WithMetrics(client metrics.Client) BackendOption {
8693
return func(o *Options) {
8794
o.Metrics = client
8895
}
8996
}
9097

98+
// WithTracerProvider sets a custom OpenTelemetry tracer provider for distributed tracing.
99+
// If not set, a no-op tracer provider will be used.
91100
func WithTracerProvider(tp trace.TracerProvider) BackendOption {
92101
return func(o *Options) {
93102
o.TracerProvider = tp
94103
}
95104
}
96105

106+
// WithConverter sets a custom converter for serializing and deserializing workflow inputs and results.
107+
// If not set, converter.DefaultConverter will be used.
97108
func WithConverter(converter converter.Converter) BackendOption {
98109
return func(o *Options) {
99110
o.Converter = converter
100111
}
101112
}
102113

114+
// WithContextPropagator adds a context propagator for passing context into workflows and activities.
115+
// Multiple propagators can be added by calling this function multiple times.
103116
func WithContextPropagator(prop workflow.ContextPropagator) BackendOption {
104117
return func(o *Options) {
105118
o.ContextPropagators = append(o.ContextPropagators, prop)
106119
}
107120
}
108121

122+
// WithRemoveContinuedAsNewInstances enables immediate removal of workflow instances
123+
// that completed using ContinueAsNew, including their history.
124+
// If not set, instances will be removed after the configured retention period or never.
109125
func WithRemoveContinuedAsNewInstances() BackendOption {
110126
return func(o *Options) {
111127
o.RemoveContinuedAsNewInstances = true
112128
}
113129
}
114130

131+
// WithMaxHistorySize sets the maximum size of a workflow history in bytes.
132+
// If a workflow exceeds this size, it will be failed to prevent unbounded growth.
115133
func WithMaxHistorySize(size int64) BackendOption {
116134
return func(o *Options) {
117135
o.MaxHistorySize = size
118136
}
119137
}
120138

139+
// WithWorkerName sets a custom name for this worker instance.
140+
// If not set, backends will generate a default name based on hostname and process ID.
121141
func WithWorkerName(workerName string) BackendOption {
122142
return func(o *Options) {
123143
o.WorkerName = workerName

0 commit comments

Comments
 (0)