pubsub

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: MIT Imports: 14 Imported by: 0

README

go-pubsub

Pubsub implementation for Go based on Postgres

Documentation

Index

Constants

View Source
const Fatal = true
View Source
const NonFatal = false

Variables

This section is empty.

Functions

func Publish

func Publish[T any](
	ctx context.Context,
	logger *slog.Logger,
	querier postgres.Querier,
	topic string,
	message T,
) (int64, error)

func Subscribe

func Subscribe[T any](
	ctx context.Context,
	logger *slog.Logger,
	dbPool *pgxpool.Pool,
	topic string,
	msgHandler Handler[T],
	subHandler Handler[bool],
	errHandler Handler[SubscriptionError],
) (string, func())

Types

type Handler

type Handler[T any] func(v T)

func HandlerWithCond

func HandlerWithCond[T any](handler Handler[T]) (Handler[T], *sync.Cond, func() T)

type SubscriptionError

type SubscriptionError struct {
	Err   error
	Fatal bool
}

func NewSubscriptionError

func NewSubscriptionError(err error, fatal bool) SubscriptionError

func (SubscriptionError) Error

func (e SubscriptionError) Error() string

func (SubscriptionError) Unwrap

func (e SubscriptionError) Unwrap() error

type SubscriptionErrors

type SubscriptionErrors []SubscriptionError

func (SubscriptionErrors) Errors

func (es SubscriptionErrors) Errors() []string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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