func (rb *raftBackend) procesReady(rd raft.Ready) bool {
	rb.logger.Debugf("ID: %d %x Hardstate: %v Entries: %v Snapshot: %v Messages: %v Committed: %v ConfState: %s", rb.raftId, rb.raftId, rd.HardState, rd.Entries, rd.Snapshot, rd.Messages, rd.CommittedEntries, rb.confState.String())
	rb.store.saveEntriesAndState(rd.Entries, rd.HardState)

	if !raft.IsEmptySnap(rd.Snapshot) {
		if err := rb.store.saveSnap(rd.Snapshot); err != nil {
			rb.logger.Errorf("Couldn't save snapshot: %s", err.Error())
			return false
		}

		rb.publishSnapshot(rd.Snapshot)
	}

	sendingErrors := rb.transport.sendMessages(rd.Messages)
	if sendingErrors != nil {
		for _, failedMsg := range sendingErrors.failedMessages {
			// TODO - think this through
			// rb.logger.Errorf("Reporting raft [%d %x] unreachable", failedMsg.To, failedMsg.To)
			// rb.raftNode.ReportUnreachable(failedMsg.To)
			if isMsgSnap(failedMsg) {
				rb.logger.Errorf("Reporting snapshot failure for raft [%d %x]", failedMsg.To, failedMsg.To)
				rb.raftNode.ReportSnapshot(failedMsg.To, raft.SnapshotFailure)
			}
		}

		for _, snapMsg := range sendingErrors.succeededSnapshotMessages {
			rb.raftNode.ReportSnapshot(snapMsg.To, raft.SnapshotFinish)
		}
	}

	if ok := rb.publishEntries(rb.entriesToApply(rd.CommittedEntries)); !ok {
		return false
	}
	rb.maybeTriggerSnapshot()
	rb.raftNode.Advance()
	return true
}
// Store raft entries and hard state, then publish changes over commit channel.
// Returning false will stop the raft state machine!
Store raft entries and hard state, then publish changes over commit channel.
Returning false will stop the raft state machine!
// Store raft entries and hard state then publish changes over commit channel . // Returning false will stop the raft state machine!
func (rb *raftBackend) procesReady(rd raft.Ready) bool {
	rb.logger.Debugf("ID: %d %x Hardstate: %v Entries: %v Snapshot: %v Messages: %v Committed: %v ConfState: %s", rb.raftId, rb.raftId, rd.HardState, rd.Entries, rd.Snapshot, rd.Messages, rd.CommittedEntries, rb.confState.String())
	rb.store.saveEntriesAndState(rd.Entries, rd.HardState)
	if !raft.IsEmptySnap(rd.Snapshot) {
		if err := rb.store.saveSnap(rd.Snapshot); err != nil {
			rb.logger.Errorf("Couldn't save snapshot: %s", err.Error())
			return false
		}
		rb.publishSnapshot(rd.Snapshot)
	}
	sendingErrors := rb.transport.sendMessages(rd.Messages)
	if sendingErrors != nil {
		for _, failedMsg := range sendingErrors.failedMessages {
			if isMsgSnap(failedMsg) {
				rb.logger.Errorf("Reporting snapshot failure for raft [%d %x]", failedMsg.To, failedMsg.To)
				rb.raftNode.ReportSnapshot(failedMsg.To, raft.SnapshotFailure)
			}
		}
		for _, snapMsg := range sendingErrors.succeededSnapshotMessages {
			rb.raftNode.ReportSnapshot(snapMsg.To, raft.SnapshotFinish)
		}
	}
	if ok := rb.publishEntries(rb.entriesToApply(rd.CommittedEntries)); !ok {
		return false
	}
	rb.maybeTriggerSnapshot()
	rb.raftNode.Advance()
	return true
}
func ( rb * raftBackend ) procesReady ( rd raft . Ready ) bool { rb . logger . Debugf ( " " , rb . raftId , rb . raftId , rd . HardState , rd . Entries , rd . Snapshot , rd . Messages , rd . CommittedEntries , rb . confState . String ( ) ) rb . store . saveEntriesAndState ( rd . Entries , rd . HardState ) if ! raft . IsEmptySnap ( rd . Snapshot ) { if err := rb . store . saveSnap ( rd . Snapshot ) ; err != nil { rb . logger . Errorf ( " " , err . Error ( ) ) return false } rb . publishSnapshot ( rd . Snapshot ) } sendingErrors := rb . transport . sendMessages ( rd . Messages ) if sendingErrors != nil { for _ , failedMsg := range sendingErrors . failedMessages { if isMsgSnap ( failedMsg ) { rb . logger . Errorf ( " " , failedMsg . To , failedMsg . To ) rb . raftNode . ReportSnapshot ( failedMsg . To , raft . SnapshotFailure ) } } for _ , snapMsg := range sendingErrors . succeededSnapshotMessages { rb . raftNode . ReportSnapshot ( snapMsg . To , raft . SnapshotFinish ) } } if ok := rb . publishEntries ( rb . entriesToApply ( rd . CommittedEntries ) ) ; ! ok { return false } rb . maybeTriggerSnapshot ( ) rb . raftNode . Advance ( ) return true }
Store raft entries and hard state, then publish changes over commit channel.
Store raft entries and hard state then publish changes over commit channel .
// TODO - think this through // rb.logger.Errorf("Reporting raft [%d %x] unreachable", failedMsg.To, failedMsg.To) // rb.raftNode.ReportUnreachable(failedMsg.To)