package core import "context" type StateBackend interface { // SetCurrentKey will perform in Memory SetCurrentKey(key string) error // GetCurrentKey will perform in Memory GetCurrentKey() string // GetValueState will perform in disk GetValueState(ctx context.Context, key string) (ValueState[any], error) } type stateBackendKeyType struct{} var stateBackendKey stateBackendKeyType func InjectStateBackend(ctx context.Context, state StateBackend) context.Context { return context.WithValue(ctx, stateBackendKey, state) } func ExtractStateBackend(ctx context.Context) (StateBackend, bool) { backend, ok := ctx.Value(stateBackendKey).(StateBackend) return backend, ok }