Documentation
¶
Index ¶
- Constants
- func GetNatsMsg() *nats.Msg
- func NewReqID() uint64
- func NewStringReqID() string
- func ReleaseNatsMsg(natsMsg *nats.Msg)
- type Connect
- func (p *Connect) Address() string
- func (p *Connect) Close()
- func (p *Connect) Connect()
- func (p *Connect) GetName() string
- func (p *Connect) MaxReconnects() int
- func (p *Connect) QueueSubscribe(subject, queue string, cb nats.MsgHandler) error
- func (p *Connect) ReconnectDelay() time.Duration
- func (p *Connect) Request(subject string, data []byte, tod ...time.Duration) ([]byte, error)
- func (p *Connect) RequestReply(reqID, reply string, data []byte) error
- func (p *Connect) RequestSync(reqID, subject string, data []byte, tod ...time.Duration) ([]byte, error)
- func (p *Connect) RequestTimeout() time.Duration
- func (p *Connect) StatsInterval() time.Duration
- func (p *Connect) Subscribe(subject string, cb nats.MsgHandler) error
- func (p *Connect) SubscribeReply(replySubject string) error
- func (p *Connect) Timeout(tod ...time.Duration) time.Duration
- type OptionFunc
- func WithAddress(address string) OptionFunc
- func WithAuth(user, password string) OptionFunc
- func WithIsStats(isStats bool) OptionFunc
- func WithParams(maxReconnects int) OptionFunc
- func WithReconnectDelay(delay time.Duration) OptionFunc
- func WithRequestTimeout(timeout time.Duration) OptionFunc
- func WithStatsInterval(seconds int) OptionFunc
Constants ¶
const (
REQ_ID = "reqID"
)
Variables ¶
This section is empty.
Functions ¶
func GetNatsMsg ¶ added in v1.4.22
func NewStringReqID ¶ added in v1.4.22
func NewStringReqID() string
func ReleaseNatsMsg ¶ added in v1.4.22
Types ¶
type Connect ¶ added in v1.4.4
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) 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 (*Connect) RequestReply ¶ added in v1.6.2
func (*Connect) RequestSync ¶ added in v1.4.4
func (*Connect) RequestTimeout ¶ added in v1.4.22
func (*Connect) StatsInterval ¶ added in v1.4.22
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
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.
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