messages

package
v0.0.0-...-132c30d Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package messages provides a postgres implementation of the repos.MessageRepo interface

Index

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 New

func New(db *sqlx.DB, log log.Factory, cfg *viper.Viper) *Repo

New instance of the sample repository

func (*Repo) Create

func (r *Repo) Create(parentCtx context.Context, message repos.Message) error

func (*Repo) DB

func (r *Repo) DB() *sqlx.DB

func (*Repo) Get

func (r *Repo) Get(parentCtx context.Context, id string) (repos.Message, error)

func (*Repo) List

func (*Repo) Logger

func (r *Repo) Logger() log.Factory

Logger used by tracer

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.

Jump to

Keyboard shortcuts

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