-
Notifications
You must be signed in to change notification settings - Fork 11
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
Implement experimental basic job execution progress reporting hook #157
Conversation
018d842
to
f2a28ca
Compare
I took a similar approach some time ago. Also @falvarez1 started working on this. Especially because if a job doesn't get scheduled or executed you also need some hook. (For example: Multiple jobs are scheduled at the same time, but only one can be executed). As far as I can tell, only somewhat "successful" runs will be registered in the current implementation. We might also want to remove |
Codecov ReportAttention: Patch coverage is
|
@linkdotnet The current approach is hooked on the
That's not the intent. Every state change should be reported. In one of the latest pushes, I've added a test that showcases an Edit: Just covered the |
src/NCronJob/NCronJob.csproj
Outdated
Documentation will be eventually hand rolled before merge. | ||
|
||
--> | ||
<GenerateDocumentationFile>false</GenerateDocumentationFile> |
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.
Savagely hacked on purpose. To be reverted before merge
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.
Interesting. For what did you need the this?
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.
Because I'm (shamelessly) more interested in getting feedback from the CI server test runs on different platforms than documenting the public types.
All the "Missing XML comment for publicly visible type or member xxxx" error messages were making my "Developer Experience" a lot less rich 😉
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.
I am not sure how to properly handle that.
Opting out might lead to missing XML annotations. It is very strict (well at least not if you use DEBUG locally, but that doesn't help in your case)
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.
Savagely hacked on purpose. To be reverted before merge
Once you think the API is ok. I'll write the xml documentation and revert this change. Before the merge.
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.
Reverted as documentation has been added.
If that ok with you I'd rather tackle that in a follow up PR. I attempted to do that, but in the end this generated a lot of diff noise that made this proposal harder to read. Besides, there's a entry |
bb1e006
to
32df99b
Compare
Yes sure - I was just interested about the second type that (to some extent) reflects the same nature. Another idea I toyed around (and maybe you had similar thoughts) is to have a mediator in the middle and do all the things just by messaging, removing a bit of the coupling. Ultimately I didn't go through as it seemed a lot of noise when I spiked something together and the overall amount of objects would be higher than for example your current approach. |
As a lot of things happens between all the types, I was willing to disrupt the current code in the least possible way in order to prevent any regression. Hence, why I tiptoed and end up plugging in the JobRun state machine. The trajectory would be to cover the current proposal with as many tests as possible in order to ensure it works as expected, and merge it as is. The tests would later provide us with a safety net would you want to revamp the internal messaging architecture. |
Just added some additional test coverage with regards to StartupJobs. @linkdotnet Do you see any other existing use cases you'd like to see covered? |
@linkdotnet rebased |
Hey @nulltoken - I am currently a bit busy. I try to have a closer look at the end of the week / weekend. |
5b22a27
to
ee59993
Compare
For example: https://github.com/NCronJob-Dev/NCronJob/blob/main/src/NCronJob/JobExecutionContext.cs#L44 Skipping dependent Jobs. Right now, we are using measure like this: (await WaitForJobsOrTimeout(1, TimeSpan.FromMilliseconds(500))).ShouldBe(false); |
@nulltoken On an unrelated side note, do you have any GitHub Sponsor page, Kofi or so? |
I do not. |
This one is a whole different beast. JobRuns of dependent jobs aren't even created yet when the skipping is done. |
fea31cf
to
0cb0973
Compare
0cb0973
to
3707030
Compare
@linkdotnet I think I'm done from the code standpoint on this first step and would welcome a review. It fulfills the need of #147 and reports the start/completion of an orchestration (whether it would be made of simple job or a root job along with its dependencies). It also contains the following fixes (covered by the tests):
Identified additional features have been logged in separate features: |
First of all: Thanks very much for the PR! Really nice. I guess it was the best decision to track those two things independently and not tackle them in this PR. That said - let's bring this in. You might wanna add this to the |
👍 Will work on that and report when it's done. |
75dcc17
to
55a8cbe
Compare
@linkdotnet Done |
var reporter = app.Services.GetRequiredService<IJobExecutionProgressReporter>(); | ||
|
||
// ...enlist a new subscriber to it... | ||
IDisposable subscriber = reporter.Register(Subscriber); |
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.
Maybe using var subscriber
would be more idiomatic for .NET devs
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.
I'd prefer keeping the IDisposable
type under the light. That's a rather important aspect of the design.
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.
Can you elaborate a bit on this?
Handling the Dispose
explicitly can lead to many pitfalls.
Especially what if,during Register
and Dispose
there is an exception? The example should be somewhat idiomatic and lead developers to a pit of success.
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.
Can you elaborate a bit on this?
This example isn't the final way this should be implemented. It is contrived.
In the real life, there are few chances the subscriber will be a private function.
Chances are it'll rather be a type built and injected in the DI container. In that design, the type itself should be disposable (taking care of disposing the registered subscribers) and the overall disposal would be trigerred by the DI container.
However, as I was willing to build a not too lengthy example, I went with this.
While working on #36, it's even possible we'll have to build something similar (or an abstraction of it) and make it available to the users so that they don't have to reinvent the wheel.
Especially what if,during Register and Dispose there is an exception? The example should be somewhat idiomatic and lead developers to a pit of success.
This is an experimental feature. It's not finished. It may not work and/or change. It comes with rough corners and sharp edges 😉
The final developer experience will be ready when this feature is deemed stable.
The only goal of that sample is to showcase how the pieces move together and give a chance to potential early adopters to "play" with it.
It's even described as such in the previous paragraph ("Below a very simple approach....").
If you prefer, I can emphasize this with some words putting under the light this isn't a "copy-and-paste-production-ready" code.
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.
Don't get me wrong, this is totally fine to merge. That is why I already approved.
This is an experimental feature. It's not finished. It may not work and/or change. It comes with rough corners and sharp edges
True - but for me, it was more about how the user code is written. That is totally independent of our stability with the feature.
The code handles the disposable in a suboptimal way - but I get your verbosity here.
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.
True - but for me, it was more about how the user code is written. That is totally independent of our stability with the feature.
The code handles the disposable in a suboptimal way
I agree and we'll refine later that part of the documentation
- but I get your verbosity here.
Thanks for coping with me 😉
Don't get me wrong, this is totally fine to merge. That is why I already approved.
Let's get this in then!
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.
LGTM
55caa71
to
fd4c7e0
Compare
fd4c7e0
to
248b266
Compare
248b266
to
9e6d0d7
Compare
Pull request description
Fix #147
The idea behind this proposal is to provide a non stable reporting mechanism.
While allowing me to scratch my own #147 itch and potentially receiving potential feedback/feature request from other early bleeding edge adopters, this should also allow us to slowly evolve this toward the requirements of #36 of an more feature rich observer.
PR meta checklist
main
branch for codeCode PR specific checklist