cherryNats

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChanExecute

func ChanExecute(subject string, msgChan chan *nats.Msg, process func(msg *nats.Msg))

func ChanSubscribe

func ChanSubscribe(subj string, ch chan *nats.Msg) (*nats.Subscription, error)

func Close

func Close()

func Init

func Init()

func Publish

func Publish(subj string, data []byte) error

func Request

func Request(subj string, data []byte, timeout time.Duration) (*nats.Msg, error)

func Subscribe

func Subscribe(subj string, cb nats.MsgHandler) (*nats.Subscription, error)

Types

type NatsConnect

type NatsConnect struct {
	*nats.Conn
	Options
}

func App

func App() *NatsConnect

func New

func New(opts ...OptionFunc) *NatsConnect

func (*NatsConnect) Connect

func (p *NatsConnect) Connect()

func (*NatsConnect) GetNatsOption

func (p *NatsConnect) GetNatsOption() []nats.Option

func (*NatsConnect) LoadConfig

func (p *NatsConnect) LoadConfig(config cfacade.JsonConfig)

type OptionFunc

type OptionFunc func(opts *Options)

func WithAddress

func WithAddress(address string) OptionFunc

func WithAuth

func WithAuth(user, password string) OptionFunc

func WithParams

func WithParams(reconnectDelay int, maxReconnects int, requestTimeout time.Duration) OptionFunc

type Options

type Options struct {
	Address        string
	ReconnectDelay int
	MaxReconnects  int
	RequestTimeout time.Duration
	User           string
	Password       string
}

Jump to

Keyboard shortcuts

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