Inherits: IConfigurable, IReconfigurable
Description
The AbstractController class allows you to create an abstract logger that caches captured log messages in memory and periodically dumps them. Child classes implement saving cached messages to their specified destinations.
Fields
Properties
Component
Component
public abstractstring Component { get; }
Instance methods
Configure
Configures a component by passing its configuration parameters.
public virtualvoid Configure(ConfigParams config)
- config: ConfigParams - configuration parameters to be set.
SetReferences
Sets references to dependent components.
public virtualvoid SetReferences(IReferences references)
- references: IReferences - references to locate the component’s dependencies.
Instrument
Starts timing.
public virtualCounterTiming Instrument(string correlationId, string methodName, string message="")
- correlationId: string - (optional) transaction id used to trace execution through the call chain.
- methodName: string - name of the method
- message: string - message
HandleError
Logs an error.
public virtualvoid HandleError(string correlationId, string methodName, Exception ex)
- correlationId: string - (optional) transaction id used to trace execution through the call chain.
- methodName: string - name of the method
- ex: Exception - exception
SafeInvokeAsync
Invokes a function.
public virtualTask<T> SafeInvokeAsync<T>(string correlationId, string methodName, Func<Task<T>> invokeFunc, bool throwException=false)
- correlationId: string - (optional) transaction id used to trace execution through the call chain.
- methodName: string - name of the method
- invokeFunc: Func<Task<T>> - invoked function
- throwException: bool - true if can throw an exception and false otherwise
SafeInvokeAsync
Invokes a function and handles the error if it fails.
public virtualTask<T> SafeInvokeAsync<T>(string correlationId, string methodName, Func<Task<T>> invokeFunc, Func<Task<T>> errorHandlerFunc, bool throwException=false)
- correlationId: string - (optional) transaction id used to trace execution through the call chain.
- methodName: string - name of the method
- invokeFunc: Func<Task<T>> - invoked function
- errorHandlerFunc: Func<Task<T>> - error handling function
- throwException: bool - true if can throw an exception and false otherwise
RetrieveFromCacheAsync
Retrieves from cache based on the cache key.
public virtualTask<T> RetrieveFromCacheAsync<T>(string correlationId, string cacheKey)
- correlationId: string - (optional) transaction id to trace execution through call chain.
- cacheKey: string - cache key
StoreInCacheAsync
Stores in cache using the cache key.
public virtualTask<T> StoreInCacheAsync<T>(string correlationId, string cacheKey, T result)
- correlationId: string - (optional) transaction id to trace execution through call chain.
- cacheKey: string - cache key
- result: T - Cached value or null if the value is not stored.
RemoveFromCacheAsync
Removes from cache.
public virtualTask RemoveFromCacheAsync(string correlationId, string id)
- correlationId: string - (optional) transaction id used to trace execution through the call chain.
- id: string - id
GetProjectionCacheKey
Gets the projection
public virtualstring GetProjectionCacheKey(string id)
- id: string - id
GetCacheKey
Returns the component’s id.
public virtualstring GetCacheKey(string id)
- id: string - id
AuditCreateAsync
Checks if an object is created.
public virtualTask AuditCreateAsync<T>(string correlationId, string collectionName, object createdObject, Func<Task<T>> auditFunc)
- correlationId: string - (optional) transaction id used to trace execution through the call chain.
- collectionName: string - name of the collection
- createdObject: object - created object
- auditFunc: Func<Task<T>> - audit function
AuditUpdateAsync
Audits the update of an object.
public virtualTask AuditUpdateAsync<T>(string correlationId, string collectionName, object oldObject, object updatedObject, Func<Task<T>> auditFunc)
- correlationId: string - (optional) transaction id used to trace execution through the call chain.
- collectionName: name of the collection
- oldObject: object - old object
- updatedObject: object - updated object
- auditFunc: Func<Task<T>> - audit function
AuditDeleteAsync
Audits the delete of an object.
public virtualTask AuditDeleteAsync<T>(string correlationId, string collectionName, object deletedObject, Func<Task<T>> auditFunc)
- correlationId: string - (optional) transaction id used to trace execution through the call chain.
- collectionName: string - name of the collection
- deletedObject: object - deleted object
- auditFunc: Func<Task<T>> - audit function