etcd over gossip

etcd over gossip

Strongly consistent semantics in a weakly consistent world.

Eb68eb9603a0e8822eda69e7ca721866?s=128

Peter Bourgon

May 09, 2016
Tweet

Transcript

  1. 13.

    weaveworks- Your application Router :6379 Gossip Receiver Gossip Sender Gossip

    Data GossipUnicast(dst Peer, m Msg) GossipBroadcast(m Msg) OnGossip(src Peer, m Msg) Peers() []Peer
  2. 43.

    weaveworks- type Proposer interface { ProposeEntry(Entry) error ProposeConfChange(ConfChange) error }

    type CommitReceiver interface { ReceiveCommit(Entry) } type ErrorReceiver interface { ReceiveError(error) }
  3. 44.

    weaveworks- type Proposer interface { ProposeEntry(Entry) error ProposeConfChange(ConfChange) error }

    type CommitReceiver interface { ReceiveCommit(Entry) } type ErrorReceiver interface { ReceiveError(error) } func main() { n := newRaftNode(...) s := newStore(...) a := newAPI(...) n.commitReceiver = s n.errorReceiver = s a.store = s a.proposer = n // ... }
  4. 45.

    weaveworks- type Proposer interface { ProposeEntry(Entry) error ProposeConfChange(ConfChange) error }

    type CommitReceiver interface { ReceiveCommit(Entry) } type ErrorReceiver interface { ReceiveError(error) } func main() { n := newRaftNode(...) s := newStore(...) a := newAPI(...) n.commitReceiver = s n.errorReceiver = s a.store = s a.proposer = n // ... } ✕
  5. 47.

    weaveworks- func main() { var ( entryc = make(chan entry)

    confchangec = make(chan confchange) commitc = make(chan entry) errorc = make(chan error) ) n := newRaftNode(entryc, confchangec, commitc, errorc, ...) s := newStore(commitc, ...) a := newAPI(entryc, ...) // ... }
  6. 48.

    weaveworks- type raftNode struct { node raft.Node entryc <-chan entry

    confchangec <-chan confchange commitc chan<- entry errorc chan<- error // storage? // transport? // ... quitc chan struct{} }
  7. 56.

    weaveworks- type PacketConn interface { ReadFrom(b []byte) (n int, addr

    Addr, err error) WriteTo(b []byte, addr Addr) (n int, err error) Close() error LocalAddr() Addr SetDeadline(t time.Time) error SetReadDeadline(t time.Time) error SetWriteDeadline(t time.Time) error }
  8. 57.

    weaveworks- type PacketConn interface { ReadFrom(b []byte) (n int, addr

    Addr, err error) WriteTo(b []byte, addr Addr) (n int, err error) Close() error LocalAddr() Addr SetDeadline(t time.Time) error SetReadDeadline(t time.Time) error SetWriteDeadline(t time.Time) error }
  9. 58.

    weaveworks- Router GossipUnicast(dst Peer, m Msg) GossipBroadcast(m Msg) OnGossip(src Peer,

    m Msg) Adapter? ReadFrom(b []byte) ... WriteTo(b []byte, addr Addr) ...
  10. 59.

    weaveworks- Router GossipUnicast(dst Peer, m Msg) GossipBroadcast(m Msg) OnGossip(src Peer,

    m Msg) meshconn.Peer ReadFrom(b []byte) ... WriteTo(b []byte, addr Addr) ...
  11. 60.

    weaveworks- Router GossipUnicast(dst Peer, m Msg) GossipBroadcast(m Msg) OnGossip(src Peer,

    m Msg) meshconn.Peer ReadFrom(b []byte) ... WriteTo(b []byte, addr Addr) ... incomingc chan Msg outgoingc chan Msg
  12. 61.

    weaveworks- type raftNode struct { node raft.Node entryc <-chan entry

    confchangec <-chan confchange commitc chan<- entry errorc chan<- error // storage? incoming <-chan msg // transport outgoing chan<- msg // transport // ... quitc chan struct{} }
  13. 64.

    weaveworks- for { select { case <-ticker: c.node.Tick() case r

    := <-c.node.Ready(): // save entries // send messages // publish entries // advance case <-c.quitc: return } }
  14. 65.

    weaveworks- for { select { case <-ticker: c.node.Tick() case r

    := <-c.node.Ready(): // save entries // send messages // publish entries // advance case <-c.quitc: return } }
  15. 67.
  16. 68.
  17. 69.
  18. 71.

    weaveworks- case r := <-c.node.Ready(): if !c.readySave(r) { return }

    c.readySend(r) if !c.readyApply(r) { return } c.readyAdvance()
  19. 80.

    weaveworks- type raftNode struct { node raft.Node incomingc <-chan raftpb.Message

    // from the transport unreachablec <-chan nodeID // from the transport confchangec <-chan raftpb.ConfChange // from the mesh proposalc <-chan []byte // from the state machine outgoingc chan<- raftpb.Message // to the transport entryc chan<- raftpb.Entry // to the demuxer snapshotc chan<- raftpb.Snapshot // to the state machine removedc chan<- struct{} // to calling context stopc chan struct{} // from the user terminatedc chan struct{} // to the user // storage? }
  20. 81.

    weaveworks- type raftNode struct { node raft.Node incomingc <-chan raftpb.Message

    // from the transport unreachablec <-chan nodeID // from the transport confchangec <-chan raftpb.ConfChange // from the mesh proposalc <-chan []byte // from the state machine outgoingc chan<- raftpb.Message // to the transport entryc chan<- raftpb.Entry // to the demuxer snapshotc chan<- raftpb.Snapshot // to the state machine removedc chan<- struct{} // to calling context stopc chan struct{} // from the user terminatedc chan struct{} // to the user // storage? }
  21. 82.

    weaveworks- type raftNode struct { node raft.Node incomingc <-chan raftpb.Message

    // from the transport unreachablec <-chan nodeID // from the transport confchangec <-chan raftpb.ConfChange // from the mesh proposalc <-chan []byte // from the state machine outgoingc chan<- raftpb.Message // to the transport entryc chan<- raftpb.Entry // to the demuxer snapshotc chan<- raftpb.Snapshot // to the state machine removedc chan<- struct{} // to calling context stopc chan struct{} // from the user terminatedc chan struct{} // to the user // storage? }
  22. 83.

    weaveworks- type raftNode struct { node raft.Node incomingc <-chan raftpb.Message

    // from the transport unreachablec <-chan nodeID // from the transport confchangec <-chan raftpb.ConfChange // from the mesh proposalc <-chan []byte // from the state machine outgoingc chan<- raftpb.Message // to the transport entryc chan<- raftpb.Entry // to the demuxer snapshotc chan<- raftpb.Snapshot // to the state machine removedc chan<- struct{} // to calling context stopc chan struct{} // from the user terminatedc chan struct{} // to the user // storage? }
  23. 92.

    weaveworks- Transport Router meshconn Controller incomingc outgoingc raft.Node Step ProposeConfChange

    entryc Demuxer Normal entries ConfChange entries unreachablec ReportUnreachable confchangec
  24. 93.

    weaveworks- Transport Router meshconn Controller incomingc outgoingc raft.Node Step ProposeConfChange

    entryc Demuxer Normal entries ConfChange entries unreachablec ReportUnreachable confchangec
  25. 94.

    weaveworks- Transport Router Membership meshconn Controller incomingc outgoingc raft.Node Step

    ProposeConfChange entryc Demuxer Normal entries ConfChange entries unreachablec confchangec ReportUnreachable
  26. 95.

    weaveworks- Transport Router Membership meshconn Controller State incomingc outgoingc raft.Node

    Step ProposeConfChange entryc Demuxer Normal entries ConfChange entries unreachablec confchangec ReportUnreachable
  27. 96.

    weaveworks- Transport Router Membership meshconn Controller State incomingc outgoingc raft.Node

    Step ProposeConfChange snapshotc entryc Demuxer Normal entries ConfChange entries unreachablec confchangec ReportUnreachable
  28. 97.

    weaveworks- Transport Router Membership meshconn Controller State incomingc outgoingc raft.Node

    Step ProposeConfChange ProposeEntry proposalc snapshotc entryc Demuxer Normal entries ConfChange entries unreachablec confchangec ReportUnreachable
  29. 99.

    weaveworks- Transport Router Membership meshconn Controller State incomingc outgoingc raft.Node

    Step ProposeConfChange ProposeEntry proposalc snapshotc entryc Demuxer Normal entries ConfChange entries unreachablec confchangec ReportUnreachable
  30. 100.

    weaveworks- type raftNode struct { node raft.Node incomingc <-chan raftpb.Message

    // from the transport unreachablec <-chan nodeID // from the transport confchangec <-chan raftpb.ConfChange // from the mesh proposalc <-chan []byte // from the state machine outgoingc chan<- raftpb.Message // to the transport entryc chan<- raftpb.Entry // to the demuxer snapshotc chan<- raftpb.Snapshot // to the state machine removedc chan<- struct{} // to calling context stopc chan struct{} // from the user terminatedc chan struct{} // to the user // storage? }
  31. 101.

    weaveworks- Transport Router Membership meshconn Controller State incomingc outgoingc raft.Node

    Step ProposeConfChange ProposeEntry proposalc snapshotc entryc Demuxer Normal entries ConfChange entries unreachablec confchangec ReportUnreachable
  32. 112.

    weaveworks- Transport Router Membership meshconn Controller State incomingc outgoingc raft.Node

    Step ProposeConfChange ProposeEntry proposalc snapshotc entryc Demuxer Normal entries ConfChange entries unreachablec confchangec ReportUnreachable
  33. 123.

    weaveworks- Transport Router Membership meshconn Controller State incomingc outgoingc raft.Node

    Step ProposeConfChange ProposeEntry proposalc snapshotc entryc Demuxer Normal entries ConfChange entries unreachablec confchangec ReportUnreachable
  34. 124.

    weaveworks- Transport Router Membership meshconn Controller State incomingc outgoingc raft.Node

    Step ProposeConfChange ProposeEntry proposalc snapshotc entryc Demuxer Normal entries ConfChange entries unreachablec confchangec ReportUnreachable