Documentation ¶
Overview ¶
Package messages provides a postgres implementation of the repos.MessageRepo interface
Index ¶
- type Repo
- func (r *Repo) Create(parentCtx context.Context, message repos.Message) error
- func (r *Repo) DB() *sqlx.DB
- func (r *Repo) Get(parentCtx context.Context, id string) (repos.Message, error)
- func (r *Repo) List(ctx context.Context, p repos.MessagePredicate) (repos.MessageIterator, error)
- func (r *Repo) Logger() log.Factory
- func (r *Repo) Update(parentCtx context.Context, message repos.Message, opts ...repos.UpdateOption) error
- func (r *Repo) UpdateConfirmed(parentCtx context.Context, id string, messageStatus repos.MessageStatus) error
- func (r *Repo) UpdateReplay(parentCtx context.Context, msg repos.Message, _ ...repos.UpdateOption) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Repo ¶
type Repo struct {
// contains filtered or unexported fields
}
Repo implements the repos.MessageRepo interface against a postgres DB.
func (*Repo) List ¶
func (r *Repo) List(ctx context.Context, p repos.MessagePredicate) (repos.MessageIterator, error)
func (*Repo) Update ¶
func (r *Repo) Update(parentCtx context.Context, message repos.Message, opts ...repos.UpdateOption) error
Update a message.
Only statuses, last_time, balances and rejection cause are mutable.
An update is performed only if the message status is strictly increasing or if the message status remains unchanged and the processing status increases. Otherwise, the operation is ignored.
func (*Repo) UpdateConfirmed ¶
func (r *Repo) UpdateConfirmed(parentCtx context.Context, id string, messageStatus repos.MessageStatus) error
UpdateConfirmed updates a message, specifically to maintain a producer's view.
Reminder: in this demo, consumers do not update the database.
However, it is required for consumers to track confirmed messages: confirmed messages won't be replayed any longer.
func (*Repo) UpdateReplay ¶
func (r *Repo) UpdateReplay(parentCtx context.Context, msg repos.Message, _ ...repos.UpdateOption) error
UpdateReplay updates a message, specifically to maintain the count of replays.
All other fields remain unaffected.