swomsg

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Log

type Log struct {
	// contains filtered or unexported fields
}

Log is a reader for the switchover log.

func NewLog

func NewLog(ctx context.Context, pool *pgxpool.Pool) (*Log, error)

NewLog will create a new log reader, skipping any existing events.

func (*Log) Append

func (l *Log) Append(ctx context.Context, msg Message) error

Append will append a message to the end of the log. Using an exclusive lock on the table, it ensures that each message will increment the log ID by exactly 1 with no gaps. All observers will see the messages in the same order.

func (*Log) Events

func (l *Log) Events() <-chan Message

Events will return a channel that will receive all events in the log.

type Message

type Message struct {
	ID   uuid.UUID
	Node uuid.UUID
	TS   time.Time `json:"-"`

	Type  string
	Ack   bool            `json:",omitempty"`
	AckID uuid.UUID       `json:",omitempty"`
	Data  json.RawMessage `json:",omitempty"`
}

Message represents a single event in the switchover log.

Jump to

Keyboard shortcuts

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