mq

package
v0.8.6 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrClosed close
	ErrClosed = errors.New("pipe.q.closed")

	//ErrCtrlQFull ctrl q full
	ErrCtrlQFull = errors.New("pipe.q.ctrl.full")
	//ErrReqQFull req q full
	ErrReqQFull = errors.New("pipe.q.req.full")

	//ErrSync never gonna happen
	ErrSync = errors.New("never.gonna.happen.crazy")
)

Functions

This section is empty.

Types

type MQ

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

MQ actor queue structure define

func NewMQ

func NewMQ(options ...Option) *MQ

NewMQ new queue

func (*MQ) AddCtrl

func (a *MQ) AddCtrl(cmd interface{}) error

AddCtrl add control request to the control queue end place.

func (*MQ) AddCtrlAnyway

func (a *MQ) AddCtrlAnyway(cmd interface{}, ts time.Duration) error

AddCtrlAnyway dd control request to the control queue end place anyway if queue full, sleep then try

func (*MQ) AddPriorCtrl

func (a *MQ) AddPriorCtrl(cmd interface{}) error

AddPriorCtrl add control request to the control queue first place.

func (*MQ) AddPriorReq

func (a *MQ) AddPriorReq(req interface{}) error

AddPriorReq add normal request to the normal queue first place.

func (*MQ) AddReq

func (a *MQ) AddReq(req interface{}) error

AddReq add normal request to the normal queue end place.

func (*MQ) AddReqAnyway

func (a *MQ) AddReqAnyway(req interface{}, ts time.Duration) error

AddReqAnyway add normal request to the normal queue end place anyway if queue full, sleep then try

func (*MQ) Close

func (a *MQ) Close()

Close : close the queue

func (*MQ) IsCleared

func (a *MQ) IsCleared() bool

IsCleared is cleared or not

func (*MQ) IsClosed

func (a *MQ) IsClosed() bool

IsClosed is closed or not

func (*MQ) Pop

func (a *MQ) Pop() (interface{}, error)

Pop consume an item, if list is empty, it's been blocked

func (*MQ) PopAnyway

func (a *MQ) PopAnyway() (interface{}, error)

PopAnyway consume an item like Pop, but it can consume even the queue is closed.

func (*MQ) TryClear

func (a *MQ) TryClear() bool

TryClear try to clear a queue. the function should be called by consumer. if the queue be set can pop even after closed. the consumer handle the last pop item, it can call the function. after the function be called, which means the queue is totally clear. no producer/no consumer anymore

func (*MQ) TryClose

func (a *MQ) TryClose() bool

TryClose try to close a queue in case it's empty. otherwise, the queue can not be closed.

func (*MQ) WaitClear

func (a *MQ) WaitClear(ctx context.Context) error

WaitClear wait clear, must call in another go routine clear must be called after queue closed. be caution: if there is no one to call TryClear to clear the queue the clear would never happen

func (*MQ) WaitClose

func (a *MQ) WaitClose(ctx context.Context) error

WaitClose wait close, must call in another go routine

type Option

type Option func(o *_Option)

Option : option function

func WithQCtrlSize

func WithQCtrlSize(num int) Option

WithQCtrlSize setup max queue number of control queue if max is 0, which means no limit

func WithQReqSize

func WithQReqSize(num int) Option

WithQReqSize setup max queue number of request queue if max is 0, which means no limit

Jump to

Keyboard shortcuts

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