-
Notifications
You must be signed in to change notification settings - Fork 0
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
Simplify worker runner #16
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16 +/- ##
==========================================
+ Coverage 29.31% 32.27% +2.96%
==========================================
Files 6 6
Lines 174 158 -16
==========================================
Hits 51 51
+ Misses 118 102 -16
Partials 5 5 ☔ View full report in Codecov by Sentry. |
Use `temporalsdk_worker.Run()` blocking call with a system interrupt listening channel to simplify the `workercmd` and `main` (cli) code. [skip-codecov]
d70dd61
to
36b74d9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note that the current model is designed to make Run
non-blocking to facilitate the addition of future tasks that we will have to execute in parallel, like a health check API, a pprof server, etc (inspired by wtfd).
If Run
were to become a blocking function managing multiple tasks we would need to adapt it to synchronize multiple goroutines, e.g. legacy enduro uses github.com/oklog/run
specifically for that, but at the end of the day I think we would end up with the same type of complexity just handled elsewhere. IMO the complexity is justified unless you're rather get rid of it until strictly necessary.
@sevein the context for this change is I'm trying to get the project test coverage above the sad ~49% mark where it's currently sitting on main (https://app.codecov.io/gh/artefactual-sdps/preprocessing-moma/commit/cc1b1bb85831b1e6ad1d537673aba249adb7797c). There are two files that are currently at zero coverage, which are dragging the average coverage way down:
Between the two of them they contribute 66 of 82 (80%) of the missed lines in the project. I've managed to add a bit of test coverage to "version.go" in PR #15, but a lot of the magic Which brings me to "cmd/main.go". I did a fair bit of Googling today on how to test a Go So this PR was a first attempt at reducing the complexity of
I'm open to the fact that we may want to run other goroutines when we start the worker, though in general I don't like the pattern in enduro-sdps of starting multiple services from one entry point. In any case, we aren't starting any other parallel tasks in the worker right now, so why include the extra complexity in the code? If we do want to start other services when we start the worker, I think it would be better to do that in |
@sevein all that said, this PR broke the integration test, so I need to rethink it anyway. 🤔 |
Thank you for the added context. Maybe in a larger codebase (we're tracking 174 lines of code today), a 44-line main function wouldn't be such a big deal, but I'm supportive with adopting a new pattern with a thinner main too if we want to go down that route. There are really cool examples out there, from cockroach's 1-line main() to something like tailscaled that seems to deal mostly with arguments and env strings. I recommend reevaluating the decision to omit passing the context from I agree that enduro-sdps needs to be fixed, that I believe was the result of forking old legacy-enduro code. However the claim "we can't test main()" is oudated since go1.20 added support for building coverage-instrumented binaries ( |
@sevein thank you for your thoughtful feedback, and for all the great links to |
This PR needs a significant rework so I'm going to close it, and come back to it later if time permits. |
Use
temporalsdk_worker.Run()
blocking call with a system interrupt listening channel to simplify theworkercmd
andmain
(cli) code.