timequeue

package module
v0.0.0-...-06b2b74 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2020 License: MIT Imports: 17 Imported by: 0

README

timequeue

timequeue is a channel-driven and chronological-based time queue writen in pure golang.

the project is work in progress, so api is unstable, use it at your own risk.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GroupQueue

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

func NewGroupQueue

func NewGroupQueue(swarmPerGroup int) *GroupQueue

NewGroupQueue ...

type TimeQueue

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

TimeQueue represents a time queue

func New

func New() *TimeQueue

New returns a initialized time queue

func (*TimeQueue) EnQueue

func (tq *TimeQueue) EnQueue(value interface{}, delay time.Duration)

EnQueue enters time queue, stay in queue for duration delay then leave immediately, it will leave immediately if delay less or equal than 0.

func (*TimeQueue) Len

func (tq *TimeQueue) Len() int

Len returns the length of time queue

func (*TimeQueue) MustPersist

func (tq *TimeQueue) MustPersist(filename string, maxExpired int64, value interface{}, registry map[string]interface{}) *TimeQueue

MustPersist must enable persistence for time queue, otherwise panics if there are any error occurred

func (*TimeQueue) Persist

func (tq *TimeQueue) Persist(filename string, maxExpired int64, value interface{}, registry map[string]interface{}) (*TimeQueue, error)

Persist enable persistence for time queue

func (*TimeQueue) PersistOff

func (tq *TimeQueue) PersistOff() *TimeQueue

PersistOff turns persistence off

func (*TimeQueue) PersistOn

func (tq *TimeQueue) PersistOn() *TimeQueue

PersistOn turns persistence on

func (*TimeQueue) Persistent

func (tq *TimeQueue) Persistent() bool

Persistent reports whether persistence is enabled

func (*TimeQueue) Receive

func (tq *TimeQueue) Receive(buf int) <-chan interface{}

Receive returns a received only channel, which can be used for receiving Value left from queue

func (*TimeQueue) SetMaxExpiredStorage

func (tq *TimeQueue) SetMaxExpiredStorage(maxExpired int64)

SetMaxExpiredStorage sets maximum expired data in bytes

func (*TimeQueue) Traverse

func (tq *TimeQueue) Traverse() <-chan interface{}

Traverse returns a received only channel, which can be used to receive traversing result

func (*TimeQueue) TraverseF

func (tq *TimeQueue) TraverseF(f TravFunc)

TraverseF traverses time queue tq with function f

type TravFunc

type TravFunc func(interface{})

TravFunc is used for traversing time queue, the argument of TravFunc is Value stored in queue item

Jump to

Keyboard shortcuts

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