Documentation ¶
Index ¶
- type Repository
- func (r *Repository) AcquireLock(dispatcherId uuid.UUID) (bool, error)
- func (r *Repository) DeleteInBatches(batchSize int, records []uuid.UUID) error
- func (r *Repository) FindInBatches(batchSize int, limit int, fc func([]*repository.OutboxRecord) error) error
- func (r *Repository) ReleaseLock(dispatcherId uuid.UUID) error
- func (r *Repository) Save(ctx context.Context, o *repository.OutboxRecord) error
- func (r *Repository) SetLogger(l logger.Logger)
- func (r *Repository) SubscribeDispatcher(dispatcherId uuid.UUID, maxDispatchers int) (bool, int, error)
- func (r *Repository) UpdateSubscription(dispatcherId uuid.UUID) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
func New ¶
func New(txKey repository.TxKey, db *sql.DB, useDollar bool) *Repository
func (*Repository) AcquireLock ¶
func (r *Repository) AcquireLock(dispatcherId uuid.UUID) (bool, error)
AcquireLock obtains a table lock on the 'outbox' table by employing a database lock strategy through the use of the auxiliary table 'outbox_lock'.
func (*Repository) DeleteInBatches ¶
func (r *Repository) DeleteInBatches(batchSize int, records []uuid.UUID) error
DeleteInBatches deletes the provided records from the outbox table in batches.
func (*Repository) FindInBatches ¶
func (r *Repository) FindInBatches(batchSize int, limit int, fc func([]*repository.OutboxRecord) error) error
FindInBatches restrieves a limited list of outbox entries to be processed in batches.
func (*Repository) ReleaseLock ¶
func (r *Repository) ReleaseLock(dispatcherId uuid.UUID) error
ReleaseLock releases the table lock on the 'outbox' table that was acquired by the specified dispatcher.
func (*Repository) Save ¶
func (r *Repository) Save(ctx context.Context, o *repository.OutboxRecord) error
Save persist an outbox entry in the same provided business transaction that should be present in the context. The expected transaction should be a pointer to an instance of sql.Tx.
func (*Repository) SetLogger ¶
func (r *Repository) SetLogger(l logger.Logger)
SetLogger sets an optional logger.
func (*Repository) SubscribeDispatcher ¶
func (r *Repository) SubscribeDispatcher(dispatcherId uuid.UUID, maxDispatchers int) (bool, int, error)
SubscribeDispatcher tries to subscribe a dispatcher in the 'outbox_dispatcher_subscription' table taking into account the max number of allowed dispatchers. If the subscription is successful the function returns the assigned subscription to the caller.
func (*Repository) UpdateSubscription ¶
func (r *Repository) UpdateSubscription(dispatcherId uuid.UUID) (bool, error)
UpdateSubscription updates 'alive_at' column with current time to prevent other dispatchers from stealing the subscription.