Example #1
0
func (cr *connectionReader) read() {
	defer cr.terminated.Done()
	for {
		select {
		case <-cr.terminate:
			return
		default:
			if seg, err := cr.readAndDecryptOne(); err == nil {
				msg := msgs.ReadRootMessage(seg)
				if !cr.enqueueQuery((*connectionReadMessage)(&msg)) {
					return
				}
			} else {
				cr.enqueueQuery(&connectionReadError{err})
				return
			}
		}
	}
}
Example #2
0
// paxos.Connection interface to allow sending to ourself.
func (cm *ConnectionManager) Send(b []byte) {
	seg, _, err := capn.ReadFromMemoryZeroCopy(b)
	server.CheckFatal(err)
	msg := msgs.ReadRootMessage(seg)
	cm.Dispatchers.DispatchMessage(cm.RMId, msg.Which(), &msg)
}