Documentation
¶
Index ¶
- Constants
- Variables
- func MachineCollection(tree *hsm.Node) hsm.Collection[Callback]
- func NewWorkflowClosedTrigger() *persistencespb.CallbackInfo_Trigger
- func RegisterExecutor(registry *hsm.Registry, executorOptions TaskExecutorOptions) error
- func RegisterStateMachine(r *hsm.Registry) error
- func RegisterTaskSerializers(reg *hsm.Registry) error
- type AddressMatchRule
- type AddressMatchRules
- type BackoffTask
- type BackoffTaskSerializer
- type Callbackdeprecated
- type CanGetNexusCompletion
- type Config
- type EventAttemptFailed
- type EventFailed
- type EventRescheduled
- type EventScheduled
- type EventSucceeded
- type HTTPCaller
- type HTTPCallerProvider
- type InvocationTask
- type InvocationTaskSerializer
- type TaskExecutorOptions
Constants ¶
const ( TaskTypeInvocation = "callbacks.Invocation" TaskTypeBackoff = "callbacks.Backoff" )
const (
// StateMachineType is a unique type identifier for this state machine.
StateMachineType = "callbacks.Callback"
)
Variables ¶
var ( RequestCounter = chasmcallbacks.RequestCounter RequestLatencyHistogram = chasmcallbacks.RequestLatencyHistogram )
var Module = fx.Module( "component.callbacks", fx.Provide(ConfigProvider), fx.Provide(HTTPCallerProviderProvider), fx.Invoke(RegisterTaskSerializers), fx.Invoke(RegisterStateMachine), fx.Invoke(RegisterExecutor), )
var RequestTimeout = dynamicconfig.NewDestinationDurationSetting( "component.callbacks.request.timeout", time.Second*10, `RequestTimeout is the timeout for executing a single callback request.`, )
var RetryPolicyInitialInterval = dynamicconfig.NewGlobalDurationSetting( "component.callbacks.retryPolicy.initialInterval", time.Second, `The initial backoff interval between every callback request attempt for a given callback.`, )
var RetryPolicyMaximumInterval = dynamicconfig.NewGlobalDurationSetting( "component.callbacks.retryPolicy.maxInterval", time.Hour, `The maximum backoff interval between every callback request attempt for a given callback.`, )
var TransitionAttemptFailed = hsm.NewTransition( []enumsspb.CallbackState{enumsspb.CALLBACK_STATE_SCHEDULED}, enumsspb.CALLBACK_STATE_BACKING_OFF, func(cb Callback, event EventAttemptFailed) (hsm.TransitionOutput, error) { cb.recordAttempt(event.Time) nextDelay := event.RetryPolicy.ComputeNextDelay(0, int(cb.Attempt), event.Err) nextAttemptScheduleTime := event.Time.Add(nextDelay) cb.CallbackInfo.NextAttemptScheduleTime = timestamppb.New(nextAttemptScheduleTime) cb.CallbackInfo.LastAttemptFailure = &failurepb.Failure{ Message: event.Err.Error(), FailureInfo: &failurepb.Failure_ApplicationFailureInfo{ ApplicationFailureInfo: &failurepb.ApplicationFailureInfo{ NonRetryable: false, }, }, } return cb.output() }, )
var TransitionFailed = hsm.NewTransition( []enumsspb.CallbackState{enumsspb.CALLBACK_STATE_SCHEDULED}, enumsspb.CALLBACK_STATE_FAILED, func(cb Callback, event EventFailed) (hsm.TransitionOutput, error) { cb.recordAttempt(event.Time) cb.CallbackInfo.LastAttemptFailure = &failurepb.Failure{ Message: event.Err.Error(), FailureInfo: &failurepb.Failure_ApplicationFailureInfo{ ApplicationFailureInfo: &failurepb.ApplicationFailureInfo{ NonRetryable: true, }, }, } return cb.output() }, )
var TransitionRescheduled = hsm.NewTransition( []enumsspb.CallbackState{enumsspb.CALLBACK_STATE_BACKING_OFF}, enumsspb.CALLBACK_STATE_SCHEDULED, func(cb Callback, event EventRescheduled) (hsm.TransitionOutput, error) { cb.CallbackInfo.NextAttemptScheduleTime = nil return cb.output() }, )
var TransitionScheduled = hsm.NewTransition( []enumsspb.CallbackState{enumsspb.CALLBACK_STATE_STANDBY}, enumsspb.CALLBACK_STATE_SCHEDULED, func(cb Callback, event EventScheduled) (hsm.TransitionOutput, error) { return cb.output() }, )
var TransitionSucceeded = hsm.NewTransition( []enumsspb.CallbackState{enumsspb.CALLBACK_STATE_SCHEDULED}, enumsspb.CALLBACK_STATE_SUCCEEDED, func(cb Callback, event EventSucceeded) (hsm.TransitionOutput, error) { cb.recordAttempt(event.Time) cb.CallbackInfo.LastAttemptFailure = nil return cb.output() }, )
Functions ¶
func MachineCollection ¶
func MachineCollection(tree *hsm.Node) hsm.Collection[Callback]
MachineCollection creates a new typed [statemachines.Collection] for callbacks.
func NewWorkflowClosedTrigger ¶
func NewWorkflowClosedTrigger() *persistencespb.CallbackInfo_Trigger
NewWorkflowClosedTrigger creates a WorkflowClosed trigger variant.
func RegisterExecutor ¶
func RegisterExecutor( registry *hsm.Registry, executorOptions TaskExecutorOptions, ) error
func RegisterStateMachine ¶
func RegisterTaskSerializers ¶
Types ¶
type AddressMatchRule ¶ added in v1.25.0
type AddressMatchRules ¶ added in v1.30.0
type AddressMatchRules struct {
Rules []AddressMatchRule
}
type BackoffTask ¶
type BackoffTask struct {
// contains filtered or unexported fields
}
func (BackoffTask) Deadline ¶
func (t BackoffTask) Deadline() time.Time
func (BackoffTask) Destination ¶ added in v1.26.2
func (BackoffTask) Destination() string
func (BackoffTask) Type ¶
func (BackoffTask) Type() string
func (BackoffTask) Validate ¶ added in v1.26.2
func (BackoffTask) Validate(ref *persistencespb.StateMachineRef, node *hsm.Node) error
type BackoffTaskSerializer ¶
type BackoffTaskSerializer struct{}
func (BackoffTaskSerializer) Deserialize ¶
func (BackoffTaskSerializer) Deserialize(data []byte, attrs hsm.TaskAttributes) (hsm.Task, error)
type Callback
deprecated
type Callback struct {
*persistencespb.CallbackInfo
}
Callback state machine.
Deprecated: HSM Callback is no longer supported.
func NewCallback ¶
func NewCallback( requestId string, registrationTime *timestamppb.Timestamp, trigger *persistencespb.CallbackInfo_Trigger, cb *persistencespb.Callback, ) Callback
NewCallback creates a new callback in the STANDBY state from given params.
func (Callback) SetState ¶
func (c Callback) SetState(state enumsspb.CallbackState)
func (Callback) State ¶
func (c Callback) State() enumsspb.CallbackState
type CanGetNexusCompletion ¶
type Config ¶
type Config struct {
RequestTimeout dynamicconfig.DurationPropertyFnWithDestinationFilter
RetryPolicy dynamicconfig.TypedPropertyFn[backoff.RetryPolicy]
InspectSourceHeader dynamicconfig.BoolPropertyFn
}
func ConfigProvider ¶
func ConfigProvider(dc *dynamicconfig.Collection) *Config
type EventAttemptFailed ¶
type EventAttemptFailed struct {
Time time.Time
Err error
RetryPolicy backoff.RetryPolicy
}
EventAttemptFailed is triggered when an attempt is failed with a retryable error.
type EventFailed ¶
EventFailed is triggered when an attempt is failed with a non retryable error.
type EventRescheduled ¶
type EventRescheduled struct{}
EventRescheduled is triggered when the callback is meant to be rescheduled after backing off from a previous attempt.
type EventScheduled ¶
type EventScheduled struct{}
EventScheduled is triggered when the callback is meant to be scheduled for the first time - when its Trigger condition is met.
type EventSucceeded ¶
EventSucceeded is triggered when an attempt succeeds.
type HTTPCaller ¶
HTTPCaller is a method that can be used to invoke HTTP requests.
type HTTPCallerProvider ¶ added in v1.25.0
type HTTPCallerProvider func(queuescommon.NamespaceIDAndDestination) HTTPCaller
func HTTPCallerProviderProvider ¶ added in v1.25.0
func HTTPCallerProviderProvider( clusterMetadata cluster.Metadata, namespaceRegistry namespace.Registry, rpcFactory common.RPCFactory, httpClientCache *cluster.FrontendHTTPClientCache, logger log.Logger, config *Config, ) (HTTPCallerProvider, error)
type InvocationTask ¶
type InvocationTask struct {
// contains filtered or unexported fields
}
func NewInvocationTask ¶ added in v1.26.2
func NewInvocationTask(destination string) InvocationTask
func (InvocationTask) Deadline ¶ added in v1.26.2
func (t InvocationTask) Deadline() time.Time
func (InvocationTask) Destination ¶
func (t InvocationTask) Destination() string
func (InvocationTask) Type ¶
func (InvocationTask) Type() string
func (InvocationTask) Validate ¶ added in v1.26.2
func (InvocationTask) Validate(ref *persistencespb.StateMachineRef, node *hsm.Node) error
type InvocationTaskSerializer ¶
type InvocationTaskSerializer struct{}
func (InvocationTaskSerializer) Deserialize ¶
func (InvocationTaskSerializer) Deserialize(data []byte, attrs hsm.TaskAttributes) (hsm.Task, error)
type TaskExecutorOptions ¶ added in v1.25.0
type TaskExecutorOptions struct {
fx.In
Config *Config
NamespaceRegistry namespace.Registry
MetricsHandler metrics.Handler
Logger log.Logger
HTTPCallerProvider HTTPCallerProvider
HTTPTraceProvider commonnexus.HTTPClientTraceProvider
HistoryClient resource.HistoryClient
ChasmEngine chasm.Engine
}