Documentation ¶
Index ¶
- Constants
- type Client
- type FixedHeader
- type LWT
- type Message
- type MockStore
- 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) 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 = "sub" KServerInfo = "srv" KRetained = "ret" KInflight = "ifm" KClient = "cl" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { 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 Username []byte // the username the client authenticated with. LWT LWT // the last-will-and-testament message for the client. }
Client contains client data that can be persistently stored.
type FixedHeader ¶
type FixedHeader struct { Type byte // the type of the packet (PUBLISH, SUBSCRIBE, etc) from bits 7 - 4 (byte 1). Dup bool // indicates if the packet was already sent at an earlier time. Qos byte // indicates the quality of service expected. Retain bool // whether the message should be retained. Remaining int // the number of remaining bytes in the payload. }
FixedHeader contains the fixed header properties of a message.
type LWT ¶
type LWT struct { Topic string // the topic the will message shall be sent to. Message []byte // the message that shall be sent when the client disconnects. 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 { ID string // the storage key. T string // the type of the stored data. Client string // the id of the client who sent the message (if inflight). FixedHeader FixedHeader // the header properties of the message. PacketID uint16 // the unique id of the packet (if inflight). TopicName string // the topic the message was sent to (if retained). Payload []byte // the message payload (if retained). 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). }
Message contains the details of a retained or inflight message.
type MockStore ¶
type MockStore struct { FailOpen bool // error on open. Closed bool // indicate mock store is closed. Opened bool // indicate mock store is open. Fail map[string]bool // issue errors for different methods. }
MockStore is a mock storage backend for testing.
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) 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() WriteSubscription(v Subscription) error WriteClient(v Client) error WriteInflight(v Message) error WriteServerInfo(v ServerInfo) error WriteRetained(v Message) error DeleteSubscription(id string) error DeleteClient(id string) error DeleteInflight(id string) error DeleteRetained(id string) error ReadSubscriptions() (v []Subscription, err error) ReadInflight() (v []Message, err error) ReadRetained() (v []Message, err error) ReadClients() (v []Client, err error) ReadServerInfo() (v ServerInfo, err 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.