gorm

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

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 *gorm.DB) *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

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 gorm.DB.

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.

Jump to

Keyboard shortcuts

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