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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//! API to consume a response when a client write request is completed.
pub
pub
pub use OneshotResponder;
pub use ProgressResponder;
use since;
use crateOptionalSend;
use crateRaftTypeConfig;
use crateLogIdOf;
/// A trait that lets `RaftCore` send a result back to the client or to somewhere else.
///
/// This is a generic abstraction for sending results of any type `T`.
/// Usually an implementation of [`Responder`] is a oneshot channel Sender.
///
/// ## Lifecycle Callbacks
///
/// - [`on_commit()`](Self::on_commit) is called when the entry is locally committed. Implementing
/// this callback is optional, and receiving it does not guarantee a later completion callback.
/// - [`on_complete()`](Self::on_complete) delivers the result after the state machine applies the
/// entry, or an error if the request is rejected. Rejection can happen without a commit callback.
///
/// The responder can be dropped without a result, before or after the commit callback. This can
/// happen during shutdown or after a fatal error, but work already handed off to the state machine
/// may still complete after the Raft core shuts down. Custom implementations should release or
/// notify any waiter when dropped, for example by owning a channel sender whose drop closes the
/// channel.
///
/// # Type Parameters
///
/// - `T`: The type of value to send through this responder