package
0.0.0-20230310201401-7aac46a7fa12
Repository: https://github.com/mitghi/protox.git
Documentation: pkg.go.dev

# README

Messages

Persistent packet storage

Message order preservation

Description:

Preserve the original ordering in which messages were published to the wait queue while keeping memory usage and lookup complexity to a minimum.

Use Case:

Suppose clientA publishes a set of messages {message1, message2, ...., messagen} to a particular topic T which is subscribed by clientB. When clientB is offline and has a subscription with QoS > 0, messages are stored for redelivery whenever clientB becomes online. Due to the message sequence number ( Message ID ), messages can become out of order which violates consistency rule. Therefore it is crucial to have a mechanism to preserve message order, it should satisfy rule for two stages. The first stage is the partial ordering of unacknowledged messages, and the second stage is total order preservation of messages with the higher quality of service.

Change(s):

  • Improve message storage by implementing it with Ordered Sets as opposed to the current implementation which uses Hash Sets.

Test units

check to ensure that it passes all test cases and view the code coverage in html mode.

NOTE: msgidfull is the build tag for concurrent test case of GetNewID(uuid.UUID) which requires 65535 ( 0xFFFF )insertions. It must return 0 when all 65535 slots are occupied.

$ go test -v -coverprofile=cover.out . && go tool cover -html=cover.out
$ go test -v -tags msgidfull -coverprofile=cover.out . && go tool cover -html=cover.out

# Functions

DNextLevelP is a wrapper for `NextLevelP` and supplies default topic constants to it.
NewInitedMessageStore returns a pointer to a new `MessageStore` and allocates memory.
No description provided by the author
NewMessageId returns a pointer to a new `MessageId` struct.
No description provided by the author
No description provided by the author
NewMessageStore returns a pointer to a new `MessageStore`.
NewQueueId returns a pointer to a new initialized and allocated `QueueId` struct.
NewRetain allocates and initializes a new `Retain` struct and returns a pointer to it.
NewSub returns a pointer to a new `Subscribe` struct.
NextLevepP seperates individual components in a topic string.
TopicComponents is a wrapper func for `DNextLevelP`.

# Constants

Enum for topic components.
Enum for topic components.
Enum for topic components.
Enum for topic components.
Enum for topic components.
Enum for topic components.
Constant values for minimum and maximum number of packets.
Constant values for minimum and maximum number of packets.
Default seperator and wildcard.
Default seperator and wildcard.

# Variables

Retain error messages.
Retain error messages.
Subscribe error messages.

# Structs

No description provided by the author
MessageId is a struct which contains mapping of packet number to their unique identifier.
No description provided by the author
No description provided by the author
MessageStore is a struct which acts as an entry into the persistent storage.
MsgEntry maps a client id to a protocol packet.
No description provided by the author
No description provided by the author
No description provided by the author
Retain is the container for retained messages.
Subscribe is the second subscriptions struct.