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

Conditionally initalise worker state #2

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

Conversation

ktec
Copy link
Owner

@ktec ktec commented Jan 29, 2020

This commit updates the Worker GenServer so that the
handle_continue/2 callback is only invoked when the service is set to
DefaultService.

This module already knows about DefaultService so this seems slightly
better than pattern matching on MockService, however if there are
alternative "production" services, other than DefaultService the
Worker.init/1 would need to change.

Because we are unable to call handle_continue/2 directly from the
worker_test.ex we need to add initialise_foo/0 which finds the pid
and sends the :initialise_foo message. This same message is also used
in the handle_continue/2 callback.

The tests can be run using:

mix test

@ktec ktec force-pushed the ks/conditional_startup branch from 145af2e to 42fda99 Compare January 29, 2020 12:24
@ktec ktec force-pushed the ks/conditional_startup branch 2 times, most recently from 8d6f282 to e750aa3 Compare January 29, 2020 13:21
This commit updates the `Worker` `GenServer` so that the
`handle_continue/2` callback is only invoked when the service is set to
`DefaultService`.

This module already knows about `DefaultService` so this seems slightly
better than pattern matching on `MockService`, however if there are
alternative "production" services, other than `DefaultService` the
`Worker.init/1` would need to change.

Because we are unable to call `handle_continue/2` directly from the
`worker_test.ex` we need to add `initialise_foo/0` which finds the pid
and sends the `:initialise_foo` message. This same message is also used
in the `handle_continue/2` callback.

The tests can be run using:

```
mix test
```
@ktec ktec force-pushed the ks/conditional_startup branch from e750aa3 to 2a44fea Compare January 29, 2020 21:16
@ktec ktec self-assigned this Feb 9, 2020
@ktec ktec changed the title Conditionally initalise Worker state Conditionally initalise worker state Feb 9, 2020
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.

1 participant