Interface IEventHubStorageProvider<TStorageRecord>
interface for implementing a storage provider for event hub app (gRPC server)
Namespace: FastEndpoints
Assembly: FastEndpoints.Messaging.Remote.dll
Syntax
public interface IEventHubStorageProvider<TStorageRecord> where TStorageRecord : IEventStorageRecord
Type Parameters
Name | Description |
---|---|
TStorageRecord | the type of the storage record |
Methods
GetNextBatchAsync(PendingRecordSearchParams<TStorageRecord>)
fetch the next batch of pending event storage records that need to be processed.
Declaration
ValueTask<IEnumerable<TStorageRecord>> GetNextBatchAsync(PendingRecordSearchParams<TStorageRecord> parameters)
Parameters
Type | Name | Description |
---|---|---|
PendingRecordSearchParams<TStorageRecord> | parameters | use these supplied search parameters to find the next batch of event records from your database |
Returns
Type | Description |
---|---|
ValueTask<IEnumerable<TStorageRecord>> |
MarkEventAsCompleteAsync(TStorageRecord, CancellationToken)
mark the event storage record as complete by either replacing the entity on storage with the supplied instance or simply update the IsComplete field to true with a partial update operation.
Declaration
ValueTask MarkEventAsCompleteAsync(TStorageRecord r, CancellationToken ct)
Parameters
Type | Name | Description |
---|---|---|
TStorageRecord | r | |
CancellationToken | ct | cancellation token |
Returns
Type | Description |
---|---|
ValueTask |
PurgeStaleRecordsAsync(StaleRecordSearchParams<TStorageRecord>)
this method will be called hourly. implement this method to remove stale records (completed or expired) from storage. or instead of removing them, you can move them to some other location (dead-letter-queue maybe) or for inspection by a human. or if you'd like to retry expired events, update the ExpireOn field to a future date/time.
NOTE: the default match criteria is:
r => r.IsComplete || DateTime.UtcNow >= r.ExpireOn
Declaration
ValueTask PurgeStaleRecordsAsync(StaleRecordSearchParams<TStorageRecord> parameters)
Parameters
Type | Name | Description |
---|---|---|
StaleRecordSearchParams<TStorageRecord> | parameters | use these supplied search parameters to find relevant event records from your database |
Returns
Type | Description |
---|---|
ValueTask |
RestoreSubscriberIDsForEventTypeAsync(SubscriberIDRestorationParams<TStorageRecord>)
this method will only be called once (for each event type) on app startup. if there are any pending records on storage from a previous app run, simply return a collection of unique subscriber IDs.
Declaration
ValueTask<IEnumerable<string>> RestoreSubscriberIDsForEventTypeAsync(SubscriberIDRestorationParams<TStorageRecord> parameters)
Parameters
Type | Name | Description |
---|---|---|
SubscriberIDRestorationParams<TStorageRecord> | parameters | use these supplied search parameters to find relevant event records from your database |
Returns
Type | Description |
---|---|
ValueTask<IEnumerable<string>> |
StoreEventAsync(TStorageRecord, CancellationToken)
store the event storage record however you please. ideally on a nosql database.
Declaration
ValueTask StoreEventAsync(TStorageRecord r, CancellationToken ct)
Parameters
Type | Name | Description |
---|---|---|
TStorageRecord | r | the event storage record which contains the actual event object as well as some metadata |
CancellationToken | ct | cancellation token |
Returns
Type | Description |
---|---|
ValueTask |