Documentation
¶
Index ¶
- type IMessage
- type MessageStorage
- func (m *MessageStorage) Check(ddl time.Time) (map[string]utils.Iterable[IMessage], error)
- func (m *MessageStorage) Check0(ddl time.Time) (map[string]utils.Iterable[IMessage], error)
- func (m *MessageStorage) Clear()
- func (m *MessageStorage) Drop(srcId string) error
- func (m *MessageStorage) Drop0(srcId string) error
- func (m *MessageStorage) Store(msg IMessage) (IMessage, error)
- func (m *MessageStorage) Store0(msg IMessage) (IMessage, error)
- func (m *MessageStorage) Take(tgtId string) (utils.Iterable[IMessage], error)
- func (m *MessageStorage) Take0(tgtId string) (utils.Iterable[IMessage], error)
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 ¶
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 ¶
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.