Documentation
¶
Index ¶
- Constants
- Variables
- func HashPayload(payload string) string
- type AttemptStart
- type DBProvider
- type Delivery
- type ExecuteOptions
- type ExecuteResult
- type MySQLSchema
- type MySQLStore
- func (s *MySQLStore) CountByStatus(ctx context.Context, consumerName string) (map[string]int64, error)
- func (s *MySQLStore) DeleteSucceededBefore(ctx context.Context, before time.Time, limit int) (int64, error)
- func (s *MySQLStore) Get(ctx context.Context, consumerName string, eventID string) (Record, error)
- func (s *MySQLStore) ListByStatus(ctx context.Context, consumerName, status string) ([]Record, error)
- func (s *MySQLStore) MarkDeadLettered(ctx context.Context, id int64, lastError string, deadLetteredAt time.Time) error
- func (s *MySQLStore) MarkRetrying(ctx context.Context, id int64, lastError string, nextAttemptAt time.Time) error
- func (s *MySQLStore) MarkSucceeded(ctx context.Context, id int64, finishedAt time.Time) error
- func (s *MySQLStore) OldestActionableAge(ctx context.Context, consumerName string) (time.Duration, error)
- func (s *MySQLStore) OldestAgeByStatus(ctx context.Context, consumerName string) (map[string]time.Duration, error)
- func (s *MySQLStore) Redrive(ctx context.Context, consumerName string, eventID string) error
- func (s *MySQLStore) StartAttempt(ctx context.Context, consumerName string, delivery Delivery, ...) (AttemptStart, error)
- type Outcome
- type ProviderStore
- func (s *ProviderStore) CountByStatus(ctx context.Context, consumerName string) (map[string]int64, error)
- func (s *ProviderStore) DeleteSucceededBefore(ctx context.Context, before time.Time, limit int) (int64, error)
- func (s *ProviderStore) Get(ctx context.Context, consumerName string, eventID string) (Record, error)
- func (s *ProviderStore) ListByStatus(ctx context.Context, consumerName, status string) ([]Record, error)
- func (s *ProviderStore) MarkDeadLettered(ctx context.Context, id int64, lastError string, deadLetteredAt time.Time) error
- func (s *ProviderStore) MarkRetrying(ctx context.Context, id int64, lastError string, nextAttemptAt time.Time) error
- func (s *ProviderStore) MarkSucceeded(ctx context.Context, id int64, finishedAt time.Time) error
- func (s *ProviderStore) OldestActionableAge(ctx context.Context, consumerName string) (time.Duration, error)
- func (s *ProviderStore) OldestAgeByStatus(ctx context.Context, consumerName string) (map[string]time.Duration, error)
- func (s *ProviderStore) Redrive(ctx context.Context, consumerName string, eventID string) error
- func (s *ProviderStore) StartAttempt(ctx context.Context, consumerName string, delivery Delivery, ...) (AttemptStart, error)
- type Record
- type StartDecision
- type Store
Constants ¶
View Source
const ( StatusPending = "pending" StatusProcessing = "processing" StatusRetrying = "retrying" StatusSucceeded = "succeeded" StatusDeadLettered = "dead_lettered" )
View Source
const MySQLTableName = defaultMySQLTableName
Variables ¶
View Source
var ( ErrMissingConsumerName = errors.New("consumer_name is required") ErrMissingEventID = errors.New("event_id is required") ErrMissingSourceTopic = errors.New("source_topic is required") ErrMissingBrokerMessageID = errors.New("broker_message_id is required") ErrEventConflict = errors.New("event_id was already consumed with a different payload") ErrEventInProgress = errors.New("event is still processing") )
View Source
var MySQLSchemaSQL string
Functions ¶
func HashPayload ¶
Types ¶
type AttemptStart ¶
type AttemptStart struct {
Record Record
Decision StartDecision
Delay time.Duration
Reclaimed bool
}
type ExecuteOptions ¶
type ExecuteOptions struct {
MaxAttempts int
InitialBackoff time.Duration
MaxBackoff time.Duration
BackoffMultiplier float64
ProcessingLease time.Duration
OnReclaim func(ctx context.Context, record Record)
OnRetry func(ctx context.Context, record Record, delay time.Duration, cause error)
OnSuccess func(ctx context.Context, record Record)
OnSkip func(ctx context.Context, record Record)
OnDeadLetter func(ctx context.Context, record Record) error
}
type ExecuteResult ¶
type ExecuteResult struct {
Outcome Outcome
Record Record
Reclaimed bool
Attempted int
DeadLetter bool
LastBackoff time.Duration
}
func Execute ¶
func Execute( ctx context.Context, tx kernel.TransactionManager, store Store, consumerName string, delivery Delivery, fn func(ctx context.Context) error, options ExecuteOptions, ) (ExecuteResult, error)
type MySQLSchema ¶
type MySQLSchema struct {
TableName string
}
type MySQLStore ¶
type MySQLStore struct {
// contains filtered or unexported fields
}
func NewMySQLStore ¶
func NewMySQLStore(db *gorm.DB, schema MySQLSchema) *MySQLStore
func (*MySQLStore) CountByStatus ¶
func (*MySQLStore) DeleteSucceededBefore ¶
func (*MySQLStore) ListByStatus ¶
func (*MySQLStore) MarkDeadLettered ¶
func (*MySQLStore) MarkRetrying ¶
func (*MySQLStore) MarkSucceeded ¶
func (*MySQLStore) OldestActionableAge ¶
func (*MySQLStore) OldestAgeByStatus ¶
func (*MySQLStore) StartAttempt ¶
type ProviderStore ¶
type ProviderStore struct {
// contains filtered or unexported fields
}
func NewProviderStore ¶
func NewProviderStore(dbProvider DBProvider, schema MySQLSchema) *ProviderStore
func (*ProviderStore) CountByStatus ¶
func (*ProviderStore) DeleteSucceededBefore ¶
func (*ProviderStore) ListByStatus ¶
func (*ProviderStore) MarkDeadLettered ¶
func (*ProviderStore) MarkRetrying ¶
func (*ProviderStore) MarkSucceeded ¶
func (*ProviderStore) OldestActionableAge ¶
func (*ProviderStore) OldestAgeByStatus ¶
func (*ProviderStore) StartAttempt ¶
type Record ¶
type Record struct {
ID int64
ConsumerName string
EventID string
SourceTopic string
Payload string
MessageMetadata map[string]string
BrokerMessageID string
PayloadHash string
Status string
AttemptCount int32
MaxAttempts int32
NextAttemptAt time.Time
LeaseExpiresAt time.Time
LastError string
DeadLetteredAt time.Time
FinishedAt time.Time
CreatedAt time.Time
UpdatedAt time.Time
}
type StartDecision ¶
type StartDecision string
const ( DecisionProcess StartDecision = "process" DecisionSkip StartDecision = "skip" DecisionWait StartDecision = "wait" )
type Store ¶
type Store interface {
StartAttempt(
ctx context.Context,
consumerName string,
delivery Delivery,
payloadHash string,
maxAttempts int,
lease time.Duration,
) (AttemptStart, error)
MarkSucceeded(ctx context.Context, id int64, finishedAt time.Time) error
MarkRetrying(ctx context.Context, id int64, lastError string, nextAttemptAt time.Time) error
MarkDeadLettered(ctx context.Context, id int64, lastError string, deadLetteredAt time.Time) error
Get(ctx context.Context, consumerName string, eventID string) (Record, error)
}
Click to show internal directories.
Click to hide internal directories.