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

Provide a way to access workers in hooks #20

Merged
merged 1 commit into from
Apr 20, 2016
Merged

Provide a way to access workers in hooks #20

merged 1 commit into from
Apr 20, 2016

Conversation

whitfin
Copy link
Owner

@whitfin whitfin commented Apr 20, 2016

This will fix #1. It's just a starting point, but I think this should be sufficient going forward.

This PR adds a :provide option to all hooks, allowing you to ask for various things to be provided to the hook (although currently it's just :worker). This will then call handle_info/2 in the hook with a { :provision, { :worker, worker } } message and allow you to bind the worker to your state.

You can then pass this worker to Cachex (i.e. Cachex.get(worker, "key")) for cache access within the hooks without jumping back over the proc barrier to the worker server.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 1e95b59 on issue-1 into 6b8f55d on master.

@whitfin whitfin merged commit 29dd55d into master Apr 20, 2016
@whitfin whitfin deleted the issue-1 branch April 20, 2016 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hooks should be provided access to the Worker state
2 participants