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

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