Repository: etcd-io/etcd
File: server/etcdserver/server.go (Go)

Code before:
	// to re-bootstrap Appliers.
	s.uberApply = s.NewUberApplier()
}

func (s *EtcdServer) NewUberApplier() apply.UberApplier {
	opts := apply.ApplierOptions{
		Logger:                       s.lg,
		KV:                           s.KV(),
		AlarmStore:                   s.alarmStore,
		AuthStore:                    s.authStore,
		Lessor:                       s.lessor,
		Cluster:                      s.cluster,
		RaftStatus:                   s,
		SnapshotServer:               s,
		ConsistentIndex:              s.consistIndex,
		TxnModeWriteWithSharedBuffer: s.Cfg.ServerFeatureGate.Enabled(features.TxnModeWriteWithSharedBuffer),
		Backend:                      s.be,
		QuotaBackendBytesCfg:         s.Cfg.QuotaBackendBytes,
		WarningApplyDuration:         s.Cfg.WarningApplyDuration,
	}
	return apply.NewUberApplier(opts)
}

func verifySnapshotIndex(snapshot raftpb.Snapshot, cindex uint64) {
	verify.VerifyPrototype(func() (bool, string, map[string]any) {
		return cindex != snapshot.Metadata.Index, fmt.Sprintf("consistent_index(%d) isn't equal to snapshot index (%d)", cindex, snapshot.Metadata.Index), nil
	})
}

func verifyConsistentIndexIsLatest(lg *zap.Logger, snapshot raftpb.Snapshot, cindex uint64) {
	verify.Verify(func() {
		if cindex < snapshot.Metadata.Index {
			lg.Panic(fmt.Sprintf("consistent_index(%d) is older than snapshot index (%d)", cindex, snapshot.Metadata.Index))
		}
	})
}

func (s *EtcdServer) applyEntries(ep *etcdProgress, apply *toApply) {
	if len(apply.entries) == 0 {
		return
	}
	firsti := apply.entries[0].Index
	if firsti > ep.appliedi+1 {
		lg := s.Logger()
		lg.Panic(
			"unexpected committed entry index",
			zap.Uint64("current-applied-index", ep.appliedi),
			zap.Uint64("first-committed-entry-index", firsti),
		)
	}
	var ents []raftpb.Entry

Review comment (suggestion):
I'm thinking that it would be easier to use static string and only allow passing dynamic values via details.

Code after:
	// to re-bootstrap Appliers.
	s.uberApply = s.NewUberApplier()
}

func (s *EtcdServer) NewUberApplier() apply.UberApplier {
	opts := apply.ApplierOptions{
		Logger:                       s.lg,
		KV:                           s.KV(),
		AlarmStore:                   s.alarmStore,
		AuthStore:                    s.authStore,
		Lessor:                       s.lessor,
		Cluster:                      s.cluster,
		RaftStatus:                   s,
		SnapshotServer:               s,
		ConsistentIndex:              s.consistIndex,
		TxnModeWriteWithSharedBuffer: s.Cfg.ServerFeatureGate.Enabled(features.TxnModeWriteWithSharedBuffer),
		Backend:                      s.be,
		QuotaBackendBytesCfg:         s.Cfg.QuotaBackendBytes,
		WarningApplyDuration:         s.Cfg.WarningApplyDuration,
	}
	return apply.NewUberApplier(opts)
}

func verifySnapshotIndex(snapshot raftpb.Snapshot, cindex uint64) {
	verify.Verify("consistent_index isn't equal to snapshot index", func() (bool, map[string]any) {
		return cindex == snapshot.Metadata.Index,
			map[string]any{
				"consistent_index": cindex,
				"snapshot_index":   snapshot.Metadata.Index,
			}
	})
}

func verifyConsistentIndexIsLatest(snapshot raftpb.Snapshot, cindex uint64) {
	verify.Verify("consistent_index is older than snapshot_index", func() (bool, map[string]any) {
		return cindex >= snapshot.Metadata.Index,
			map[string]any{
				"consistent_index": cindex,
				"snapshot_index":   snapshot.Metadata.Index,
			}
	})
}

func (s *EtcdServer) applyEntries(ep *etcdProgress, apply *toApply) {
	if len(apply.entries) == 0 {
		return
	}
	firsti := apply.entries[0].Index
	if firsti > ep.appliedi+1 {
		lg := s.Logger()
		lg.Panic(