Skip to content

Commit d4ff36a

Browse files
committed
more typing
1 parent 4db4d34 commit d4ff36a

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

dbos/workflow.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -212,17 +212,17 @@ func (h *workflowPollingHandle[R]) GetResult() (R, error) {
212212
/**********************************/
213213
/******* WORKFLOW REGISTRY *******/
214214
/**********************************/
215-
type GenericWrappedWorkflowFunc[P any, R any] func(ctx DBOSContext, input P, opts ...WorkflowOption) (WorkflowHandle[R], error)
216-
type WrappedWorkflowFunc func(ctx DBOSContext, input any, opts ...WorkflowOption) (WorkflowHandle[any], error)
215+
type WrappedWorkflowFunc[P any, R any] func(ctx DBOSContext, input P, opts ...WorkflowOption) (WorkflowHandle[R], error)
216+
type wrappedWorkflowFunc func(ctx DBOSContext, input any, opts ...WorkflowOption) (WorkflowHandle[any], error)
217217

218218
type workflowRegistryEntry struct {
219-
wrappedFunction WrappedWorkflowFunc
219+
wrappedFunction wrappedWorkflowFunc
220220
maxRetries int
221221
name string
222222
}
223223

224224
// Register adds a workflow function to the registry (thread-safe, only once per name)
225-
func registerWorkflow(ctx DBOSContext, workflowFQN string, fn WrappedWorkflowFunc, maxRetries int, customName string) {
225+
func registerWorkflow(ctx DBOSContext, workflowFQN string, fn wrappedWorkflowFunc, maxRetries int, customName string) {
226226
// Skip if we don't have a concrete dbosContext
227227
c, ok := ctx.(*dbosContext)
228228
if !ok {
@@ -411,7 +411,7 @@ func RegisterWorkflow[P any, R any](ctx DBOSContext, fn WorkflowFunc[P, R], opts
411411
return fn(ctx, typedInput)
412412
})
413413

414-
typeErasedWrapper := WrappedWorkflowFunc(func(ctx DBOSContext, input any, opts ...WorkflowOption) (WorkflowHandle[any], error) {
414+
typeErasedWrapper := wrappedWorkflowFunc(func(ctx DBOSContext, input any, opts ...WorkflowOption) (WorkflowHandle[any], error) {
415415
opts = append(opts, withWorkflowName(fqn)) // Append the name so ctx.RunAsWorkflow can look it up from the registry to apply registration-time options
416416
handle, err := ctx.RunAsWorkflow(ctx, typedErasedWorkflow, input, opts...)
417417
if err != nil {
@@ -831,8 +831,8 @@ type stepFunc func(ctx context.Context) (any, error)
831831
// StepFunc represents a type-safe step function with a specific output type R.
832832
type StepFunc[R any] func(ctx context.Context) (R, error)
833833

834-
// stepOptions holds the configuration for step execution using functional options pattern.
835-
type stepOptions struct {
834+
// StepOptions holds the configuration for step execution using functional options pattern.
835+
type StepOptions struct {
836836
MaxRetries int // Maximum number of retry attempts (0 = no retries)
837837
BackoffFactor float64 // Exponential backoff multiplier between retries (default: 2.0)
838838
BaseInterval time.Duration // Initial delay between retries (default: 100ms)
@@ -841,7 +841,7 @@ type stepOptions struct {
841841
}
842842

843843
// setDefaults applies default values to stepOptions
844-
func (opts *stepOptions) setDefaults() {
844+
func (opts *StepOptions) setDefaults() {
845845
if opts.BackoffFactor == 0 {
846846
opts.BackoffFactor = _DEFAULT_STEP_BACKOFF_FACTOR
847847
}
@@ -854,13 +854,13 @@ func (opts *stepOptions) setDefaults() {
854854
}
855855

856856
// StepOption is a functional option for configuring step execution parameters.
857-
type StepOption func(*stepOptions)
857+
type StepOption func(*StepOptions)
858858

859859
// WithStepName sets a custom name for the step. If the step name has already been set
860860
// by a previous call to WithStepName, this option will be ignored to allow
861861
// multiple WithStepName calls without overriding the first one.
862862
func WithStepName(name string) StepOption {
863-
return func(opts *stepOptions) {
863+
return func(opts *StepOptions) {
864864
if opts.StepName == "" {
865865
opts.StepName = name
866866
}
@@ -870,7 +870,7 @@ func WithStepName(name string) StepOption {
870870
// WithStepMaxRetries sets the maximum number of retry attempts for the step.
871871
// A value of 0 means no retries (default behavior).
872872
func WithStepMaxRetries(maxRetries int) StepOption {
873-
return func(opts *stepOptions) {
873+
return func(opts *StepOptions) {
874874
opts.MaxRetries = maxRetries
875875
}
876876
}
@@ -879,23 +879,23 @@ func WithStepMaxRetries(maxRetries int) StepOption {
879879
// The delay between retries is calculated as: BaseInterval * (BackoffFactor^(retry-1))
880880
// Default value is 2.0.
881881
func WithBackoffFactor(factor float64) StepOption {
882-
return func(opts *stepOptions) {
882+
return func(opts *StepOptions) {
883883
opts.BackoffFactor = factor
884884
}
885885
}
886886

887887
// WithBaseInterval sets the initial delay between retries.
888888
// Default value is 100ms.
889889
func WithBaseInterval(interval time.Duration) StepOption {
890-
return func(opts *stepOptions) {
890+
return func(opts *StepOptions) {
891891
opts.BaseInterval = interval
892892
}
893893
}
894894

895895
// WithMaxInterval sets the maximum delay between retries.
896896
// Default value is 5s.
897897
func WithMaxInterval(interval time.Duration) StepOption {
898-
return func(opts *stepOptions) {
898+
return func(opts *StepOptions) {
899899
opts.MaxInterval = interval
900900
}
901901
}
@@ -971,7 +971,7 @@ func RunAsStep[R any](ctx DBOSContext, fn StepFunc[R], opts ...StepOption) (R, e
971971

972972
func (c *dbosContext) RunAsStep(_ DBOSContext, fn stepFunc, opts ...StepOption) (any, error) {
973973
// Process functional options
974-
stepOpts := &stepOptions{}
974+
stepOpts := &StepOptions{}
975975
for _, opt := range opts {
976976
opt(stepOpts)
977977
}

0 commit comments

Comments
 (0)