natsbus

package
v0.0.0-...-fc7aaf0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FmtByte2RefVal

func FmtByte2RefVal(t reflect.Type, data []byte) (reflect.Value, error)

func FmtData2Byte

func FmtData2Byte(args interface{}) ([]byte, error)

func New

func New(nc *nats.Conn) gobus.Bus

New returns new QueueBus with nats adapter.

func NewNatsBus

func NewNatsBus(nc *nats.Conn) gobus.Bus

New returns new QueueBus with empty handlers.

Types

type Message

type Message struct {
	*nats.Msg
}

func (*Message) GetData

func (msg *Message) GetData() []byte

func (*Message) GetReply

func (msg *Message) GetReply() string

func (*Message) GetSubject

func (msg *Message) GetSubject() string

type NatsAdapter

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

NatsAdapter - nats adapter

func (*NatsAdapter) Conn

func (bus *NatsAdapter) Conn() interface{}

func (*NatsAdapter) Name

func (bus *NatsAdapter) Name() string

func (*NatsAdapter) Publish

func (bus *NatsAdapter) Publish(topic string, data []byte) error

func (*NatsAdapter) Request

func (bus *NatsAdapter) Request(topic string, data []byte, timeout time.Duration) (gobus.Message, error)

func (*NatsAdapter) Subscribe

func (bus *NatsAdapter) Subscribe(topic, group string, fn func(gobus.Message)) (sub interface{}, err error)

func (*NatsAdapter) Unsubscribe

func (bus *NatsAdapter) Unsubscribe(sub interface{}) error

func (*NatsAdapter) Valid

func (bus *NatsAdapter) Valid() error

type NatsBus

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

NatsBus - box for handlers and callbacks.

func (*NatsBus) Publish

func (bus *NatsBus) Publish(topic string, args interface{}) error

Publish executes callback defined for a topic. Any additional argument will be transferred to the callback.

func (*NatsBus) Request

func (bus *NatsBus) Request(topic string, timeout time.Duration, args interface{}, result interface{}) error

Publish executes callback defined for a topic. Any additional argument will be transferred to the callback.

func (*NatsBus) RequestB

func (bus *NatsBus) RequestB(topic string, timeout time.Duration, args interface{}) ([]byte, error)

func (*NatsBus) Subscribe

func (bus *NatsBus) Subscribe(topic string, fn interface{}) error

func (?) (result, (error)), 注意订阅中包含 ">>" 是异步订阅

func (*NatsBus) SubscribeAsync

func (bus *NatsBus) SubscribeAsync(topic string, fn interface{}) error

func (?) (result, (error)), 异步订阅忽略 ">>",即无论任何情况下都是异步订阅

func (*NatsBus) SubscribeOnce

func (bus *NatsBus) SubscribeOnce(topic string, fn interface{}) error

func (?) (result, (error))

func (*NatsBus) SubscribeOnceAsync

func (bus *NatsBus) SubscribeOnceAsync(topic string, fn interface{}) error

func (?) (result, (error))

func (*NatsBus) Unsubscribe

func (bus *NatsBus) Unsubscribe(topic string, handler interface{}) error

Unsubscribe removes callback defined for a topic. Returns error if there are no callbacks subscribed to the topic.

Jump to

Keyboard shortcuts

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