pubsub

package
v0.27.3 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const BufferSize = 2048

BufferSize is the maximum number of unhandled messages we will buffer for a subscriber before dropping messages.

Variables

View Source
var ErrDroppedMessages = xerrors.New("dropped messages")

ErrDroppedMessages is sent to ListenerWithErr if messages are dropped or might have been dropped.

Functions

This section is empty.

Types

type Listener

type Listener func(ctx context.Context, message []byte)

Listener represents a pubsub handler.

type ListenerWithErr

type ListenerWithErr func(ctx context.Context, message []byte, err error)

ListenerWithErr represents a pubsub handler that can also receive error indications

type MemoryPubsub added in v0.26.1

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

MemoryPubsub is an in-memory Pubsub implementation. It's an exported type so that our test code can do type checks.

func (*MemoryPubsub) Close added in v0.26.1

func (*MemoryPubsub) Close() error

func (*MemoryPubsub) Publish added in v0.26.1

func (m *MemoryPubsub) Publish(event string, message []byte) error

func (*MemoryPubsub) Subscribe added in v0.26.1

func (m *MemoryPubsub) Subscribe(event string, listener Listener) (cancel func(), err error)

func (*MemoryPubsub) SubscribeWithErr added in v0.26.1

func (m *MemoryPubsub) SubscribeWithErr(event string, listener ListenerWithErr) (cancel func(), err error)

type Pubsub

type Pubsub interface {
	Subscribe(event string, listener Listener) (cancel func(), err error)
	SubscribeWithErr(event string, listener ListenerWithErr) (cancel func(), err error)
	Publish(event string, message []byte) error
	Close() error
}

Pubsub is a generic interface for broadcasting and receiving messages. Implementors should assume high-availability with the backing implementation.

func New

func New(ctx context.Context, database *sql.DB, connectURL string) (Pubsub, error)

New creates a new Pubsub implementation using a PostgreSQL connection.

func NewInMemory

func NewInMemory() Pubsub

Jump to

Keyboard shortcuts

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

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy