(entries []raftpb.Entry)
| 451 | } |
| 452 | |
| 453 | func (n *Node) applyEntries(entries []raftpb.Entry) { |
| 454 | if len(entries) == 0 || entries[0].Index > n.appliedIndex+1 { |
| 455 | return |
| 456 | } |
| 457 | |
| 458 | firstEntryIndex := entries[0].Index |
| 459 | // remove entries that have been applied |
| 460 | if n.appliedIndex-firstEntryIndex+1 < uint64(len(entries)) { |
| 461 | entries = entries[n.appliedIndex-firstEntryIndex+1:] |
| 462 | } |
| 463 | for _, entry := range entries { |
| 464 | if err := n.applyEntry(entry); err != nil { |
| 465 | n.logger.Error("failed to apply entry", zap.Error(err)) |
| 466 | } |
| 467 | } |
| 468 | n.appliedIndex = entries[len(entries)-1].Index |
| 469 | } |
| 470 | |
| 471 | func (n *Node) applyEntry(entry raftpb.Entry) error { |
| 472 | switch entry.Type { |
no test coverage detected