Documentation
¶
Index ¶
- Constants
- type Client
- type FixedHeader
- type LWT
- type Message
- type MockStore
- func (s *MockStore) ClearExpiredInflight(d int64) error
- func (s *MockStore) Close()
- func (s *MockStore) DeleteClient(id string) error
- func (s *MockStore) DeleteInflight(id string) error
- func (s *MockStore) DeleteRetained(id string) error
- func (s *MockStore) DeleteSubscription(id string) error
- func (s *MockStore) Open() error
- func (s *MockStore) ReadClients() (v []Client, err error)
- func (s *MockStore) ReadInflight() (v []Message, err error)
- func (s *MockStore) ReadRetained() (v []Message, err error)
- func (s *MockStore) ReadServerInfo() (v ServerInfo, err error)
- func (s *MockStore) ReadSubscriptions() (v []Subscription, err error)
- func (s *MockStore) SetInflightTTL(seconds int64)
- func (s *MockStore) WriteClient(v Client) error
- func (s *MockStore) WriteInflight(v Message) error
- func (s *MockStore) WriteRetained(v Message) error
- func (s *MockStore) WriteServerInfo(v ServerInfo) error
- func (s *MockStore) WriteSubscription(v Subscription) error
- type ServerInfo
- type Store
- type Subscription
Constants ¶
const ( // KSubscription is the key for subscription data. KSubscription = "sub" // KServerInfo is the key for server info data. KServerInfo = "srv" // KRetained is the key for retained messages data. KRetained = "ret" // KInflight is the key for inflight messages data. KInflight = "ifm" // KClient is the key for client data. KClient = "cl" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { LWT LWT // the last-will-and-testament message for the client. Username []byte // the username the client authenticated with. ID string // the storage key. ClientID string // the id of the client. T string // the type of the stored data. Listener string // the last known listener id for the client }
Client contains client data that can be persistently stored.
type FixedHeader ¶
type FixedHeader struct { Remaining int // the number of remaining bytes in the payload. Type byte // the type of the packet (PUBLISH, SUBSCRIBE, etc) from bits 7 - 4 (byte 1). Qos byte // indicates the quality of service expected. Dup bool // indicates if the packet was already sent at an earlier time. Retain bool // whether the message should be retained. }
FixedHeader contains the fixed header properties of a message.
type LWT ¶
type LWT struct { Message []byte // the message that shall be sent when the client disconnects. Topic string // the topic the will message shall be sent to. Qos byte // the quality of service desired. Retain bool // indicates whether the will message should be retained }
LWT contains details about a clients LWT payload.
type Message ¶
type Message struct { Payload []byte // the message payload (if retained). FixedHeader FixedHeader // the header properties of the message. T string // the type of the stored data. ID string // the storage key. Client string // the id of the client who sent the message (if inflight). TopicName string // the topic the message was sent to (if retained). Created int64 // the time the message was created in unixtime (if inflight). Sent int64 // the last time the message was sent (for retries) in unixtime (if inflight). Resends int // the number of times the message was attempted to be sent (if inflight). PacketID uint16 // the unique id of the packet (if inflight). }
Message contains the details of a retained or inflight message.
type MockStore ¶
type MockStore struct { Fail map[string]bool // issue errors for different methods. FailOpen bool // error on open. Closed bool // indicate mock store is closed. Opened bool // indicate mock store is open. // contains filtered or unexported fields }
MockStore is a mock storage backend for testing.
func (*MockStore) ClearExpiredInflight ¶ added in v1.3.0
ReadServerInfo loads the server info from the storage instance.
func (*MockStore) DeleteClient ¶
DeleteClient deletes a client from the persistent store.
func (*MockStore) DeleteInflight ¶
DeleteInflight deletes an inflight message from the persistent store.
func (*MockStore) DeleteRetained ¶
DeleteRetained deletes a retained message from the persistent store.
func (*MockStore) DeleteSubscription ¶
DeleteSubscription deletes a subscription from the persistent store.
func (*MockStore) ReadClients ¶
ReadClients loads the clients from the storage instance.
func (*MockStore) ReadInflight ¶
ReadInflight loads the inflight messages from the storage instance.
func (*MockStore) ReadRetained ¶
ReadRetained loads the retained messages from the storage instance.
func (*MockStore) ReadServerInfo ¶
func (s *MockStore) ReadServerInfo() (v ServerInfo, err error)
ReadServerInfo loads the server info from the storage instance.
func (*MockStore) ReadSubscriptions ¶
func (s *MockStore) ReadSubscriptions() (v []Subscription, err error)
ReadSubscriptions loads the subscriptions from the storage instance.
func (*MockStore) SetInflightTTL ¶ added in v1.3.0
Close closes the storage instance.
func (*MockStore) WriteClient ¶
WriteClient writes a single client to the storage instance.
func (*MockStore) WriteInflight ¶
WriteInFlight writes a single InFlight message to the storage instance.
func (*MockStore) WriteRetained ¶
WriteRetained writes a single retained message to the storage instance.
func (*MockStore) WriteServerInfo ¶
func (s *MockStore) WriteServerInfo(v ServerInfo) error
WriteServerInfo writes server info to the storage instance.
func (*MockStore) WriteSubscription ¶
func (s *MockStore) WriteSubscription(v Subscription) error
WriteSubscription writes a single subscription to the storage instance.
type ServerInfo ¶
type ServerInfo struct { system.Info // embed the system info struct. ID string // the storage key. }
ServerInfo contains information and statistics about the server.
type Store ¶
type Store interface { Open() error Close() ReadSubscriptions() (v []Subscription, err error) WriteSubscription(v Subscription) error DeleteSubscription(id string) error ReadClients() (v []Client, err error) WriteClient(v Client) error DeleteClient(id string) error ReadInflight() (v []Message, err error) WriteInflight(v Message) error DeleteInflight(id string) error SetInflightTTL(seconds int64) ClearExpiredInflight(expiry int64) error ReadServerInfo() (v ServerInfo, err error) WriteServerInfo(v ServerInfo) error ReadRetained() (v []Message, err error) WriteRetained(v Message) error DeleteRetained(id string) error }
Store is an interface which details a persistent storage connector.
type Subscription ¶
type Subscription struct { ID string // the storage key. T string // the type of the stored data. Client string // the id of the client who the subscription belongs to. Filter string // the topic filter being subscribed to. QoS byte // the desired QoS byte. }
Subscription contains the details of a topic filter subscription.