mailbox

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LockFree

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

func NewLockFree

func NewLockFree(dispatcher dispatcher.Dispatcher, recipient Recipient) *LockFree

NewLockFree 创建一个基于无锁队列实现的邮箱,该邮箱基于 queues.LFQueue 实现

  • 默认邮箱在 userMessageBatchLimit 大于 1 时需要注意,一批用户消息将会被处理,而不会被系统消息抢先执行

func (*LockFree) DeliverySystemMessage

func (m *LockFree) DeliverySystemMessage(message prc.Message)

func (*LockFree) DeliveryUserMessage

func (m *LockFree) DeliveryUserMessage(message prc.Message)

func (*LockFree) Resume

func (m *LockFree) Resume()

func (*LockFree) Suspend

func (m *LockFree) Suspend()

type Mailbox

type Mailbox interface {
	// Suspend 暂停邮箱
	Suspend()

	// Resume 恢复邮箱
	Resume()

	// DeliveryUserMessage 投递用户消息到邮箱
	DeliveryUserMessage(message prc.Message)

	// DeliverySystemMessage 投递系统消息到邮箱
	DeliverySystemMessage(message prc.Message)
}

type Recipient

type Recipient interface {
	// ProcessUserMessage 处理用户消息
	ProcessUserMessage(message prc.Message)

	// ProcessSystemMessage 处理系统消息
	ProcessSystemMessage(message prc.Message)

	// ProcessAccident 处理意外情况
	ProcessAccident(reason prc.Message)
}

Recipient 邮箱接收者接口

Jump to

Keyboard shortcuts

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