goqueue

package
v0.0.0-...-01a1fb0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusPending    = iota // 0
	StatusProcessing        // 1
	StatusInvalid           // 2
	StatusOK                // 3
)

Variables

View Source
var (
	StoreBucket = []byte("stores")
	IdsBucket   = []byte("ids")
	StatBucket  = []byte("stats")
)

Functions

This section is empty.

Types

type Item

type Item struct {
	ID        int       `json:"id"`
	Message   string    `json:"message"`
	Status    int       `json:"status"`
	Error     string    `json:"error"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func NewItem

func NewItem(msg string) *Item

func NewItemFromBytes

func NewItemFromBytes(data []byte) (*Item, error)

func (*Item) Bytes

func (this *Item) Bytes() ([]byte, error)

func (*Item) Key

func (this *Item) Key() []byte

type Queue

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

func New

func New(name, dataPath string) (*Queue, error)

func (*Queue) Close

func (this *Queue) Close() error

func (*Queue) Exists

func (this *Queue) Exists(msg string) bool

func (*Queue) Find

func (this *Queue) Find(offset, limit int) []*Item

func (*Queue) Get

func (this *Queue) Get() (string, error)

func (*Queue) Put

func (this *Queue) Put(msg string) error

func (*Queue) Reply

func (this *Queue) Reply(msg string, status int, errMsg string) error

func (*Queue) ReplyInvalid

func (this *Queue) ReplyInvalid(msg, errMsg string) error

func (*Queue) ReplyOK

func (this *Queue) ReplyOK(msg string) error

func (*Queue) SetSeparator

func (this *Queue) SetSeparator(separator string)

仅用于判断消息是否存在 如果设置分隔符,会用分隔符切割,取分隔后的最后一段作为消息,判断消息是否存在

func (*Queue) Size

func (this *Queue) Size() int

返回队列中剩余数量

func (*Queue) Stats

func (this *Queue) Stats() *Stats

type Stats

type Stats struct {
	CurrentID int       `json:"current_id"`
	Size      int       `json:"size"`
	ReadSize  int       `json:"read_size"`
	ReplySize int       `json:"reply_size"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func (*Stats) String

func (this *Stats) String() string

Jump to

Keyboard shortcuts

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