queue

package module
v0.0.0-...-236808b Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: BSD-2-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package queue manage queue's logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

func NewManager

func NewManager(queueMaxLen int, publisher NoticePublisher) *Manager

func (*Manager) GetRawQueue

func (m *Manager) GetRawQueue(name string) Queue

manually lock (by call Lock) manually publish notice (by call PublishNotice)

func (*Manager) GetSyncQueue

func (m *Manager) GetSyncQueue(name string) Queue

automatically lock automatically publish notice

func (*Manager) RawQueue

func (m *Manager) RawQueue(name string) Queue

manually lock (by call Lock) manually publish notice (by call PublishNotice) create if not exist.

func (*Manager) SyncQueue

func (m *Manager) SyncQueue(name string) Queue

automatically lock automatically publish notice create if not exist.

type NoticePublisher

type NoticePublisher interface {
	Publish(channel string, message datadef.Marshaler)
}

func NewRedisPublisher

func NewRedisPublisher(conf *RedisPublisherConfig) NoticePublisher

type Queue

type Queue interface {
	sync.Locker

	// lockfree
	Name() string
	Len() int

	// ErrRunOut ErrAlreadyExist
	Push(key, value string, priority int64, force bool) (pos protodef.QUEUEPOS, rank int, err error)

	// ErrRunOut ErrAlreadyExist
	Repush(key, value string, pos protodef.QUEUEPOS) (rank int, err error)

	// ErrRunOut
	Pop(numMin, numMax int) (pops []protodef.PopElement, err error)

	// ErrNotFound
	Remove(key string, pos protodef.QUEUEPOS) error

	// concurrently-access
	PublishNotice()
}

type RedisPublisherConfig

type RedisPublisherConfig struct {
	Addr string
	Pass string

	BufferSize int
	WorkerNum  int
}

Directories

Path Synopsis
common
datadef
Package datadef defines some common types.
Package datadef defines some common types.

Jump to

Keyboard shortcuts

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