queue

package
v2.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrQueueClosed = errors.New("queue is closed")

ErrQueueClosed queue is closed

Functions

This section is empty.

Types

type Config

type Config struct {
	Name          string        `yaml:"name" json:"name"`
	BatchSize     int           `yaml:"batchSize" json:"batchSize" default:"10"`
	ExpireTime    time.Duration `yaml:"expireTime" json:"expireTime" default:"168h"`
	CleanInterval time.Duration `yaml:"cleanInterval" json:"cleanInterval" default:"1h"`
	WriteTimeout  time.Duration `yaml:"writeTimeout" json:"writeTimeout" default:"100ms"`
	DeleteTimeout time.Duration `yaml:"deleteTimeout" json:"deleteTimeout" default:"500ms"`
}

Config queue config

type Persistence

type Persistence struct {
	utils.Tomb
	sync.Mutex
	// contains filtered or unexported fields
}

Persistence is a persistent queue

func (*Persistence) Chan

func (q *Persistence) Chan() <-chan *common.Event

Chan returns message channel

func (*Persistence) Close

func (q *Persistence) Close(clean bool) error

Close closes this queue and clean queue data when cleanSession is true

func (*Persistence) Disable added in v2.2.3

func (q *Persistence) Disable()

Disable disable

func (*Persistence) ID added in v2.2.3

func (q *Persistence) ID() string

ID return id

func (*Persistence) Pop

func (q *Persistence) Pop() (*common.Event, error)

Pop pops a message from queue

func (*Persistence) Push

func (q *Persistence) Push(e *common.Event) (err error)

Push pushes a message into queue

type Queue

type Queue interface {
	ID() string
	Push(*common.Event) error
	Pop() (*common.Event, error)
	Chan() <-chan *common.Event
	Disable()
	Close(bool) error
}

Queue interfaces

func NewPersistence

func NewPersistence(cfg Config, bucket store.BatchBucket) (Queue, error)

NewPersistence creates a new persistent queue

func NewTemporary

func NewTemporary(id string, capacity int, dropIfFull bool) Queue

NewTemporary creates a new temporary queue

type Temporary

type Temporary struct {
	sync.Once
	// contains filtered or unexported fields
}

Temporary is an temporary queue in memory

func (*Temporary) Chan

func (q *Temporary) Chan() <-chan *common.Event

Chan returns message channel

func (*Temporary) Close

func (q *Temporary) Close(_ bool) error

Close closes this queue

func (*Temporary) Disable added in v2.2.3

func (q *Temporary) Disable()

Disable disable

func (*Temporary) ID added in v2.2.3

func (q *Temporary) ID() string

ID return id

func (*Temporary) Pop

func (q *Temporary) Pop() (*common.Event, error)

Pop pops a message from queue

func (*Temporary) Push

func (q *Temporary) Push(e *common.Event) error

Push pushes a message to queue

Jump to

Keyboard shortcuts

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