Skip to content

Commit 8857bcd

Browse files
authored
Refactor callback documentation (#139)
Refactor callback comments. - Regroup related callbacks. - Move optional callbacks to the bottom and indicate "(optional)".
1 parent 9f2205f commit 8857bcd

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

include/raft.h

+14-12
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,9 @@ typedef struct
665665
/** Callback for sending snapshot messages */
666666
raft_send_snapshot_f send_snapshot;
667667

668+
/** Callback for sending timeoutnow message */
669+
raft_send_timeoutnow_f send_timeoutnow;
670+
668671
/** Callback for loading snapshot. This will be called when we complete
669672
* receiving snapshot from the leader */
670673
raft_load_snapshot_f load_snapshot;
@@ -697,30 +700,29 @@ typedef struct
697700
/** Callback for detecting when a non-voting node has sufficient logs. */
698701
raft_node_has_sufficient_logs_f node_has_sufficient_logs;
699702

700-
/** Callback for being notified of membership changes (optional). */
703+
/** Callback to retrieve monotonic timestamp in microseconds */
704+
raft_timestamp_f timestamp;
705+
706+
/** (optional) Callback for being notified of membership changes. */
701707
raft_membership_event_f notify_membership_event;
702708

703-
/** Callback for being notified of state changes (optional). */
709+
/** (optional) Callback for being notified of state changes. */
704710
raft_state_event_f notify_state_event;
705711

706-
/** Callbakc for notified of transfer leadership events (optional) */
712+
/** (optional) Callback for being notified of transfer leadership events. */
707713
raft_transfer_event_f notify_transfer_event;
708714

709-
/** Callback for catching debugging log messages
710-
* This callback is optional */
715+
/** (optional) Callback for catching debugging log messages. */
711716
raft_log_f log;
712717

713-
/** Callback for sending TimeoutNow RPC messages to nodes */
714-
raft_send_timeoutnow_f send_timeoutnow;
715-
716-
/** Callback for deciding whether to send raft_appendentries_req to a node. */
718+
/** (optional) Callback for deciding whether to send raft_appendentries_req
719+
* to a node. */
717720
raft_backpressure_f backpressure;
718721

719-
/** Callback for preparing entries to send in a raft_appendentries_req */
722+
/** (optional) Callback for preparing entries to send in
723+
* a raft_appendentries_req. */
720724
raft_get_entries_to_send_f get_entries_to_send;
721725

722-
/** Callback to retrieve monotonic timestamp in microseconds */
723-
raft_timestamp_f timestamp;
724726
} raft_cbs_t;
725727

726728
/** A callback used to notify when queued read requests can be processed.

0 commit comments

Comments
 (0)