Documentation
¶
Overview ¶
Package compensation provides compensation (rollback) activities for workflow steps.
Index ¶
- type APIRollbackHandler
- type APIRollbackInput
- type AgentRollbackHandler
- type AgentRollbackInput
- type CompensationActivities
- func (ca *CompensationActivities) RollbackAgentExecution(ctx context.Context, input AgentRollbackInput) (RollbackOutput, error)
- func (ca *CompensationActivities) RollbackDatabaseOperation(ctx context.Context, input DatabaseRollbackInput) (RollbackOutput, error)
- func (ca *CompensationActivities) RollbackExternalAPICall(ctx context.Context, input APIRollbackInput) (RollbackOutput, error)
- func (ca *CompensationActivities) RollbackFileOperation(ctx context.Context, input FileRollbackInput) (RollbackOutput, error)
- func (ca *CompensationActivities) RollbackNotification(ctx context.Context, input NotificationRollbackInput) (RollbackOutput, error)
- type DatabaseRollbackHandler
- type DatabaseRollbackInput
- type DefaultAPIRollbackHandler
- type DefaultAgentRollbackHandler
- type DefaultDatabaseRollbackHandler
- type DefaultFileRollbackHandler
- type DefaultNotificationRollbackHandler
- type FileRollbackHandler
- type FileRollbackInput
- type NotificationRollbackHandler
- type NotificationRollbackInput
- type RollbackInput
- type RollbackOutput
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIRollbackHandler ¶
type APIRollbackHandler interface {
RollbackAPI(ctx context.Context, input APIRollbackInput) error
}
APIRollbackHandler handles external API call rollbacks.
type APIRollbackInput ¶
type APIRollbackInput struct {
RollbackInput
Endpoint string `json:"endpoint"`
Method string `json:"method"`
RequestID string `json:"requestId,omitempty"`
CompensateURL string `json:"compensateUrl,omitempty"`
CompensateMethod string `json:"compensateMethod,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
}
APIRollbackInput for compensating external API calls.
type AgentRollbackHandler ¶
type AgentRollbackHandler interface {
RollbackAgent(ctx context.Context, input AgentRollbackInput) error
}
AgentRollbackHandler handles agent execution rollbacks.
type AgentRollbackInput ¶
type AgentRollbackInput struct {
RollbackInput
AgentType string `json:"agentType"`
AgentName string `json:"agentName"`
OutputPath string `json:"outputPath,omitempty"`
Output json.RawMessage `json:"output,omitempty"`
}
AgentRollbackInput for undoing agent execution side effects.
type CompensationActivities ¶
type CompensationActivities struct {
// contains filtered or unexported fields
}
CompensationActivities holds compensation activity implementations.
func NewCompensationActivities ¶
func NewCompensationActivities( agentHandler AgentRollbackHandler, fileHandler FileRollbackHandler, apiHandler APIRollbackHandler, notifHandler NotificationRollbackHandler, dbHandler DatabaseRollbackHandler, ) *CompensationActivities
NewCompensationActivities creates a new CompensationActivities instance.
func NewDefaultCompensationActivities ¶
func NewDefaultCompensationActivities() *CompensationActivities
NewDefaultCompensationActivities creates CompensationActivities with all default handlers.
func (*CompensationActivities) RollbackAgentExecution ¶
func (ca *CompensationActivities) RollbackAgentExecution(ctx context.Context, input AgentRollbackInput) (RollbackOutput, error)
RollbackAgentExecution undoes agent execution side effects.
func (*CompensationActivities) RollbackDatabaseOperation ¶
func (ca *CompensationActivities) RollbackDatabaseOperation(ctx context.Context, input DatabaseRollbackInput) (RollbackOutput, error)
RollbackDatabaseOperation undoes database changes.
func (*CompensationActivities) RollbackExternalAPICall ¶
func (ca *CompensationActivities) RollbackExternalAPICall(ctx context.Context, input APIRollbackInput) (RollbackOutput, error)
RollbackExternalAPICall compensates external API calls.
func (*CompensationActivities) RollbackFileOperation ¶
func (ca *CompensationActivities) RollbackFileOperation(ctx context.Context, input FileRollbackInput) (RollbackOutput, error)
RollbackFileOperation undoes file creation/modification.
func (*CompensationActivities) RollbackNotification ¶
func (ca *CompensationActivities) RollbackNotification(ctx context.Context, input NotificationRollbackInput) (RollbackOutput, error)
RollbackNotification cancels scheduled notifications.
type DatabaseRollbackHandler ¶
type DatabaseRollbackHandler interface {
RollbackDatabase(ctx context.Context, input DatabaseRollbackInput) error
}
DatabaseRollbackHandler handles database rollbacks.
type DatabaseRollbackInput ¶
type DatabaseRollbackInput struct {
RollbackInput
Collection string `json:"collection"`
DocumentID string `json:"documentId"`
Operation string `json:"operation"` // "insert", "update", "delete"
PreviousData json.RawMessage `json:"previousData,omitempty"`
}
DatabaseRollbackInput for undoing database changes.
type DefaultAPIRollbackHandler ¶
type DefaultAPIRollbackHandler struct{}
DefaultAPIRollbackHandler provides default API rollback implementation.
func NewDefaultAPIRollbackHandler ¶
func NewDefaultAPIRollbackHandler() *DefaultAPIRollbackHandler
NewDefaultAPIRollbackHandler creates a new DefaultAPIRollbackHandler.
func (*DefaultAPIRollbackHandler) RollbackAPI ¶
func (h *DefaultAPIRollbackHandler) RollbackAPI(ctx context.Context, input APIRollbackInput) error
RollbackAPI sends compensation request to external API.
type DefaultAgentRollbackHandler ¶
type DefaultAgentRollbackHandler struct{}
DefaultAgentRollbackHandler provides default agent rollback implementation.
func NewDefaultAgentRollbackHandler ¶
func NewDefaultAgentRollbackHandler() *DefaultAgentRollbackHandler
NewDefaultAgentRollbackHandler creates a new DefaultAgentRollbackHandler.
func (*DefaultAgentRollbackHandler) RollbackAgent ¶
func (h *DefaultAgentRollbackHandler) RollbackAgent(ctx context.Context, input AgentRollbackInput) error
RollbackAgent cleans up agent execution artifacts.
type DefaultDatabaseRollbackHandler ¶
type DefaultDatabaseRollbackHandler struct{}
DefaultDatabaseRollbackHandler provides default database rollback implementation.
func NewDefaultDatabaseRollbackHandler ¶
func NewDefaultDatabaseRollbackHandler() *DefaultDatabaseRollbackHandler
NewDefaultDatabaseRollbackHandler creates a new DefaultDatabaseRollbackHandler.
func (*DefaultDatabaseRollbackHandler) RollbackDatabase ¶
func (h *DefaultDatabaseRollbackHandler) RollbackDatabase(ctx context.Context, input DatabaseRollbackInput) error
RollbackDatabase reverts database changes.
type DefaultFileRollbackHandler ¶
type DefaultFileRollbackHandler struct{}
DefaultFileRollbackHandler provides default file rollback implementation.
func NewDefaultFileRollbackHandler ¶
func NewDefaultFileRollbackHandler() *DefaultFileRollbackHandler
NewDefaultFileRollbackHandler creates a new DefaultFileRollbackHandler.
func (*DefaultFileRollbackHandler) RollbackFile ¶
func (h *DefaultFileRollbackHandler) RollbackFile(ctx context.Context, input FileRollbackInput) error
RollbackFile restores files to their original state.
type DefaultNotificationRollbackHandler ¶
type DefaultNotificationRollbackHandler struct{}
DefaultNotificationRollbackHandler provides default notification rollback implementation.
func NewDefaultNotificationRollbackHandler ¶
func NewDefaultNotificationRollbackHandler() *DefaultNotificationRollbackHandler
NewDefaultNotificationRollbackHandler creates a new DefaultNotificationRollbackHandler.
func (*DefaultNotificationRollbackHandler) RollbackNotification ¶
func (h *DefaultNotificationRollbackHandler) RollbackNotification(ctx context.Context, input NotificationRollbackInput) error
RollbackNotification cancels or revokes notifications.
type FileRollbackHandler ¶
type FileRollbackHandler interface {
RollbackFile(ctx context.Context, input FileRollbackInput) error
}
FileRollbackHandler handles file operation rollbacks.
type FileRollbackInput ¶
type FileRollbackInput struct {
RollbackInput
FilePath string `json:"filePath"`
Operation string `json:"operation"` // "create", "update", "delete"
OriginalContent json.RawMessage `json:"originalContent,omitempty"`
BackupPath string `json:"backupPath,omitempty"`
}
FileRollbackInput for undoing file operations.
type NotificationRollbackHandler ¶
type NotificationRollbackHandler interface {
RollbackNotification(ctx context.Context, input NotificationRollbackInput) error
}
NotificationRollbackHandler handles notification rollbacks.
type NotificationRollbackInput ¶
type NotificationRollbackInput struct {
RollbackInput
NotificationType string `json:"notificationType"` // "email", "webhook", "sms"
NotificationID string `json:"notificationId"`
Recipients []string `json:"recipients,omitempty"`
}
NotificationRollbackInput for canceling scheduled notifications.
type RollbackInput ¶
type RollbackInput struct {
WorkflowID string `json:"workflowId"`
ActivityName string `json:"activityName"`
ResourceID string `json:"resourceId,omitempty"`
ResourceType string `json:"resourceType,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
OriginalData json.RawMessage `json:"originalData,omitempty"`
}
RollbackInput provides context for rollback operations.