nats

package
v0.0.0-...-841f565 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultServerOptions = server.Options{
	Host:           "127.0.0.1",
	Port:           4222,
	NoLog:          true,
	NoSigs:         true,
	MaxControlLine: 4096,
	HTTPPort:       8222,

	DisableShortFirstPing: true,
}

Functions

func Connect

func Connect(addr string, options ...nats.Option) (*nats.Conn, error)

func RunServer

func RunServer(opts *server.Options) (*server.Server, error)

Types

type Broker

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

func NewBroker

func NewBroker(nc *nats.Conn) *Broker

NewBroker creates a new NATS broker

func (Broker) Close

func (b Broker) Close() error

Close closes the attaches nats client

func (Broker) Publish

func (b Broker) Publish(topic cqrs.RouteKey, messages ...cqrs.Message) error

Publish send a message

func (Broker) Subscribe

func (b Broker) Subscribe(
	ctx context.Context,
	topic cqrs.RouteKey,
	_ *time.Duration,
) (<-chan cqrs.Envelope, error)

Subscribe registers interest in the given topic and returns a channel to begin processing messages The subscription will be canceled and interest will be removed from the topic when the context is canceled An error is returned if we fail to subscribe

Jump to

Keyboard shortcuts

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