mailbox

package
v0.0.0-...-be88ffe Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package mailbox implements mailbox queues and dispatching

Index

Constants

View Source
const DefaultPriority = int8(priorityLevels / 2)

Variables

This section is empty.

Functions

func NewPriorityGoringQueue

func NewPriorityGoringQueue() *priorityQueue

func NewPriorityMpscQueue

func NewPriorityMpscQueue() *priorityQueue

func NewPriorityQueue

func NewPriorityQueue(queueProducer func() queue) *priorityQueue

func SetLogLevel

func SetLogLevel(level log.Level)

SetLogLevel sets the log level for the logger.

SetLogLevel is safe to call concurrently

Types

type Dispatcher

type Dispatcher interface {
	Schedule(fn func())
	Throughput() int
}

func NewDefaultDispatcher

func NewDefaultDispatcher(throughput int) Dispatcher

func NewSynchronizedDispatcher

func NewSynchronizedDispatcher(throughput int) Dispatcher

type Mailbox

type Mailbox interface {
	PostUserMessage(message interface{})
	PostSystemMessage(message interface{})
	RegisterHandlers(invoker MessageInvoker, dispatcher Dispatcher)
	Start()
	UserMessageCount() int
}

Mailbox interface is used to enqueue messages to the mailbox

type MessageInvoker

type MessageInvoker interface {
	InvokeSystemMessage(interface{})
	InvokeUserMessage(interface{})
	EscalateFailure(reason interface{}, message interface{})
}

MessageInvoker is the interface used by a mailbox to forward messages for processing

type PriorityMessage

type PriorityMessage interface {
	GetPriority() int8
}

type Producer

type Producer func() Mailbox

Producer is a function which creates a new mailbox

func Bounded

func Bounded(size int, mailboxStats ...Statistics) Producer

Bounded returns a producer which creates an bounded mailbox of the specified size

func BoundedDropping

func BoundedDropping(size int, mailboxStats ...Statistics) Producer

Bounded dropping returns a producer which creates an bounded mailbox of the specified size that drops front element on push

func Unbounded

func Unbounded(mailboxStats ...Statistics) Producer

Unbounded returns a producer which creates an unbounded mailbox

func UnboundedLockfree

func UnboundedLockfree(mailboxStats ...Statistics) Producer

UnboundedLockfree returns a producer which creates an unbounded, lock-free mailbox. This mailbox is cheaper to allocate, but has a slower throughput than the plain Unbounded mailbox.

func UnboundedPriority

func UnboundedPriority(mailboxStats ...Statistics) Producer

func UnboundedPriorityMpsc

func UnboundedPriorityMpsc(mailboxStats ...Statistics) Producer

type ResumeMailbox

type ResumeMailbox struct{}

ResumeMailbox is message sent by the actor system to resume mailbox processing.

This will not be forwarded to the Receive method

type Statistics

type Statistics interface {
	MailboxStarted()
	MessagePosted(message interface{})
	MessageReceived(message interface{})
	MailboxEmpty()
}

type SuspendMailbox

type SuspendMailbox struct{}

SuspendMailbox is message sent by the actor system to suspend mailbox processing.

This will not be forwarded to the Receive method

Jump to

Keyboard shortcuts

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