cherryNats

package
v1.6.6 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

View Source
const (
	REQ_ID = "reqID"
)

Variables

This section is empty.

Functions

func GetNatsMsg added in v1.4.22

func GetNatsMsg() *nats.Msg

func NewReqID added in v1.4.22

func NewReqID() uint64

func NewStringReqID added in v1.4.22

func NewStringReqID() string

func ReleaseNatsMsg added in v1.4.22

func ReleaseNatsMsg(natsMsg *nats.Msg)

Types

type Connect added in v1.4.4

type Connect struct {
	*nats.Conn
	// contains filtered or unexported fields
}

func NewConnect added in v1.4.4

func NewConnect(name string, opts ...OptionFunc) *Connect

func NewConnectFromConfig added in v1.6.2

func NewConnectFromConfig(config cfacade.ProfileJSON, name string) (*Connect, error)

NewConnectFromConfig builds a *Connect from the cluster.nats config section. name identifies the connect (used in logs and as the reply subject suffix); it must be unique per process among connects that subscribe the same reply subject base. The returned Connect is NOT connected and has no reply subscription; the caller decides when to call Connect() and, if the connect will issue RequestSync, whether to call SubscribeReply.

func (*Connect) Address added in v1.4.4

func (p *Connect) Address() string

func (*Connect) Close added in v1.4.4

func (p *Connect) Close()

func (*Connect) Connect added in v1.4.4

func (p *Connect) Connect()

func (*Connect) GetName added in v1.6.2

func (p *Connect) GetName() string

func (*Connect) MaxReconnects added in v1.4.4

func (p *Connect) MaxReconnects() int

func (*Connect) QueueSubscribe added in v1.4.4

func (p *Connect) QueueSubscribe(subject, queue string, cb nats.MsgHandler) error

func (*Connect) ReconnectDelay added in v1.4.22

func (p *Connect) ReconnectDelay() time.Duration

func (*Connect) Request added in v1.4.4

func (p *Connect) Request(subject string, data []byte, tod ...time.Duration) ([]byte, error)

func (*Connect) RequestReply added in v1.6.2

func (p *Connect) RequestReply(reqID, reply string, data []byte) error

func (*Connect) RequestSync added in v1.4.4

func (p *Connect) RequestSync(reqID, subject string, data []byte, tod ...time.Duration) ([]byte, error)

func (*Connect) RequestTimeout added in v1.4.22

func (p *Connect) RequestTimeout() time.Duration

func (*Connect) StatsInterval added in v1.4.22

func (p *Connect) StatsInterval() time.Duration

func (*Connect) Subscribe added in v1.4.8

func (p *Connect) Subscribe(subject string, cb nats.MsgHandler) error

func (*Connect) SubscribeReply added in v1.6.2

func (p *Connect) SubscribeReply(replySubject string) error

SubscribeReply sets this connect's reply subject and subscribes to it, so that responses to RequestSync sent on this connect can be received. Call it after Connect() on connects that will issue requests; the subject base should be unique per node. Connects that only publish or subscribe do not need it.

func (*Connect) Timeout added in v1.4.22

func (p *Connect) Timeout(tod ...time.Duration) time.Duration

type OptionFunc

type OptionFunc func(o *options)

func WithAddress

func WithAddress(address string) OptionFunc

func WithAuth

func WithAuth(user, password string) OptionFunc

func WithIsStats added in v1.4.4

func WithIsStats(isStats bool) OptionFunc

func WithParams

func WithParams(maxReconnects int) OptionFunc

func WithReconnectDelay added in v1.4.22

func WithReconnectDelay(delay time.Duration) OptionFunc

func WithRequestTimeout added in v1.4.22

func WithRequestTimeout(timeout time.Duration) OptionFunc

func WithStatsInterval added in v1.4.22

func WithStatsInterval(seconds int) OptionFunc

Jump to

Keyboard shortcuts

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