faktory-rs icon indicating copy to clipboard operation
faktory-rs copied to clipboard

Handle SIGTERM and singals from userland

Open rustworthy opened this issue 11 months ago • 2 comments

As per #4

The development branch is the clone of the feat/async-support. The latter is in my fork of the repo and is destined for main in #49. I will now start creating feature branches in the main repo.

This PR is also adding:

  • tracing dep and and a couple of events (heartbeat at trace level, sigterm at info level);
  • examples;

This change is Reviewable

rustworthy avatar Mar 21 '24 07:03 rustworthy

Codecov Report

Attention: Patch coverage is 93.75000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 69.5%. Comparing base (5c0ff09) to head (6eb5b17).

Additional details and impacted files
Files Coverage Δ
src/worker/health.rs 88.6% <ø> (+11.3%) :arrow_up:
src/worker/builder.rs 98.9% <95.2%> (-1.1%) :arrow_down:
src/worker/mod.rs 83.3% <97.1%> (+2.1%) :arrow_up:
src/worker/stop.rs 75.0% <75.0%> (ø)

... and 3 files with indirect coverage changes

codecov[bot] avatar Apr 09 '24 19:04 codecov[bot]

just fyi, I've seen this, but am holding off on reviewing until we get #49 over the finish line.

jonhoo avatar Apr 27 '24 16:04 jonhoo

I'd prefer that we don't put signal handling directly into this library, and instead do something like what axum does and allow the user to supply a shutdown future.

jonhoo avatar May 19 '24 14:05 jonhoo

Also, would you mind doing the examples and tracing in a separate PR just to make it easier to review and land this piecemeal?

jonhoo avatar May 19 '24 14:05 jonhoo

Also, would you mind doing the examples and tracing in a separate PR just to make it easier to review and land this piecemeal?

Sure. It's not that I like mixing unrelated stuff one PR, rather the example and tracing became a side-effect of adding a signal handling logic, namely testing ctrl c handling

rustworthy avatar May 19 '24 18:05 rustworthy

Sorry it took me a while (again) 😅

No worries, it actually takes me that exact Duration to iterate over the things

rustworthy avatar May 25 '24 08:05 rustworthy

@jonhoo Please have another look.

As for the conflicts, #68 should unblock the pipeline in main

rustworthy avatar Jun 08 '24 04:06 rustworthy

Just FYI — I'm away on holiday this week, so won't get to this until the weekend after next probably 😅

jonhoo avatar Jun 13 '24 19:06 jonhoo

Just FYI — I'm away on holiday this week, so won't get to this until the weekend after next probably 😅

I wish you a great holiday! As for the PRs, I still need some extra time for the tech debt one, so this is actually great.

rustworthy avatar Jun 13 '24 19:06 rustworthy

@jonhoo Sorry for pushing amid review request - just pulled the latest from main resolving some minor conflicts

rustworthy avatar Jun 22 '24 08:06 rustworthy

@jonhoo I think all the threads have been addressed.

I thing that I have just realized is that we do not allow to Worker::run a terminated worker, and we drop the processing workers we have spawned, but Worker::run_one is still possible since the coordinating worker is not dropped.

Imagine the situation where the server told us to stop the consumption (we get this message in the heartbeat task on the coordinator), and we do so and mark the coordinator as terminated. What they can do then is take this worker and call run_one in a loop mimicking this way the Worker::run logic, but without HEARTBEATing and - most importantly - breaking the server instruction we've received previously. I think this is not something we want to be possible, wdyt?

rustworthy avatar Jul 19 '24 06:07 rustworthy