queue

package
v0.0.0-...-39cffea Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HandleTimeout = 5 * time.Second
)

const

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler interface {
	Name() string
	Handle(ctx context.Context, data []byte) error
}

Handler of MsgQue

type HandlerWrapper

type HandlerWrapper struct {
	NameValue string
	Impl      func(ctx context.Context, data []byte) error
}

HandlerWrapper for Handler

func HandlerWrap

func HandlerWrap(name string, f func(ctx context.Context, data []byte) error) *HandlerWrapper

HandlerWrap function for Handler interface

func (*HandlerWrapper) Handle

func (hw *HandlerWrapper) Handle(ctx context.Context, data []byte) error

Handle of hw

func (*HandlerWrapper) Name

func (hw *HandlerWrapper) Name() string

Name of the handler

type MsgQueue

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

MsgQueue struct

func NewMsgQueue

func NewMsgQueue() *MsgQueue

NewMsgQueue creats new MsaQueue

func (*MsgQueue) Handlers

func (mq *MsgQueue) Handlers() map[string]map[Handler]UnSub

Handlers of all topics

func (*MsgQueue) Pub

func (mq *MsgQueue) Pub(topic string, data []byte) error

Pub data into the topic

func (*MsgQueue) Run

func (mq *MsgQueue) Run()

Run the background processor

func (*MsgQueue) Stop

func (mq *MsgQueue) Stop()

Stop the message queue

func (*MsgQueue) Sub

func (mq *MsgQueue) Sub(topic string, handler Handler) (UnSub, error)

Sub topic with specific handler

type Publisher

type Publisher interface {
	Pub(topic string, data []byte) error
}

Publisher xxx

type Subscriber

type Subscriber interface {
	Sub(topic string, handler Handler) (UnSub, error)
}

Subscriber xxx

type UnSub

type UnSub func()

UnSub the handler

Jump to

Keyboard shortcuts

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