msgstorage

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 4 Imported by: ? modules, 0 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 IMessage

type IMessage interface {

	// Get the source id of the message.
	// this call should be constant for this message instance.
	GetSource() string

	// Get the target id of the message.
	// this call should be constant for this message instance.
	GetTarget() string

	// Get the expiration time of the message.
	// this call should be constant for this message instance.
	GetExpireTime() time.Time
}

type MessageStorage

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

MessageStorage is a storage for messages.

func NewMessageStorage

func NewMessageStorage(limitPerSrc uint) *MessageStorage

func (*MessageStorage) Check

func (m *MessageStorage) Check(ddl time.Time) (map[string]utils.Iterable[IMessage], error)

Check the storage for expired (expire <= deadline) messages; with lock. Returns a map of expired messages for each client, grouped by source id. Returns an error if the messages could not be checked.

func (*MessageStorage) Check0

func (m *MessageStorage) Check0(ddl time.Time) (map[string]utils.Iterable[IMessage], error)

Check0 the storage for expired (expire <= deadline) messages. Returns a map of expired messages for each client, grouped by source id. Returns an error if the messages could not be checked.

func (*MessageStorage) Clear

func (m *MessageStorage) Clear()

func (*MessageStorage) Drop

func (m *MessageStorage) Drop(srcId string) error

Drop0 all messages for a specific client (with source id); with lock. Returns an error if the messages could not be dropped.

func (*MessageStorage) Drop0

func (m *MessageStorage) Drop0(srcId string) error

Drop0 all messages for a specific client (with source id). Returns an error if the messages could not be dropped.

func (*MessageStorage) Store

func (m *MessageStorage) Store(msg IMessage) (IMessage, error)

Store a message for a client; with lock. Returns the overflown message and the expiration time Returns an error if the message could not be stored.

func (*MessageStorage) Store0

func (m *MessageStorage) Store0(msg IMessage) (IMessage, error)

Store a message for a client. Returns the overflown message and the expiration time Returns an error if the message could not be stored.

func (*MessageStorage) Take

func (m *MessageStorage) Take(tgtId string) (utils.Iterable[IMessage], error)

Take all valid messages for a specific client (with target id); with lock. Returns a slice of messages. Returns an error if the messages could not be retrieved.

func (*MessageStorage) Take0

func (m *MessageStorage) Take0(tgtId string) (utils.Iterable[IMessage], error)

Take all valid messages for a specific client (with target id). Returns a slice of messages. Returns an error if the messages could not be retrieved.

Jump to

Keyboard shortcuts

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