Documentation ¶
Overview ¶
Package queue is a generated GoMock package.
Package queue is a generated GoMock package.
Index ¶
- Variables
- func ElemExpiry(now time.Time, elem *Elem) bool
- type Elem
- type InitOptions
- type InternalError
- type MessageWithID
- type MockMessageWithID
- type MockMessageWithIDMockRecorder
- type MockNotifier
- type MockNotifierMockRecorder
- type MockStore
- func (m *MockStore) Add(elem *Elem) error
- func (m *MockStore) Clean() error
- func (m *MockStore) Close() error
- func (m *MockStore) EXPECT() *MockStoreMockRecorder
- func (m *MockStore) Init(opts *InitOptions) error
- func (m *MockStore) Read(pids []packets.PacketID) ([]*Elem, error)
- func (m *MockStore) ReadInflight(maxSize uint) ([]*Elem, error)
- func (m *MockStore) Remove(pid packets.PacketID) error
- func (m *MockStore) Replace(elem *Elem) (bool, error)
- type MockStoreMockRecorder
- func (mr *MockStoreMockRecorder) Add(elem interface{}) *gomock.Call
- func (mr *MockStoreMockRecorder) Clean() *gomock.Call
- func (mr *MockStoreMockRecorder) Close() *gomock.Call
- func (mr *MockStoreMockRecorder) Init(opts interface{}) *gomock.Call
- func (mr *MockStoreMockRecorder) Read(pids interface{}) *gomock.Call
- func (mr *MockStoreMockRecorder) ReadInflight(maxSize interface{}) *gomock.Call
- func (mr *MockStoreMockRecorder) Remove(pid interface{}) *gomock.Call
- func (mr *MockStoreMockRecorder) Replace(elem interface{}) *gomock.Call
- type Notifier
- type Publish
- type Pubrel
- type Store
Constants ¶
This section is empty.
Variables ¶
var ( ErrClosed = errors.New("queue has been closed") ErrDropExceedsMaxPacketSize = errors.New("maximum packet size exceeded") ErrDropQueueFull = errors.New("the message queue is full") ErrDropExpired = errors.New("the message is expired") ErrDropExpiredInflight = errors.New("the inflight message is expired") )
Functions ¶
Types ¶
type Elem ¶
type Elem struct { // At represents the entry time. At time.Time // Expiry represents the expiry time. // Empty means never expire. Expiry time.Time MessageWithID }
Elem represents the element store in the queue.
type InitOptions ¶
type InitOptions struct { // CleanStart is the cleanStart field in the connect packet. CleanStart bool // Version is the client MQTT protocol version. Version packets.Version // ReadBytesLimit indicates the maximum publish size that is allow to read. ReadBytesLimit uint32 Notifier Notifier }
InitOptions is used to pass some required client information to the queue.Init()
type InternalError ¶
type InternalError struct { // Err is the error return by the backend storage. Err error }
InternalError wraps the error of the backend storage.
func (*InternalError) Error ¶
func (i *InternalError) Error() string
type MessageWithID ¶
type MockMessageWithID ¶
type MockMessageWithID struct {
// contains filtered or unexported fields
}
MockMessageWithID is a mock of MessageWithID interface
func NewMockMessageWithID ¶
func NewMockMessageWithID(ctrl *gomock.Controller) *MockMessageWithID
NewMockMessageWithID creates a new mock instance
func (*MockMessageWithID) EXPECT ¶
func (m *MockMessageWithID) EXPECT() *MockMessageWithIDMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockMessageWithID) ID ¶
func (m *MockMessageWithID) ID() packets.PacketID
ID mocks base method
func (*MockMessageWithID) SetID ¶
func (m *MockMessageWithID) SetID(id packets.PacketID)
SetID mocks base method
type MockMessageWithIDMockRecorder ¶
type MockMessageWithIDMockRecorder struct {
// contains filtered or unexported fields
}
MockMessageWithIDMockRecorder is the mock recorder for MockMessageWithID
func (*MockMessageWithIDMockRecorder) ID ¶
func (mr *MockMessageWithIDMockRecorder) ID() *gomock.Call
ID indicates an expected call of ID
func (*MockMessageWithIDMockRecorder) SetID ¶
func (mr *MockMessageWithIDMockRecorder) SetID(id interface{}) *gomock.Call
SetID indicates an expected call of SetID
type MockNotifier ¶ added in v0.3.2
type MockNotifier struct {
// contains filtered or unexported fields
}
MockNotifier is a mock of Notifier interface
func NewMockNotifier ¶ added in v0.3.2
func NewMockNotifier(ctrl *gomock.Controller) *MockNotifier
NewMockNotifier creates a new mock instance
func (*MockNotifier) EXPECT ¶ added in v0.3.2
func (m *MockNotifier) EXPECT() *MockNotifierMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockNotifier) NotifyDropped ¶ added in v0.3.2
func (m *MockNotifier) NotifyDropped(elem *Elem, err error)
NotifyDropped mocks base method
func (*MockNotifier) NotifyInflightAdded ¶ added in v0.3.2
func (m *MockNotifier) NotifyInflightAdded(delta int)
NotifyInflightAdded mocks base method
func (*MockNotifier) NotifyMsgQueueAdded ¶ added in v0.3.2
func (m *MockNotifier) NotifyMsgQueueAdded(delta int)
NotifyMsgQueueAdded mocks base method
type MockNotifierMockRecorder ¶ added in v0.3.2
type MockNotifierMockRecorder struct {
// contains filtered or unexported fields
}
MockNotifierMockRecorder is the mock recorder for MockNotifier
func (*MockNotifierMockRecorder) NotifyDropped ¶ added in v0.3.2
func (mr *MockNotifierMockRecorder) NotifyDropped(elem, err interface{}) *gomock.Call
NotifyDropped indicates an expected call of NotifyDropped
func (*MockNotifierMockRecorder) NotifyInflightAdded ¶ added in v0.3.2
func (mr *MockNotifierMockRecorder) NotifyInflightAdded(delta interface{}) *gomock.Call
NotifyInflightAdded indicates an expected call of NotifyInflightAdded
func (*MockNotifierMockRecorder) NotifyMsgQueueAdded ¶ added in v0.3.2
func (mr *MockNotifierMockRecorder) NotifyMsgQueueAdded(delta interface{}) *gomock.Call
NotifyMsgQueueAdded indicates an expected call of NotifyMsgQueueAdded
type MockStore ¶
type MockStore struct {
// contains filtered or unexported fields
}
MockStore is a mock of Store interface
func NewMockStore ¶
func NewMockStore(ctrl *gomock.Controller) *MockStore
NewMockStore creates a new mock instance
func (*MockStore) EXPECT ¶
func (m *MockStore) EXPECT() *MockStoreMockRecorder
EXPECT returns an object that allows the caller to indicate expected use
func (*MockStore) ReadInflight ¶
ReadInflight mocks base method
type MockStoreMockRecorder ¶
type MockStoreMockRecorder struct {
// contains filtered or unexported fields
}
MockStoreMockRecorder is the mock recorder for MockStore
func (*MockStoreMockRecorder) Add ¶
func (mr *MockStoreMockRecorder) Add(elem interface{}) *gomock.Call
Add indicates an expected call of Add
func (*MockStoreMockRecorder) Clean ¶
func (mr *MockStoreMockRecorder) Clean() *gomock.Call
Clean indicates an expected call of Clean
func (*MockStoreMockRecorder) Close ¶
func (mr *MockStoreMockRecorder) Close() *gomock.Call
Close indicates an expected call of Close
func (*MockStoreMockRecorder) Init ¶
func (mr *MockStoreMockRecorder) Init(opts interface{}) *gomock.Call
Init indicates an expected call of Init
func (*MockStoreMockRecorder) Read ¶
func (mr *MockStoreMockRecorder) Read(pids interface{}) *gomock.Call
Read indicates an expected call of Read
func (*MockStoreMockRecorder) ReadInflight ¶
func (mr *MockStoreMockRecorder) ReadInflight(maxSize interface{}) *gomock.Call
ReadInflight indicates an expected call of ReadInflight
func (*MockStoreMockRecorder) Remove ¶
func (mr *MockStoreMockRecorder) Remove(pid interface{}) *gomock.Call
Remove indicates an expected call of Remove
func (*MockStoreMockRecorder) Replace ¶
func (mr *MockStoreMockRecorder) Replace(elem interface{}) *gomock.Call
Replace indicates an expected call of Replace
type Notifier ¶ added in v0.3.2
type Notifier interface { // NotifyDropped will be called when the element in the queue is dropped. // The err indicates the reason of why it is dropped. // The MessageWithID field in elem param can be queue.Pubrel or queue.Publish. NotifyDropped(elem *Elem, err error) NotifyInflightAdded(delta int) NotifyMsgQueueAdded(delta int) }
type Publish ¶
type Store ¶
type Store interface { // Close will be called when the client disconnect. // This method must unblock the Read method. Close() error // Init will be called when the client connect. // If opts.CleanStart set to true, the implementation should remove any associated data in backend store. // If it sets to false, the implementation should be able to retrieve the associated data from backend store. // The opts.version indicates the protocol version of the connected client, it is mainly used to calculate the publish packet size. Init(opts *InitOptions) error Clean() error // Add inserts a elem to the queue. // When the len of queue is reaching the maximum setting, the implementation should drop messages according the following priorities: // 1. Drop the expired inflight message. // 2. Drop the current elem if there is no more non-inflight messages. // 3. Drop expired non-inflight message. // 4. Drop qos0 message. // 5. Drop the front message. // See queue.mem for more details. Add(elem *Elem) error // Replace replaces the PUBLISH with the PUBREL with the same packet id. Replace(elem *Elem) (replaced bool, err error) // Read reads a batch of new message (non-inflight) from the store. The qos0 messages will be removed after read. // The size of the batch will be less than or equal to the size of the given packet id list. // The implementation must remove and do not return any : // 1. expired messages // 2. publish message which exceeds the InitOptions.ReadBytesLimit // while reading. // The caller must call ReadInflight first to read all inflight message before calling this method. // Calling this method will be blocked until there are any new messages can be read or the store has been closed. // If the store has been closed, returns nil, ErrClosed. Read(pids []packets.PacketID) ([]*Elem, error) // ReadInflight reads at most maxSize inflight messages. // The caller must call this method to read all inflight messages before calling Read method. // Returning 0 length elems means all inflight messages have been read. ReadInflight(maxSize uint) (elems []*Elem, err error) // Remove removes the elem for a given id. Remove(pid packets.PacketID) error }
Store represents a queue store for one client.