nats

package module
v0.0.0-...-c1e5b24 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Eventbus

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

func NewEventbus

func NewEventbus(opts ...Option) *Eventbus

func (*Eventbus) Close

func (eb *Eventbus) Close() error

Close 停止监听

func (*Eventbus) Publish

func (eb *Eventbus) Publish(ctx context.Context, topic string, payload interface{}) error

Publish 发布事件

func (*Eventbus) Subscribe

func (eb *Eventbus) Subscribe(ctx context.Context, topic string, handler eventbus.EventHandler) error

Subscribe 订阅事件

func (*Eventbus) Unsubscribe

func (eb *Eventbus) Unsubscribe(ctx context.Context, topic string, handler eventbus.EventHandler) error

Unsubscribe 取消订阅

type Option

type Option func(o *options)

func WithConn

func WithConn(conn *nats.Conn) Option

WithConn 设置外部客户端连接

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout 客户端连接超时时间

func WithUrl

func WithUrl(url string) Option

WithUrl 设置连接地址

Jump to

Keyboard shortcuts

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