Interface ICausationManager
- Namespace
- Cratis.Chronicle.Auditing
- Assembly
- Cratis.Chronicle.dll
Defines a system that manages causation.
public interface ICausationManager
- Extension Methods
Properties
Root
Gets the root causation.
Causation Root { get; }
Property Value
Methods
Add(CausationType, IDictionary<string, string>)
Adds a causation.
void Add(CausationType type, IDictionary<string, string> properties)
Parameters
typeCausationTypeType to add.
propertiesIDictionary<string, string>Properties associated with the causation.
Remarks
Additions apply to the current async flow and flows it starts afterwards. They do not propagate back to the caller after an awaited async method returns.
BeginScope(CausationType, IDictionary<string, string>)
Adds a causation that lasts only as long as the returned scope.
IDisposable BeginScope(CausationType type, IDictionary<string, string> properties)
Parameters
typeCausationTypeType to add.
propertiesIDictionary<string, string>Properties associated with the causation.
Returns
- IDisposable
An IDisposable that removes the causation again.
Remarks
Like Add(CausationType, IDictionary<string, string>), the addition applies to the current async flow and flows it starts afterwards, not back to the caller after an awaited async method returns. Scope disposal is shared with flows forked inside the scope, including disposal after awaiting.
Add(CausationType, IDictionary<string, string>) is append-only, which is right for a link that describes how the work arrived and stays true for everything that follows - an HTTP request, a reactor invocation. It is wrong for a link that describes one bounded piece of work, because two such pieces done one after the other both end up on the chain and the second reads as caused by the first. That is an ordering nothing actually established.
Scopes are last-in first-out: disposing one removes its causation and anything added after it. Dispose is idempotent, and disposing out of order removes the later scopes with it rather than corrupting the chain.
GetCurrentChain()
Gets the current causation.
IImmutableList<Causation> GetCurrentChain()
Returns
- IImmutableList<Causation>
A collection of Causation.