@@ -70,54 +70,74 @@ var DefaultOptions Options = Options{
70
70
71
71
type BackendOption func (* Options )
72
72
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.
73
76
func WithStickyTimeout (timeout time.Duration ) BackendOption {
74
77
return func (o * Options ) {
75
78
o .StickyTimeout = timeout
76
79
}
77
80
}
78
81
82
+ // WithLogger sets a custom logger for the backend.
83
+ // If not set, slog.Default() will be used.
79
84
func WithLogger (logger * slog.Logger ) BackendOption {
80
85
return func (o * Options ) {
81
86
o .Logger = logger
82
87
}
83
88
}
84
89
90
+ // WithMetrics sets a custom metrics client for collecting workflow execution metrics.
91
+ // If not set, a no-op metrics client will be used.
85
92
func WithMetrics (client metrics.Client ) BackendOption {
86
93
return func (o * Options ) {
87
94
o .Metrics = client
88
95
}
89
96
}
90
97
98
+ // WithTracerProvider sets a custom OpenTelemetry tracer provider for distributed tracing.
99
+ // If not set, a no-op tracer provider will be used.
91
100
func WithTracerProvider (tp trace.TracerProvider ) BackendOption {
92
101
return func (o * Options ) {
93
102
o .TracerProvider = tp
94
103
}
95
104
}
96
105
106
+ // WithConverter sets a custom converter for serializing and deserializing workflow inputs and results.
107
+ // If not set, converter.DefaultConverter will be used.
97
108
func WithConverter (converter converter.Converter ) BackendOption {
98
109
return func (o * Options ) {
99
110
o .Converter = converter
100
111
}
101
112
}
102
113
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.
103
116
func WithContextPropagator (prop workflow.ContextPropagator ) BackendOption {
104
117
return func (o * Options ) {
105
118
o .ContextPropagators = append (o .ContextPropagators , prop )
106
119
}
107
120
}
108
121
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.
109
125
func WithRemoveContinuedAsNewInstances () BackendOption {
110
126
return func (o * Options ) {
111
127
o .RemoveContinuedAsNewInstances = true
112
128
}
113
129
}
114
130
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.
115
133
func WithMaxHistorySize (size int64 ) BackendOption {
116
134
return func (o * Options ) {
117
135
o .MaxHistorySize = size
118
136
}
119
137
}
120
138
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.
121
141
func WithWorkerName (workerName string ) BackendOption {
122
142
return func (o * Options ) {
123
143
o .WorkerName = workerName
0 commit comments