-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
FEATURE: Policy Wrap ( / pipeline) #140
Comments
I had a PolicyChain which actually implemented this Wrap very similarly, except that ExecuteAndCapture actually was done by the innermost policy, and returned backwards. (I am not sure which solution would be ideal - option at builder ?) The IPolicy was also implemented by a CombinedPolicy which "merges" an async policy with a sync policy, removing the runtime exceptions of using an async policy synchronouslly and a sync policy asynchronouslly. IPolicy extended from IAsyncPolicy and from ISyncPolicy, which made policies more clearly separated and avoid any miss-usage of them. |
@juancarrey That's great to hear: thanks for sharing!
@juancarrey That's exactly the implementation I am planning. Each policy in the Wrap only needs to know about the next, and this actually simplifies the wrap implementation greatly. Except that we have consciously held off |
@juancarrey , re:
My thought so far was that the capture of My assumption so far about the If the question is about how to capture 'what went on [what exception was maybe thrown] at the inner levels', then my thinking so far is that the complexity dictates we need to look to another mechanism: either Thoughts, anyone? |
@reisenberger That makes sense to be the outermost |
i like the idea of emitting events. your examples of using the events for telemetry and logging were great examples of some of the benefits. |
An initial implementation of |
Proposal: Policy Wrap (was: Pipeline)
Purpose
To provide the ability to chain a series of policies together.
Scope
TResult
Action
-executing) policies may be wrapped; all polices in the wrap must returnvoid
.Original proposal: Policy Pipeline
The roadmap originally proposed the following syntax:
Some issues were:
Revised proposal: Policy Wrap
The revision proposes the name Policy Wrap:
Syntax proposal
Both static and instance configuration methods are now proposed:
Value of functional composition
With the original 'one-shot' static syntax, it was not intuitive how to create a pipeline that was a slight variation on another. It could lead to questions about 'how to [consistently] insert something into the middle of an IEnumerable/ICollection'. Mutable pipelines also potentially have issues in multi-threaded, concurrent scenarios.
The instance syntax of
.Wrap(...)
allows more flexible functional-composition of a PolicyWrap:The functional-composition paradigm matches LINQ and Rx: successively composing functional transformations on the function-so-far, before actual execution.
Operation
Context
instance carriesKey
information unifying the call: see Keys proposal FEATURE: Add KEYs to policies and executions #139 for details.ExecuteAndCapture()
. Probably only the outermost policy in the wrap shouldExecuteAndCapture()
; others shouldExecute()
-and-throw.Naming
Any alternative naming suggestions?
Comments?
Comments? Alternative suggestions? Extra considerations to bear in mind?
Have scenarios to share where you'd use this? (could inform development)
The text was updated successfully, but these errors were encountered: