hooks

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package hooks provides lifecycle hooks for workflow observability.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivityCacheHitInfo

type ActivityCacheHitInfo struct {
	InstanceID   string
	WorkflowName string
	ActivityID   string
	ActivityName string
	CachedResult any
}

ActivityCacheHitInfo contains information about a cache hit during replay.

type ActivityCompleteInfo

type ActivityCompleteInfo struct {
	InstanceID   string
	WorkflowName string
	ActivityID   string
	ActivityName string
	OutputData   any
	Duration     time.Duration
	IsReplay     bool
}

ActivityCompleteInfo contains information about an activity completion.

type ActivityFailedInfo

type ActivityFailedInfo struct {
	InstanceID   string
	WorkflowName string
	ActivityID   string
	ActivityName string
	Error        error
	Duration     time.Duration
	Attempt      int
}

ActivityFailedInfo contains information about an activity failure.

type ActivityRetryInfo

type ActivityRetryInfo struct {
	InstanceID   string
	WorkflowName string
	ActivityID   string
	ActivityName string
	Attempt      int
	MaxAttempts  int
	NextDelay    time.Duration
	Error        error
}

ActivityRetryInfo contains information about an activity retry.

type ActivityStartInfo

type ActivityStartInfo struct {
	InstanceID   string
	WorkflowName string
	ActivityID   string
	ActivityName string
	InputData    any
	IsReplay     bool
}

ActivityStartInfo contains information about an activity start.

type EventReceivedInfo

type EventReceivedInfo struct {
	EventType   string
	EventID     string
	EventSource string
	InstanceID  string
}

EventReceivedInfo contains information about a received event.

type EventTimeoutInfo

type EventTimeoutInfo struct {
	InstanceID   string
	WorkflowName string
	EventType    string
}

EventTimeoutInfo contains information about an event timeout.

type EventWaitCompleteInfo

type EventWaitCompleteInfo struct {
	InstanceID   string
	WorkflowName string
	EventType    string
	Duration     time.Duration
}

EventWaitCompleteInfo contains information about completing an event wait.

type EventWaitStartInfo

type EventWaitStartInfo struct {
	InstanceID   string
	WorkflowName string
	EventType    string
	Timeout      *time.Duration
}

EventWaitStartInfo contains information about starting to wait for an event.

type NoOpHooks

type NoOpHooks struct{}

NoOpHooks is a no-operation implementation of WorkflowHooks. Use this as a base for partial implementations.

func (*NoOpHooks) OnActivityCacheHit

func (n *NoOpHooks) OnActivityCacheHit(ctx context.Context, info ActivityCacheHitInfo)

func (*NoOpHooks) OnActivityComplete

func (n *NoOpHooks) OnActivityComplete(ctx context.Context, info ActivityCompleteInfo)

func (*NoOpHooks) OnActivityFailed

func (n *NoOpHooks) OnActivityFailed(ctx context.Context, info ActivityFailedInfo)

func (*NoOpHooks) OnActivityRetry

func (n *NoOpHooks) OnActivityRetry(ctx context.Context, info ActivityRetryInfo)

func (*NoOpHooks) OnActivityStart

func (n *NoOpHooks) OnActivityStart(ctx context.Context, info ActivityStartInfo)

func (*NoOpHooks) OnEventReceived

func (n *NoOpHooks) OnEventReceived(ctx context.Context, info EventReceivedInfo)

func (*NoOpHooks) OnEventTimeout

func (n *NoOpHooks) OnEventTimeout(ctx context.Context, info EventTimeoutInfo)

func (*NoOpHooks) OnEventWaitComplete

func (n *NoOpHooks) OnEventWaitComplete(ctx context.Context, info EventWaitCompleteInfo)

func (*NoOpHooks) OnEventWaitStart

func (n *NoOpHooks) OnEventWaitStart(ctx context.Context, info EventWaitStartInfo)

func (*NoOpHooks) OnReplayComplete

func (n *NoOpHooks) OnReplayComplete(ctx context.Context, info ReplayCompleteInfo)

func (*NoOpHooks) OnReplayStart

func (n *NoOpHooks) OnReplayStart(ctx context.Context, info ReplayStartInfo)

func (*NoOpHooks) OnTimerFired

func (n *NoOpHooks) OnTimerFired(ctx context.Context, info TimerFiredInfo)

func (*NoOpHooks) OnTimerStart

func (n *NoOpHooks) OnTimerStart(ctx context.Context, info TimerStartInfo)

func (*NoOpHooks) OnWorkflowCancelled

func (n *NoOpHooks) OnWorkflowCancelled(ctx context.Context, info WorkflowCancelledInfo)

func (*NoOpHooks) OnWorkflowComplete

func (n *NoOpHooks) OnWorkflowComplete(ctx context.Context, info WorkflowCompleteInfo)

func (*NoOpHooks) OnWorkflowFailed

func (n *NoOpHooks) OnWorkflowFailed(ctx context.Context, info WorkflowFailedInfo)

func (*NoOpHooks) OnWorkflowStart

func (n *NoOpHooks) OnWorkflowStart(ctx context.Context, info WorkflowStartInfo)

type ReplayCompleteInfo

type ReplayCompleteInfo struct {
	InstanceID    string
	WorkflowName  string
	CacheHits     int
	NewActivities int
	Duration      time.Duration
}

ReplayCompleteInfo contains information about replay completion.

type ReplayStartInfo

type ReplayStartInfo struct {
	InstanceID     string
	WorkflowName   string
	HistoryEvents  int
	ResumeActivity string
}

ReplayStartInfo contains information about replay starting.

type TimerFiredInfo

type TimerFiredInfo struct {
	InstanceID   string
	WorkflowName string
	TimerID      string
	FiredAt      time.Time
}

TimerFiredInfo contains information about a fired timer.

type TimerStartInfo

type TimerStartInfo struct {
	InstanceID   string
	WorkflowName string
	TimerID      string
	ExpiresAt    time.Time
}

TimerStartInfo contains information about a timer start.

type WorkflowCancelledInfo

type WorkflowCancelledInfo struct {
	InstanceID   string
	WorkflowName string
	Reason       string
	Duration     time.Duration
}

WorkflowCancelledInfo contains information about a workflow cancellation.

type WorkflowCompleteInfo

type WorkflowCompleteInfo struct {
	InstanceID   string
	WorkflowName string
	OutputData   any
	Duration     time.Duration
}

WorkflowCompleteInfo contains information about a workflow completion.

type WorkflowFailedInfo

type WorkflowFailedInfo struct {
	InstanceID   string
	WorkflowName string
	Error        error
	Duration     time.Duration
}

WorkflowFailedInfo contains information about a workflow failure.

type WorkflowHooks

type WorkflowHooks interface {
	// Workflow lifecycle
	OnWorkflowStart(ctx context.Context, info WorkflowStartInfo)
	OnWorkflowComplete(ctx context.Context, info WorkflowCompleteInfo)
	OnWorkflowFailed(ctx context.Context, info WorkflowFailedInfo)
	OnWorkflowCancelled(ctx context.Context, info WorkflowCancelledInfo)

	// Activity lifecycle
	OnActivityStart(ctx context.Context, info ActivityStartInfo)
	OnActivityComplete(ctx context.Context, info ActivityCompleteInfo)
	OnActivityFailed(ctx context.Context, info ActivityFailedInfo)
	OnActivityRetry(ctx context.Context, info ActivityRetryInfo)

	// Event handling
	OnEventReceived(ctx context.Context, info EventReceivedInfo)
	OnEventWaitStart(ctx context.Context, info EventWaitStartInfo)
	OnEventWaitComplete(ctx context.Context, info EventWaitCompleteInfo)
	OnEventTimeout(ctx context.Context, info EventTimeoutInfo)

	// Timer handling
	OnTimerStart(ctx context.Context, info TimerStartInfo)
	OnTimerFired(ctx context.Context, info TimerFiredInfo)

	// Replay
	OnReplayStart(ctx context.Context, info ReplayStartInfo)
	OnReplayComplete(ctx context.Context, info ReplayCompleteInfo)
	OnActivityCacheHit(ctx context.Context, info ActivityCacheHitInfo)
}

WorkflowHooks defines callbacks for workflow lifecycle events. Implement this interface to add observability (logging, tracing, metrics).

type WorkflowStartInfo

type WorkflowStartInfo struct {
	InstanceID   string
	WorkflowName string
	InputData    any
	StartTime    time.Time
}

WorkflowStartInfo contains information about a workflow start.

Directories

Path Synopsis
Package otel provides OpenTelemetry integration for Romancy workflow hooks.
Package otel provides OpenTelemetry integration for Romancy workflow hooks.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL