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

Move check on zero workers from client constructor to Start #88

Merged
merged 1 commit into from
Dec 2, 2023

Conversation

brandur
Copy link
Contributor

@brandur brandur commented Dec 2, 2023

This one's in pursuit of trying to solve #87, where it's difficult to
inject a River client into a worker because trying to initialize a
client with the workers bundle empty is an error, creating a chicken and
egg problem.

There's no real reason to disallow a zero worker bundle from the
constructor, and in fact a lot of our tests already add additional
workers after the client was originally initialized (although
newTestClient injects a default worker, which is why there's no
error). If it's a useful pattern for us, it's probably useful for other
users too.

Here, move the zero workers check from the constructor over to the
Start function instead. While it seems okay to initialize a client
without workers, starting it without any does seem like a potential
problem that we'd want to keep an eye out for.

Fixes #87.

This one's in pursuit of trying to solve #87, where it's difficult to
inject a River client into a worker because trying to initialize a
client with the workers bundle empty is an error, creating a chicken and
egg problem.

There's no real reason to disallow a zero worker bundle from the
constructor, and in fact a lot of our tests already add additional
workers after the client was originally initialized (although
`newTestClient` injects a default worker, which is why there's no
error). If it's a useful pattern for us, it's probably useful for other
users too.

Here, move the zero workers check from the constructor over to the
`Start` function instead. While it seems okay to initialize a client
without workers, starting it without any does seem like a potential
problem that we'd want to keep an eye out for.

Fixes #87.
@brandur brandur force-pushed the brandur-move-zero-workers-check-to-start branch from 015ee53 to 89fa9f3 Compare December 2, 2023 19:29
@brandur
Copy link
Contributor Author

brandur commented Dec 2, 2023

Thanks! Also added a changelog.

@brandur brandur merged commit e0a99d0 into master Dec 2, 2023
7 checks passed
@brandur brandur deleted the brandur-move-zero-workers-check-to-start branch December 2, 2023 19:46
@dhermes
Copy link
Contributor

dhermes commented Dec 13, 2023

Awesome change, thanks!

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.

Passing a riverClient to a worker?
3 participants