libbus

package
v1.0.0-rc.6 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 15 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

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConnectionClosed       = errors.New("connection closed")
	ErrStreamSubscriptionFail = errors.New("stream subscription failed")
	ErrMessagePublish         = errors.New("message publishing failed")
	ErrRequestTimeout         = errors.New("request timed out")
	ErrNoResponders           = fmt.Errorf("%w: no handler was subscribed to the subject, so the request was never delivered and is safe to retry", ErrRequestTimeout)
)

Functions

func SetupNatsInstance

func SetupNatsInstance(ctx context.Context) (string, testcontainers.Container, func(), error)

Types

type Config

type Config struct {
	NATSURL      string
	NATSPassword string
	NATSUser     string
}

type Handler

type Handler func(ctx context.Context, data []byte) ([]byte, error)

type InMem added in v0.28.0

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

func NewInMem added in v0.28.0

func NewInMem() *InMem

func (*InMem) Close added in v0.28.0

func (p *InMem) Close() error

func (*InMem) Publish added in v0.28.0

func (p *InMem) Publish(ctx context.Context, subject string, data []byte) error

func (*InMem) Request added in v0.28.0

func (p *InMem) Request(ctx context.Context, subject string, data []byte) ([]byte, error)

func (*InMem) Serve added in v0.28.0

func (p *InMem) Serve(ctx context.Context, subject string, handler Handler) (Subscription, error)

func (*InMem) Stream added in v0.28.0

func (p *InMem) Stream(ctx context.Context, subject string, ch chan<- []byte) (Subscription, error)

type Messenger

type Messenger interface {
	Publish(ctx context.Context, subject string, data []byte) error

	Stream(ctx context.Context, subject string, ch chan<- []byte) (Subscription, error)

	Request(ctx context.Context, subject string, data []byte) ([]byte, error)

	Serve(ctx context.Context, subject string, handler Handler) (Subscription, error)

	Close() error
}

func NewPubSub

func NewPubSub(ctx context.Context, cfg *Config) (Messenger, error)

func NewTestPubSub

func NewTestPubSub() (Messenger, func(), error)

type SQLiteBus added in v0.28.0

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

func NewSQLite added in v0.28.0

func NewSQLite(exec sqlExec) *SQLiteBus

func NewSQLiteWithOptions added in v0.28.0

func NewSQLiteWithOptions(exec sqlExec, opt SQLiteBusOptions) *SQLiteBus

func (*SQLiteBus) Close added in v0.28.0

func (b *SQLiteBus) Close() error

func (*SQLiteBus) Publish added in v0.28.0

func (b *SQLiteBus) Publish(ctx context.Context, subject string, data []byte) error

func (*SQLiteBus) Request added in v0.28.0

func (b *SQLiteBus) Request(ctx context.Context, subject string, data []byte) ([]byte, error)

func (*SQLiteBus) Serve added in v0.28.0

func (b *SQLiteBus) Serve(ctx context.Context, subject string, handler Handler) (Subscription, error)

func (*SQLiteBus) Stream added in v0.28.0

func (b *SQLiteBus) Stream(ctx context.Context, subject string, ch chan<- []byte) (Subscription, error)

type SQLiteBusOptions added in v0.28.0

type SQLiteBusOptions struct {
	EventPoll   time.Duration
	RequestPoll time.Duration
}

type Subscription

type Subscription interface {
	Unsubscribe() error
}

Jump to

Keyboard shortcuts

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