notify

package
v0.0.0-...-46fdbbc Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2025 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 Notifier

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

func New

func New(db *pgxpool.Pool, log logrus.FieldLogger, opts ...Option) *Notifier

func (*Notifier) Listen

func (n *Notifier) Listen(table string) <-chan Payload

Listen returns a channel that will receive notifications for the given table It will receive all notifications for the table unless one or more filters are provided

func (*Notifier) Run

func (n *Notifier) Run(ctx context.Context)

func (*Notifier) SetChannel

func (n *Notifier) SetChannel(channel string)

SetChannel sets the channel to listen on Will not take effect after Run has been called

type Operation

type Operation string
const (
	Insert Operation = "INSERT"
	Update Operation = "UPDATE"
	Delete Operation = "DELETE"
)

type Option

type Option func(n *Notifier)

func WithRetries

func WithRetries(num int) Option

type Payload

type Payload struct {
	Table string         `json:"table"`
	Op    Operation      `json:"op"`
	Data  map[string]any `json:"data"`
}

Payload is the payload of a notification You should not change this struct, as it's used by all listeners

Jump to

Keyboard shortcuts

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