mailbox

package
v0.0.0-...-47b5856 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 11 Imported by: 10

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