1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use crate::storage::kv::WriteData;
use crate::storage::lock_manager::LockManager;
use crate::storage::txn::commands::{
Command, CommandExt, ResponsePolicy, TypedCommand, WriteCommand, WriteContext, WriteResult,
};
use crate::storage::txn::Result;
use crate::storage::{ProcessResult, Snapshot};
use std::thread;
use std::time::Duration;
use txn_types::Key;
command! {
Pause:
cmd_ty => (),
display => "kv::command::pause keys:({}) {} ms | {:?}", (keys.len, duration, ctx),
content => {
keys: Vec<Key>,
duration: u64,
}
}
impl CommandExt for Pause {
ctx!();
tag!(pause);
write_bytes!(keys: multiple);
gen_lock!(keys: multiple);
}
impl<S: Snapshot, L: LockManager> WriteCommand<S, L> for Pause {
fn process_write(self, _snapshot: S, _context: WriteContext<'_, L>) -> Result<WriteResult> {
thread::sleep(Duration::from_millis(self.duration));
Ok(WriteResult {
ctx: self.ctx,
to_be_write: WriteData::default(),
rows: 0,
pr: ProcessResult::Res,
lock_info: None,
lock_guards: vec![],
response_policy: ResponsePolicy::OnApplied,
})
}
}