raft
raft copied to clipboard
Add a per-entry custom user data field.
This is useful to allow leaders to pass context between raft_recv_entry() and a subsequent execution of the entry (after it was committed) as an applylog callback.
This allows an optimized use pattern when entries received locally on the leader can be used without going through an unnecessary deserialization.
Do you think you can achieve this with this? https://github.com/clibs/container_of
For Raft's 1.0 release, I have some intentions to remove all user data passing in favour of container_of
. So I'm a little hesitant to add more user data passing.
Need to take a closer look but from what I remember it's not going to work, because the log entry is copied so "container of" struct won't be found where one expects it to be.
By the way, why do you want to use this approach? To me it seems like an extremely dangerous approach that may be a good last resort hack, to work around poorly written code that doesn't provide an explicit user data hook. Besides defeating all compile time type checking the compiler offers, it makes it so easy to create really hard to find bugs...