nats

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(cfg *Config)

Init create producer

Types

type Config

type Config struct {
	Addr string `mapstructure:"name"`
}

Config nats config

type Consumer

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

Consumer define a nats consumer

func NewConsumer

func NewConsumer(addr string) *Consumer

NewConsumer create consumer

func (*Consumer) Consume

func (c *Consumer) Consume(topic string, handler interface{}) error

Consume consume data from nats queue

func (*Consumer) ReConnect

func (c *Consumer) ReConnect()

ReConnect .

func (*Consumer) Run

func (c *Consumer) Run() error

Run .

func (*Consumer) Start

func (c *Consumer) Start() error

Start .

func (*Consumer) Stop

func (c *Consumer) Stop()

Stop .

type Producer

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

Producer define a nats producer

var (
	// Queue nats queue
	Queue *Producer
)

func NewProducer

func NewProducer(addr string) *Producer

NewProducer create a producer

func (*Producer) Publish

func (p *Producer) Publish(topic string, data interface{}) error

Publish push data to queue

func (*Producer) ReConnect

func (p *Producer) ReConnect()

ReConnect .

func (*Producer) Run

func (p *Producer) Run() error

Run .

func (*Producer) Start

func (p *Producer) Start() error

Start .

func (*Producer) Stop

func (p *Producer) Stop()

Stop .

Jump to

Keyboard shortcuts

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