MCPcopy Create free account
hub / github.com/deventlab/d-engine / insert_raft_log

Function insert_raft_log

d-engine-server/src/test_utils/integration/mod.rs:286–303  ·  view source on GitHub ↗
(
    raft_log: &Arc<ROF<RaftTypeConfig<FileStorageEngine, FileStateMachine>>>,
    ids: Vec<u64>,
    term: u64,
)

Source from the content-addressed store, hash-verified

284/// Panics if the batch insert operation fails.
285#[allow(dead_code)]
286pub(crate) async fn insert_raft_log(
287 raft_log: &Arc<ROF<RaftTypeConfig<FileStorageEngine, FileStateMachine>>>,
288 ids: Vec<u64>,
289 term: u64,
290) {
291 let mut entries = Vec::new();
292 for id in ids {
293 let log = Entry {
294 index: raft_log.pre_allocate_raft_logs_next_index(),
295 term,
296 payload: Some(EntryPayload::command(generate_insert_commands(vec![id]))),
297 };
298 entries.push(log);
299 }
300 if let Err(e) = raft_log.insert_batch(entries).await {
301 panic!("error:{e:?}");
302 }
303}
304
305/// Applies entries to the state machine with specified IDs and term.
306///

Callers 1

Calls 4

generate_insert_commandsFunction · 0.50
pushMethod · 0.45
insert_batchMethod · 0.45

Tested by 1