Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove GetState and WithGetStateEnable already deprecated #102

Merged
merged 1 commit into from
Mar 12, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions compose/graph_compile_options.go
Original file line number Diff line number Diff line change
@@ -52,14 +52,6 @@ func WithGraphCompileCallbacks(cbs ...GraphCompileCallback) GraphCompileOption {
}
}

// WithGetStateEnable enables/disables GetState in Workflow nodes.
// Deprecated: use ProcessState instead of GetState, which is always concurrency-safe.
func WithGetStateEnable(enabled bool) GraphCompileOption {
return func(o *graphCompileOptions) {
o.getStateEnabled = enabled
}
}

// InitGraphCompileCallbacks set global graph compile callbacks,
// which ONLY will be added to top level graph compile options
func InitGraphCompileCallbacks(cbs []GraphCompileCallback) {
20 changes: 0 additions & 20 deletions compose/state.go
Original file line number Diff line number Diff line change
@@ -141,26 +141,6 @@ func ProcessState[S any](ctx context.Context, handler func(context.Context, S) e
return handler(ctx, s)
}

// GetState gets the state from the context.
// Deprecated: use ProcessState instead.
func GetState[S any](ctx context.Context) (S, error) {
state := ctx.Value(stateKey{})

iState := state.(*internalState)
if iState.forbidden {
var s S
return s, fmt.Errorf("GetState in node is forbidden in Workflow because of the race of state, if you have handled concurrent state access safety, you can add WithGetStateEnable option at graph compile")
}
cState, ok := iState.state.(S)
if !ok {
var s S
return s, fmt.Errorf("unexpected state type. expected: %v, got: %v",
generic.TypeOf[S](), reflect.TypeOf(iState.state))
}

return cState, nil
}

func getState[S any](ctx context.Context) (S, *sync.Mutex, error) {
state := ctx.Value(stateKey{})

Loading