| 1 |
store |
| 2 |
===== |
| 3 |
|
| 4 |
Contains implementations of `session.storer`. These are used to store session states; that is store packets, |
| 5 |
packets indexed by a uint32, with the ability to retrieve in the order written. |
| 6 |
|
| 7 |
The MQTT client will open two stores; one for PUBLISH packets (and related acknowledgements) originating from the server |
| 8 |
(i.e. the packet identifier was assigned by the server) and the other for messages originating on the client |
| 9 |
(these may well share the same basic backend). |
| 10 |
|
| 11 |
as per section 4.1 in the spec; The Session State in the Client consists of: |
| 12 |
> · QoS 1 and QoS 2 messages which have been sent to the Server, but have not been completely acknowledged. |
| 13 |
> · QoS 2 messages which have been received from the Server, but have not been completely acknowledged. |
| 14 |
|
| 15 |
This means that we only need to store PUBLISH (QOS1+) related outbound packets (if we have not responded, the packet |
| 16 |
will be resent). So the only things needed are: |
| 17 |
`PUBLISH` - This is the only situation where the message body is needed (so we can resend it). |
| 18 |
`PUBREC` - response to inbound PUBLISH. The only packet originating on the server that will be stored. |
| 19 |
`PUBREL` - relating to a PUBLISH we initiated |
| 20 |
We do need to store the entire packet because, when resending it, this should include any properties. |
| 21 |
|
| 22 |
The vast majority of operations will be writes. The only time data should be read is: |
| 23 |
* At startup an inventory of packets held will be needed (need to know which identifiers are allocated) |
| 24 |
* When connection is established, we load the packets, so they can be retransmitted |
| 25 |
|
| 26 |
Design goals: |
| 27 |
- Simplicity |
| 28 |
- Store agnostic (allow for memory, disk files, database, REDIS etc) |
| 29 |
- Minimise data transfers (only read when data is needed) |
| 30 |
- Allow for properties (we use `packets.ControlPacket` so that a whole packet is stored; when resending we |
| 31 |
need to include properties etc). |