msgstore

package
v0.0.0-...-e3e94bd Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MessageStore

type MessageStore interface {
	// 返回的布尔值表示消息存储是否成功,msg 的类型一般是 *protoext.SignedGossipMessage。
	Add(msg interface{}) bool

	// 返回的布尔值表示消息是否合法,是否能被存储,实际上就是将给定的消息与存储区里的每个
	// 消息进行一一对比,如果给定的消息在某个已存储的消息面前是无效的,那么此消息就是不合
	// 法的,例如给定的消息是反映节点状态的消息,由于节点状态会随着时间而变化,所以如果给
	// 定的消息比存储区中某个消息旧,说明给定的消息已经过时了,不足以反映节点的当前状态,
	// 那么此时给定的消息就是无效的,或者说是不合法的,不适合再存储到存储区里了。
	//
	// 传入的 interface{} 是 *protoext.SignedGossipMessage。
	CheckValid(msg interface{}) bool

	// 返回当前消息存储区中存储的消息条数(去除掉已过期的消息)。
	Size() int

	// 返回当前存储区中的所有消息(不包含已过期的消息)。
	Get() []interface{}

	// 停止消息存储服务。
	Stop()

	// 根据接收的谓词参数清楚特定的消息。
	Purge(func(interface{}) bool)
}

func NewMessageStore

func NewMessageStore(policy common.MessageReplacingPolicy, trigger invalidationTrigger) MessageStore

func NewMessageStoreExpirable

func NewMessageStoreExpirable(policy common.MessageReplacingPolicy, trigger invalidationTrigger, msgTTL time.Duration, externalLock func(), externalUnlock func(), externalExpire func(interface{})) MessageStore

Jump to

Keyboard shortcuts

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