Documentation
¶
Index ¶
- type Option
- func WithClientName(name string) Option
- func WithContext(ctx context.Context) Option
- func WithEncoder(encoder encoder.Encoder) Option
- func WithErrorHandler(h nc.ErrorHandler) Option
- func WithGroupName(name string) Option
- func WithLogger(logger loggerInterface) Option
- func WithNatsConn(conn *nats.Conn) Option
- func WithNatsOptions(natsOpts ...nats.Option) Option
- func WithNatsURL(urlString string) Option
- func WithNkey(pubKey string, sigCB nats.SignatureHandler) Option
- func WithPanicHandler(h nc.PanicHandler) Option
- func WithToken(token string) Option
- func WithTokenHandler(cb nats.AuthTokenHandler) Option
- func WithTopics(topics ...string) Option
- func WithUserCredentials(userOrChainedFile string, seedFiles ...string) Option
- func WithUserInfo(user, password string) Option
- func WithUserJWT(userCB nats.UserJWTHandler, sigCB nats.SignatureHandler) Option
- type Options
- type Publisher
- type Subscriber
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶ added in v1.0.0
type Option func(opt *Options)
Option of the NATS subscriber or publisher
func WithClientName ¶ added in v1.0.0
WithClientName is an Option to set the client name.
func WithContext ¶ added in v1.5.0
WithContext puts the client context value
func WithEncoder ¶ added in v1.0.0
WithEncoder set the message encoder
func WithErrorHandler ¶ added in v1.0.0
func WithErrorHandler(h nc.ErrorHandler) Option
WithErrorHandler set handler of error processing
func WithGroupName ¶ added in v1.0.0
WithGroupName puts the name group of the subsciber or publisher
func WithLogger ¶ added in v1.0.0
func WithLogger(logger loggerInterface) Option
WithLogger provides logging interface
func WithNatsConn ¶ added in v1.0.0
WithNatsConn is an Option to inited client connection
func WithNatsOptions ¶ added in v1.0.0
WithNatsOptions provides options of the NATS module
func WithNatsURL ¶ added in v1.0.0
WithNatsURL is an Option to set the URL the client should connect to. The url can contain username/password semantics. e.g. nats://derek:pass@localhost:4222/{groupName}?topics=topic1,topic2 Comma separated arrays are also supported, e.g. urlA, urlB.
func WithNkey ¶ added in v1.0.0
func WithNkey(pubKey string, sigCB nats.SignatureHandler) Option
WithNkey will set the public Nkey and the signature callback to sign the server nonce.
func WithPanicHandler ¶ added in v1.0.0
func WithPanicHandler(h nc.PanicHandler) Option
WithPanicHandler set handler of panic processing
func WithToken ¶ added in v1.0.0
WithToken is an Option to set the token to use when a token is not included directly in the URLs and when a token handler is not provided.
func WithTokenHandler ¶ added in v1.0.0
func WithTokenHandler(cb nats.AuthTokenHandler) Option
WithTokenHandler is an Option to set the token handler to use when a token is not included directly in the URLs and when a token is not set.
func WithTopics ¶ added in v1.1.0
WithTopics will set the list of topics for publishing or subscribing
func WithUserCredentials ¶ added in v1.0.0
WithUserCredentials is a convenience function that takes a filename for a user's JWT and a filename for the user's private Nkey seed.
func WithUserInfo ¶ added in v1.0.0
WithUserInfo is an Option to set the username and password to use when not included directly in the URLs.
func WithUserJWT ¶ added in v1.0.0
func WithUserJWT(userCB nats.UserJWTHandler, sigCB nats.SignatureHandler) Option
WithUserJWT will set the callbacks to retrieve the user's JWT and the signature callback to sign the server nonce. This an the Nkey option are mutually exclusive.
type Options ¶ added in v1.0.0
type Options struct { Ctx context.Context // Inited NATS connection Conn *nats.Conn // ConnURL of connection ConnURL string // Raw options from the "github.com/nats-io/nats.go" module NatsOptions []nats.Option // Name of the subscription group GroupName string // Names of topics for subscribing or publishing Topics []string // ErrorHandler of message processing ErrorHandler nc.ErrorHandler // PanicHandler process panic PanicHandler nc.PanicHandler // Message encoder interface Encoder encoder.Encoder // Logger of subscriber Logger loggerInterface }
Options of the NATS wrapper
type Publisher ¶ added in v1.0.0
type Publisher struct {
// contains filtered or unexported fields
}
Publisher provides functionality to work with NATS queue
func MustNewPublisher ¶ added in v1.0.0
MustNewPublisher object
func NewPublisher ¶ added in v1.0.0
NewPublisher object
type Subscriber ¶
type Subscriber struct { notificationcenter.ModelSubscriber // contains filtered or unexported fields }
Subscriber for NATS queue
func MustNewSubscriber ¶
func MustNewSubscriber(options ...Option) *Subscriber
MustNewSubscriber creates new subscriber object
func NewSubscriber ¶
func NewSubscriber(options ...Option) (*Subscriber, error)
NewSubscriber creates new subscriber object @url nats://login:password@hostname:port/group?topics=topic1,topic2,topicN