Commit 66a1f846 authored by Willem Thiart's avatar Willem Thiart
Browse files

Add entry index to applylog callback

parent 2e2c15ea
...@@ -214,19 +214,6 @@ typedef void ( ...@@ -214,19 +214,6 @@ typedef void (
); );
#endif #endif
/** Callback for applying this log entry to the state machine.
* @param[in] raft The Raft server making this callback
* @param[in] user_data User data that is passed from Raft server
* @param[in] ety Log entry to be applied
* @return 0 on success */
typedef int (
*func_applylog_f
) (
raft_server_t* raft,
void *user_data,
raft_entry_t* ety
);
/** Callback for saving who we voted for to disk. /** Callback for saving who we voted for to disk.
* For safety reasons this callback MUST flush the change to disk. * For safety reasons this callback MUST flush the change to disk.
* @param[in] raft The Raft server making this callback * @param[in] raft The Raft server making this callback
...@@ -245,9 +232,10 @@ typedef int ( ...@@ -245,9 +232,10 @@ typedef int (
* *
* This callback is used for: * This callback is used for:
* <ul> * <ul>
* <li>Adding entries to the log (ie. offer) * <li>Adding entries to the log (ie. offer)</li>
* <li>Removing the first entry from the log (ie. polling) * <li>Removing the first entry from the log (ie. polling)</li>
* <li>Removing the last entry from the log (ie. popping) * <li>Removing the last entry from the log (ie. popping)</li>
* <li>Applying entries</li>
* </ul> * </ul>
* *
* For safety reasons this callback MUST flush the change to disk. * For safety reasons this callback MUST flush the change to disk.
...@@ -255,8 +243,9 @@ typedef int ( ...@@ -255,8 +243,9 @@ typedef int (
* @param[in] raft The Raft server making this callback * @param[in] raft The Raft server making this callback
* @param[in] user_data User data that is passed from Raft server * @param[in] user_data User data that is passed from Raft server
* @param[in] entry The entry that the event is happening to. * @param[in] entry The entry that the event is happening to.
* The user is allowed to change the memory pointed to in the * For offering, polling, and popping, the user is allowed to change the
* raft_entry_data_t struct. This MUST be done if the memory is temporary. * memory pointed to in the raft_entry_data_t struct. This MUST be done if
* the memory is temporary.
* @param[in] entry_idx The entries index in the log * @param[in] entry_idx The entries index in the log
* @return 0 on success */ * @return 0 on success */
typedef int ( typedef int (
...@@ -279,7 +268,7 @@ typedef struct ...@@ -279,7 +268,7 @@ typedef struct
/** Callback for finite state machine application /** Callback for finite state machine application
* Return 0 on success. * Return 0 on success.
* Return RAFT_ERR_SHUTDOWN if you want the server to shutdown. */ * Return RAFT_ERR_SHUTDOWN if you want the server to shutdown. */
func_applylog_f applylog; func_logentry_event_f applylog;
/** Callback for persisting vote data /** Callback for persisting vote data
* For safety reasons this callback MUST flush the change to disk. */ * For safety reasons this callback MUST flush the change to disk. */
......
...@@ -659,7 +659,7 @@ int raft_apply_entry(raft_server_t* me_) ...@@ -659,7 +659,7 @@ int raft_apply_entry(raft_server_t* me_)
me->last_applied_idx++; me->last_applied_idx++;
if (me->cb.applylog) if (me->cb.applylog)
{ {
int e = me->cb.applylog(me_, me->udata, ety); int e = me->cb.applylog(me_, me->udata, ety, me->last_applied_idx - 1);
if (RAFT_ERR_SHUTDOWN == e) if (RAFT_ERR_SHUTDOWN == e)
return RAFT_ERR_SHUTDOWN; return RAFT_ERR_SHUTDOWN;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment