Documentation
¶
Index ¶
- Constants
- func NormalizeOutcome(raw string) string
- func NormalizeStatus(raw string) string
- type AbortHandler
- type CompletionPolicy
- type DispatchResult
- type Evaluation
- type Handler
- type PendingHandler
- type Record
- type SMTPAcceptedPolicy
- type Scope
- type Service
- func (s Service) Abort(ctx context.Context, scope Scope, effectID string, reason string, ...) (Record, error)
- func (s Service) Complete(ctx context.Context, scope Scope, effectID string, policy CompletionPolicy, ...) (Record, error)
- func (s Service) MarkDispatching(ctx context.Context, scope Scope, effectID string, dispatchID string) (Record, error)
- func (s Service) Prepare(ctx context.Context, scope Scope, record Record) (Record, bool, error)
- type Store
Constants ¶
const ( StatusPrepared = "prepared" StatusDispatching = "dispatching" StatusGuardPending = "guard_pending" StatusFinalized = "finalized" StatusRetrying = "retrying" StatusAborted = "aborted" StatusDeadLettered = "dead_lettered" OutcomeCompleted = "completed" OutcomePending = "pending" OutcomeFailed = "failed" PolicySMTPAccepted = "smtp_accepted" )
Variables ¶
This section is empty.
Functions ¶
func NormalizeOutcome ¶
func NormalizeStatus ¶
Types ¶
type AbortHandler ¶
AbortHandler receives explicit effect-abort lifecycle events.
type CompletionPolicy ¶
type CompletionPolicy interface {
Name() string
EvaluateDispatchResult(result DispatchResult) Evaluation
}
CompletionPolicy classifies one dispatch result.
type DispatchResult ¶
type DispatchResult struct {
Outcome string `json:"outcome"`
DispatchID string `json:"dispatch_id"`
ProviderMessageID string `json:"provider_message_id"`
MetadataJSON string `json:"metadata_json"`
OccurredAt time.Time `json:"occurred_at"`
}
DispatchResult is the structured external-effect completion signal consumed by effect finalizers.
type Evaluation ¶
Evaluation captures completion-policy output.
type Handler ¶
type Handler interface {
Finalize(ctx context.Context, effect Record, result DispatchResult) error
Fail(ctx context.Context, effect Record, result DispatchResult, nextRetryAt *time.Time) error
}
Handler owns workflow-specific finalization and failure behavior.
type PendingHandler ¶
type PendingHandler interface {
Pending(ctx context.Context, effect Record, result DispatchResult) error
}
PendingHandler receives provider-accepted, not-yet-final outcomes.
type Record ¶
type Record struct {
EffectID string `json:"effect_id"`
TenantID string `json:"tenant_id"`
OrgID string `json:"org_id"`
Kind string `json:"kind"`
GroupType string `json:"group_type"`
GroupID string `json:"group_id"`
SubjectType string `json:"subject_type"`
SubjectID string `json:"subject_id"`
IdempotencyKey string `json:"idempotency_key"`
CorrelationID string `json:"correlation_id"`
Status string `json:"status"`
AttemptCount int `json:"attempt_count"`
MaxAttempts int `json:"max_attempts"`
GuardPolicy string `json:"guard_policy"`
PreparePayloadJSON string `json:"prepare_payload_json"`
DispatchPayloadJSON string `json:"dispatch_payload_json"`
ResultPayloadJSON string `json:"result_payload_json"`
ErrorJSON string `json:"error_json"`
DispatchID string `json:"dispatch_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DispatchedAt *time.Time `json:"dispatched_at"`
FinalizedAt *time.Time `json:"finalized_at"`
AbortedAt *time.Time `json:"aborted_at"`
RetryAt *time.Time `json:"retry_at"`
}
Record is the durable lifecycle boundary for a guarded external effect.
type SMTPAcceptedPolicy ¶
type SMTPAcceptedPolicy struct{}
SMTPAcceptedPolicy treats provider acceptance as the completion boundary.
func (SMTPAcceptedPolicy) EvaluateDispatchResult ¶
func (SMTPAcceptedPolicy) EvaluateDispatchResult(result DispatchResult) Evaluation
func (SMTPAcceptedPolicy) Name ¶
func (SMTPAcceptedPolicy) Name() string
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service coordinates durable status changes around guarded external effects.
func NewService ¶
NewService builds a guarded effect lifecycle coordinator.
func (Service) Abort ¶
func (s Service) Abort( ctx context.Context, scope Scope, effectID string, reason string, handler Handler, ) (Record, error)
Abort moves an effect into an explicit aborted terminal state.
func (Service) Complete ¶
func (s Service) Complete( ctx context.Context, scope Scope, effectID string, policy CompletionPolicy, result DispatchResult, nextRetryAt *time.Time, handler Handler, ) (Record, error)
Complete applies one dispatch result and delegates workflow-specific finalize/failure handling.
type Store ¶
type Store interface {
SaveGuardedEffect(ctx context.Context, scope Scope, record Record) (Record, error)
GetGuardedEffect(ctx context.Context, effectID string) (Record, error)
GetGuardedEffectByIdempotencyKey(ctx context.Context, scope Scope, key string) (Record, error)
}
Store is the durable persistence boundary required by the guarded effect service.