odo-journal
v1.9.2
Published
Distributed, p2p, append-only event streaming journal
Downloads
22
Readme
Odo Journal
Distributed, p2p, append-only event streaming journal
Todo
- [ ] Upgrade to promises
- [ ] Peers of current journal become out of date
Relies on leveldown style storage
Generate self signed key
openssl genrsa -out key.pem 4096 openssl req -new -key key.pem -out csr.pem openssl x509 -req -days 365 -in csr.pem -signkey key.pem -out cert.pem
Discovery States
- Outgoing
- Incoming
- Active (heartbeat)
- Lifesupport (needs prooving)
Discovery
- Peers discovered through DNS and DHT that do not match an existing known peer's host and port have their state set to 'connecting' and a connection attempt is started.
- A connection attempt starts with a TLS socket connection and is followed by introductions which includes asking for the peer's id.
- If an attempted connection has a timeout or another error occurs the connection is closed and the peer's state is set to lifesupport.
- If during introductions the peer's id matches an existing peer or the same id as the initiating peer the connection is closed and the peer's state is set to purgatory with an appropriate reason.
- If everything goes well the peer's state is set to active and the peer becomes available for communication. The host, port and id are saved to peer history.
- A heartbeat is sent to all peers in active state that have had no recent activity for a set amount of time.
- If a peer has a communication failure or misses a heartbeat the connection is closed and the peer's state is set to lifesupport.
- Using an exponential backoff timeout peers in lifesupport state have their state set to 'connecting' and a connection attempt is started.
- After a set timeout peers in purgatory state are deleted.
Synchronisation
- Peers exchange their catalogue of device ids and revisions, including if they are the source of device id or are subscribed to the source
- A peer requests a catchup by providing device ids and last known revisions
- The server streams as separate payloads the the latest snapshot for each id and all events since
- A peer requests to be subscribed to any new event for a device id by providing a last known revision
- The server remembers subscriptions and will catch up subscribers to the latest revision before streaming any new events live
- Any issue or lost connection will drop the state back to step 1
- After set interval or event count a snapshot of the data is built and saved
- After an interval or event count all events before a set snapshot are deleted