whpgstate

package
v1.169.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package whpgstate keeps the state of each postgres webhook source's listener (#2408) in webhook_pg_listeners: which replica listens and since when, what it filed and refused, and its last failure, so a source's page on any replica shows how its listener is going. Nothing of a payload is kept.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type State

type State struct {
	// Replica is the replica listening, empty when none is.
	Replica        string     `json:"replica"`
	ListeningSince *time.Time `json:"listening_since,omitempty"`
	LastEventAt    *time.Time `json:"last_event_at,omitempty"`
	Delivered      int64      `json:"delivered"`
	Rejected       int64      `json:"rejected"`
	LastError      string     `json:"last_error,omitempty"`
	LastErrorAt    *time.Time `json:"last_error_at,omitempty"`
}

State is how a postgres source's listener stands: which replica listens, since when, what it filed and refused, and its last failure.

type States

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

States keeps each source's state in webhook_pg_listeners. A write for a source deleted meanwhile changes nothing: the row went with the source.

func New

func New(db *sql.DB) *States

New returns the store, nil without a database.

func (*States) Failed

func (s *States) Failed(ctx context.Context, source, msg string, at time.Time) error

Failed records a listener's failure.

func (*States) Filed

func (s *States) Filed(ctx context.Context, source string, delivered, rejected int64, at time.Time) error

Filed adds what one delivery filed and refused.

func (*States) Get

func (s *States) Get(ctx context.Context, source string) (State, error)

Get returns a source's state, the zero value when no replica has listened.

func (*States) Listening

func (s *States) Listening(ctx context.Context, source, replica string, since time.Time) error

Listening records replica as the source's listener from since, clearing the last failure.

func (*States) Stopped

func (s *States) Stopped(ctx context.Context, source, replica string) error

Stopped records that replica no longer listens, unless another replica took over meanwhile.

Jump to

Keyboard shortcuts

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