Documentation ¶
Index ¶
- func ApplyEventCriteria(crit EventCriteria, notifier s.EventNotifier) s.EventNotifier
- func NewReliableNotifier(notifierFns map[string]s.EventNotifier, opts ...ReliableNotifierOpt) (s.EventNotifier, context.CancelFunc, error)
- type EventCriteria
- type ReliableNotifierOpt
- func WithEntrypointBufferSize(n uint) ReliableNotifierOpt
- func WithNotifierBufferSize(n uint) ReliableNotifierOpt
- func WithNotifierTimeout(ts time.Duration) ReliableNotifierOpt
- func WithOnNotifierTimeout(cb func(string)) ReliableNotifierOpt
- func WithOnReliableNotifierFailure(cb func(error)) ReliableNotifierOpt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyEventCriteria ¶
func ApplyEventCriteria(crit EventCriteria, notifier s.EventNotifier) s.EventNotifier
ApplyEventCriteria forwards Event records that match positively the given criteria to the given EventNotifier
func NewReliableNotifier ¶
func NewReliableNotifier( notifierFns map[string]s.EventNotifier, opts ...ReliableNotifierOpt, ) (s.EventNotifier, context.CancelFunc, error)
NewReliableNotifier is an EventNotifier that guarantees it will never panic the execution of its caller, and that it will continue sending events to notifiers despite previous panics
Types ¶
type EventCriteria ¶
EventCriteria is an utility that allows us to specify a matching criteria to a specific supervision event
var EIsFailure EventCriteria = func(ev s.Event) bool { return ev.GetTag() == s.ProcessFailed }
EIsFailure returns true if the event represent a node failure.
var EIsSupervisorRestartError EventCriteria = func(ev s.Event) bool { if ev.GetTag() == s.ProcessFailed && ev.GetNodeTag() == c.Supervisor { var restartErr *s.SupervisorRestartError return errors.As(ev.Err(), &restartErr) } return false }
EIsSupervisorRestartError returns true if the event represents a restart tolerance reached error
var EIsWorkerFailure EventCriteria = func(ev s.Event) bool { return EIsFailure(ev) && ev.GetNodeTag() == c.Worker }
EIsWorkerFailure returns true if the event represents a worker failure.
func EAnd ¶
func EAnd(crits ...EventCriteria) EventCriteria
EAnd joins a slice of EventCriteria with an "and" statement. A call without arguments will accept all given events.
func EHasNameSuffix ¶
func EHasNameSuffix(rawSuffix string) EventCriteria
EHasNameSuffix returns true if the runtime name of the node that emitted the event matches the given suffix
func EHasRuntimeName ¶
func EHasRuntimeName(runtimeName string) EventCriteria
EHasRuntimeName returns true if the runtime name of the node that emitted the event matches the given name
func EInSubtree ¶
func EInSubtree(rawName string) EventCriteria
EInSubtree allows to filter s.Event that were sent from an specific subtree.
func ENot ¶
func ENot(crit EventCriteria) EventCriteria
ENot negates the result from a given EventCriteria.
func EOr ¶
func EOr(crits ...EventCriteria) EventCriteria
EOr joins a slice of EventCriteria with an "or" statement. A call without arguments wil accept all given events.
type ReliableNotifierOpt ¶
type ReliableNotifierOpt func(*notifierSettings)
ReliableNotifierOpt allows clients to tweak the behavior of a ReliableNotifier instance
func WithEntrypointBufferSize ¶
func WithEntrypointBufferSize(n uint) ReliableNotifierOpt
WithEntrypointBufferSize sets the buffer size for entrypoint of the reliable notifier.
func WithNotifierBufferSize ¶
func WithNotifierBufferSize(n uint) ReliableNotifierOpt
WithNotifierBufferSize sets the buffer size for each notifier.
func WithNotifierTimeout ¶
func WithNotifierTimeout(ts time.Duration) ReliableNotifierOpt
WithNotifierTimeout sets the maximum allowed time the reliable notifier is going to wait for a notifier function to be ready to receive an event (defaults to 10 millis).
func WithOnNotifierTimeout ¶
func WithOnNotifierTimeout(cb func(string)) ReliableNotifierOpt
WithOnNotifierTimeout sets callback that gets executed when a given notifier is so slow to get an event that it gets skipped. You need to ensure the given callback does not block.
func WithOnReliableNotifierFailure ¶
func WithOnReliableNotifierFailure(cb func(error)) ReliableNotifierOpt
WithOnReliableNotifierFailure sets a callback that gets executed when a failure occurs on the event broadcasting logic. You need to ensure the given callback does not block.