Skip to content

Commit 27e3e9b

Browse files
af-mdmaxdml
authored andcommitted
refactor: rename StepOptions to stepOptions for consistency and update related function signatures
1 parent d53546f commit 27e3e9b

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

dbos/workflow.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -987,8 +987,8 @@ type StepFunc func(ctx context.Context) (any, error)
987987
// Step represents a type-safe step function with a specific output type R.
988988
type Step[R any] func(ctx context.Context) (R, error)
989989

990-
// StepOptions holds the configuration for step execution using functional options pattern.
991-
type StepOptions struct {
990+
// stepOptions holds the configuration for step execution using functional options pattern.
991+
type stepOptions struct {
992992
maxRetries int // Maximum number of retry attempts (0 = no retries)
993993
backoffFactor float64 // Exponential backoff multiplier between retries (default: 2.0)
994994
baseInterval time.Duration // Initial delay between retries (default: 100ms)
@@ -998,7 +998,7 @@ type StepOptions struct {
998998
}
999999

10001000
// setDefaults applies default values to stepOptions
1001-
func (opts *StepOptions) setDefaults() {
1001+
func (opts *stepOptions) setDefaults() {
10021002
if opts.backoffFactor == 0 {
10031003
opts.backoffFactor = _DEFAULT_STEP_BACKOFF_FACTOR
10041004
}
@@ -1011,12 +1011,12 @@ func (opts *StepOptions) setDefaults() {
10111011
}
10121012

10131013
// StepOption is a functional option for configuring step execution parameters.
1014-
type StepOption func(*StepOptions)
1014+
type StepOption func(*stepOptions)
10151015

10161016
// WithStepName sets a custom name for the step. If the step name has already been set
10171017
// by a previous call to WithStepName, this option will be ignored
10181018
func WithStepName(name string) StepOption {
1019-
return func(opts *StepOptions) {
1019+
return func(opts *stepOptions) {
10201020
if opts.stepName == "" {
10211021
opts.stepName = name
10221022
}
@@ -1026,7 +1026,7 @@ func WithStepName(name string) StepOption {
10261026
// WithStepMaxRetries sets the maximum number of retry attempts for the step.
10271027
// A value of 0 means no retries (default behavior).
10281028
func WithStepMaxRetries(maxRetries int) StepOption {
1029-
return func(opts *StepOptions) {
1029+
return func(opts *stepOptions) {
10301030
opts.maxRetries = maxRetries
10311031
}
10321032
}
@@ -1035,30 +1035,30 @@ func WithStepMaxRetries(maxRetries int) StepOption {
10351035
// The delay between retries is calculated as: BaseInterval * (BackoffFactor^(retry-1))
10361036
// Default value is 2.0.
10371037
func WithBackoffFactor(factor float64) StepOption {
1038-
return func(opts *StepOptions) {
1038+
return func(opts *stepOptions) {
10391039
opts.backoffFactor = factor
10401040
}
10411041
}
10421042

10431043
// WithBaseInterval sets the initial delay between retries.
10441044
// Default value is 100ms.
10451045
func WithBaseInterval(interval time.Duration) StepOption {
1046-
return func(opts *StepOptions) {
1046+
return func(opts *stepOptions) {
10471047
opts.baseInterval = interval
10481048
}
10491049
}
10501050

10511051
// WithMaxInterval sets the maximum delay between retries.
10521052
// Default value is 5s.
10531053
func WithMaxInterval(interval time.Duration) StepOption {
1054-
return func(opts *StepOptions) {
1054+
return func(opts *stepOptions) {
10551055
opts.maxInterval = interval
10561056
}
10571057
}
10581058

10591059

10601060
func WithNextStepID(stepID int) StepOption {
1061-
return func(opts *StepOptions) {
1061+
return func(opts *stepOptions) {
10621062
opts.preGeneratedStepID = &stepID
10631063
}
10641064
}
@@ -1149,7 +1149,7 @@ func RunAsStep[R any](ctx DBOSContext, fn Step[R], opts ...StepOption) (R, error
11491149

11501150
func (c *dbosContext) RunAsStep(_ DBOSContext, fn StepFunc, opts ...StepOption) (any, error) {
11511151
// Process functional options
1152-
stepOpts := &StepOptions{}
1152+
stepOpts := &stepOptions{}
11531153
for _, opt := range opts {
11541154
opt(stepOpts)
11551155
}

0 commit comments

Comments
 (0)