mailbox

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 10 Imported by: 3 modules, 20 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mailbox

type Mailbox[T any] struct {
	// contains filtered or unexported fields
}

Mailbox contains a notify channel, a mutual exclusive lock, a queue of interfaces, and a queue capacity.

func New

func New[T any](capacity uint64) *Mailbox[T]

New creates a new mailbox instance. If name is non-empty, it must be unique and calling Start will launch prometheus metric monitor that periodically reports mailbox load until Close() is called.

func NewHighCapacity

func NewHighCapacity[T any]() *Mailbox[T]

NewHighCapacity create a new mailbox with a capacity that is better able to handle e.g. large log replays.

func NewSingle

func NewSingle[T any]() *Mailbox[T]

NewSingle returns a new Mailbox with capacity one.

func (*Mailbox[T]) Close

func (m *Mailbox[T]) Close() error

func (*Mailbox[T]) Deliver

func (m *Mailbox[T]) Deliver(x T) (wasOverCapacity bool)

Deliver appends to the queue and returns true if the queue was full, causing a message to be dropped.

func (*Mailbox[T]) Notify

func (m *Mailbox[T]) Notify() <-chan struct{}

Notify returns the contents of the notify channel

func (*Mailbox[T]) Retrieve

func (m *Mailbox[T]) Retrieve() (t T, ok bool)

Retrieve fetches one element from the queue.

func (*Mailbox[T]) RetrieveAll

func (m *Mailbox[T]) RetrieveAll() []T

RetrieveAll fetches all elements from the queue.

func (*Mailbox[T]) RetrieveLatestAndClear

func (m *Mailbox[T]) RetrieveLatestAndClear() (t T)

RetrieveLatestAndClear fetch the latest value (or nil), and clears the rest of the queue (if any).

type Monitor

type Monitor struct {
	services.StateMachine
	// contains filtered or unexported fields
}

func NewMonitor

func NewMonitor(appID string, lggr logger.Logger) *Monitor

func (*Monitor) Close

func (m *Monitor) Close() error

func (*Monitor) HealthReport

func (m *Monitor) HealthReport() map[string]error

func (*Monitor) Monitor

func (m *Monitor) Monitor(mb mailbox, name ...string)

func (*Monitor) Name

func (m *Monitor) Name() string

func (*Monitor) Start

func (m *Monitor) Start(context.Context) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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