Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a per-entry custom user data field. #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yossigo
Copy link
Contributor

@yossigo yossigo commented Mar 7, 2018

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.

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.
@willemt
Copy link
Owner

willemt commented May 16, 2018

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.

@yossigo
Copy link
Contributor Author

yossigo commented May 20, 2018

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants