queue

package
Version: v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Consumer

type Consumer interface {
	Subject() string
	Config() string
	Subscribe(Listener) error
}

Consumer define the consumer of message queue service

func NewConsumer

func NewConsumer(subject string) (Consumer, error)

NewConsumer returns a new consumer of message queue service

type Listener

type Listener func([]byte, Consumer)

Listener for message listening

type LocalConsumer

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

LocalConsumer define the comsumer for local message queue based on channel

func (*LocalConsumer) Config

func (c *LocalConsumer) Config() string

Config returns config of local message queue

func (*LocalConsumer) Subject

func (c *LocalConsumer) Subject() string

Subject returns subject of local message queue

func (*LocalConsumer) Subscribe

func (c *LocalConsumer) Subscribe(listener Listener) error

Subscribe sets the listener for local message queue based on channel

type LocalProducer

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

LocalProducer define the producer for local message queue based on channel

func (*LocalProducer) Config

func (p *LocalProducer) Config() string

Config returns config of local message queue

func (*LocalProducer) Produce

func (p *LocalProducer) Produce(data []byte) error

Produce sends data to local message queue

func (*LocalProducer) Subject

func (p *LocalProducer) Subject() string

Subject returns subject of local message queue

type LocalQueue

type LocalQueue struct {
	Subject string
	Config  string

	sync.Mutex
	// contains filtered or unexported fields
}

LocalQueue implements a inner version of message queue

func (*LocalQueue) Init

func (q *LocalQueue) Init() error

Init message queue

func (*LocalQueue) NewConsumer

func (q *LocalQueue) NewConsumer() (c Consumer, err error)

NewConsumer returns a new consumer for the message queue

func (*LocalQueue) NewProducer

func (q *LocalQueue) NewProducer() (p Producer, err error)

NewProducer returns a new producer for the message queue

type NatsConsumer

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

NatsConsumer define the consumer for local message queue based on channel

func (*NatsConsumer) Config

func (c *NatsConsumer) Config() string

Config returns config of local message queue

func (*NatsConsumer) Subject

func (c *NatsConsumer) Subject() string

Subject returns subject of local message queue

func (*NatsConsumer) Subscribe

func (c *NatsConsumer) Subscribe(listener Listener) (err error)

Subscribe sets the listener for local message queue based on channel

type NatsProducer

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

NatsProducer define the producer for local message queue based on channel

func (*NatsProducer) Config

func (p *NatsProducer) Config() string

Config returns config of local message queue

func (*NatsProducer) Produce

func (p *NatsProducer) Produce(data []byte) (err error)

Produce sends data to local message queue

func (*NatsProducer) Subject

func (p *NatsProducer) Subject() string

Subject returns subject of local message queue

type NatsQueue

type NatsQueue struct {
	Subject string
	Config  string
}

NatsQueue wraps nats client as a message queue service

func (*NatsQueue) Init

func (q *NatsQueue) Init() error

Init message queue

func (*NatsQueue) NewConsumer

func (q *NatsQueue) NewConsumer() (c Consumer, err error)

NewConsumer returns a new consumer for the message queue

func (*NatsQueue) NewProducer

func (q *NatsQueue) NewProducer() (p Producer, err error)

NewProducer returns a new producer for the message queue

type Producer

type Producer interface {
	Subject() string
	Config() string
	Produce([]byte) error
}

Producer define the producer of message queue service

func NewProducer

func NewProducer(subject string) (Producer, error)

NewProducer returns a new producer of message queue service

type Queue

type Queue interface {
	Init() error
	NewProducer() (Producer, error)
	NewConsumer() (Consumer, error)
}

Queue define the queue of message queue service

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL