Add IProcessEnd interface#1140
Conversation
martinothamar
left a comment
There was a problem hiding this comment.
I think this makes sense to have long term as well 👍
Open questions
IProcessEndvsIInstanceEnd? I like the process one but I guess we could say that both the instance and the process is done here, so thought I'd bring it up- For symmetry we could consider
IProcessStartorIInstanceStartI guess, but we already have hooks for the start variant of this.
It would have been useful to have a concrete list of events/hooks we want to have in the future process engine (v9). We should probably do that soon...
Does backport-ignore make more sense here since this is a new feature?
Good question! I don't have any strong opinions on this, I only went with
Definitely! I only skipped this part because I don't need it for the issue I'm working on right now, so I figured it could be added later if we wanted it. I also suspect that
I did this on purpose, because I am hoping to get this released very soon (assuming everyone's cool with that). But other than that, I completely agree that this doesn't really fit the usual "backport" mindset. Happy to take some advice on this too 🙂 |
ivarne
left a comment
There was a problem hiding this comment.
I will likely vote for Process. I don't think it makes much sense to hide the fact that we have a process backing the instance.
- Should we include
IInstanceDataMutator? - Telemetry around execution of the hook
- Can/should we support parallel execution of multiple hooks? It kind of makes sense to be able to run multiple reporting jobs simultaneously.
This isn't available in ProcessEngine, so I'm not sure exactly how that would flow out to these invocations. Other than that, sure!
We haven't done anything with telemetry for other user hooks, as far as I can see. So I didn't feel it was necessary here either, but perhaps this could be a bigger lift at some point?
My initial thought is that this possibly breaks with user expectations, since we're invoking all other user code sequentially? |
|
/publish |
PR release:
|
We do in dataProcessing and validation app-lib-dotnet/src/Altinn.App.Api/Helpers/Patch/InternalPatchService.cs Lines 273 to 289 in b347d72 Validation does it in parallel, but IProcessEnd would need to be opt-in for parallel execution, so we can add that later if the new process engine wants to support it in some way. |
|



Description
As discussed briefly within the team, though not necessarily agreed upon, this is a proposal to add an
IProcessEndinterface to the process engine.Following the established convention, this would involve creating and registering a
WhateverEventHandler. In this particular case, based on the names of the other handlers, the name would probably beEndProcessEventHandleror something similar. However, we already have an EndEventEventHandler, which also gets invoked at the end of the process.So to avoid further confusing the issue, I simply added this new feature as an
IEnumerable<IProcessEnd>injection straight inProcessEngine.Motivation
A service owner wishes to place a hook in their app code, to be executed after the instance process has come to an end. In the case at hand, their wish is to place a call to
/completeto flag the instance as "read". This is typically done after the instance has completed its processing and has arrived atendEvent.We currently have IAppEvents.OnEndAppEvent which gets invoked at the end of a process, but it's not really intended for public implementation and the default handler contains logic which we want to keep. Additionally, the invocation of
OnEndAppEventdoesn't actually happen right at the end of the process:OnEndAppEventI've actually lost track of whether it matters or not, that the
OnEndAppEventfires before the last call to Stoage. But regardless of that, the overall vibe of the uphill battle I've had here leads me to think that implementing an actualIProcessEndinterface is a reasonable solution.Verification
Documentation