InMemoryWebhookStore
AgentPrism.Core.dllThe default implementation that keeps webhook subscriptions and delivery history in process memory.
public sealed class InMemoryWebhookStore : IWebhookStoreInheritance
Section titled “Inheritance”Implements
Section titled “Implements”Inherited Members
Section titled “Inherited Members”object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Remarks
Section titled “Remarks”For single-process deployments and tests. UsePostgreSql replaces it
with PostgresWebhookStore.
Constructors
Section titled “Constructors”InMemoryWebhookStore()
Section titled “ InMemoryWebhookStore()”public InMemoryWebhookStore()Methods
Section titled “Methods”CreateDeliveryAsync(WebhookDelivery, CancellationToken)
Section titled “ CreateDeliveryAsync(WebhookDelivery, CancellationToken)”Creates a delivery record.
public ValueTask<WebhookDelivery> CreateDeliveryAsync(WebhookDelivery delivery, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”delivery WebhookDelivery
The delivery.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The created record.
DeleteSubscriptionAsync(string, string, CancellationToken)
Section titled “ DeleteSubscriptionAsync(string, string, CancellationToken)”Deletes a subscription and its delivery history.
public ValueTask<bool> DeleteSubscriptionAsync(string tenantId, string name, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”tenantId string
The tenant identifier.
name string
The subscription name.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”true if the delete happened.
FindForEventAsync(string, string, CancellationToken)
Section titled “ FindForEventAsync(string, string, CancellationToken)”Fetches all enabled subscriptions subscribed to a specific event.
public ValueTask<IReadOnlyList<WebhookSubscription>> FindForEventAsync(string tenantId, string eventType, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”tenantId string
The tenant identifier.
eventType string
The event name.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”ValueTask<IReadOnlyList<WebhookSubscription>>
The matching subscriptions. An empty list if none.
GetDeliveryAsync(Guid, CancellationToken)
Section titled “ GetDeliveryAsync(Guid, CancellationToken)”Fetches a single delivery record.
public ValueTask<WebhookDelivery?> GetDeliveryAsync(Guid deliveryId, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”deliveryId Guid
The delivery identifier.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The record; null if it does not exist.
GetSubscriptionAsync(string, string, CancellationToken)
Section titled “ GetSubscriptionAsync(string, string, CancellationToken)”Fetches a single subscription by name.
public ValueTask<WebhookSubscription?> GetSubscriptionAsync(string tenantId, string name, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”tenantId string
The tenant identifier.
name string
The subscription name.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”ValueTask<WebhookSubscription?>
The subscription; null if it does not exist.
ListSubscriptionsAsync(string, CancellationToken)
Section titled “ ListSubscriptionsAsync(string, CancellationToken)”Lists a tenant’s subscriptions.
public ValueTask<IReadOnlyList<WebhookSubscription>> ListSubscriptionsAsync(string tenantId, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”tenantId string
The tenant identifier.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”ValueTask<IReadOnlyList<WebhookSubscription>>
The subscriptions.
QueryDeliveriesAsync(WebhookDeliveryQuery, CancellationToken)
Section titled “ QueryDeliveriesAsync(WebhookDeliveryQuery, CancellationToken)”Lists delivery history. The newest record is returned first.
public ValueTask<IReadOnlyList<WebhookDelivery>> QueryDeliveriesAsync(WebhookDeliveryQuery query, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”query WebhookDeliveryQuery
The filter.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”ValueTask<IReadOnlyList<WebhookDelivery>>
The records.
RecordDeliveryResultAsync(WebhookDeliveryResult, CancellationToken)
Section titled “ RecordDeliveryResultAsync(WebhookDeliveryResult, CancellationToken)”Writes a delivery attempt’s result.
public ValueTask RecordDeliveryResultAsync(WebhookDeliveryResult result, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”result WebhookDeliveryResult
The result.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”The completion task.
RecordSubscriptionOutcomeAsync(Guid, bool, int, DateTimeOffset, CancellationToken)
Section titled “ RecordSubscriptionOutcomeAsync(Guid, bool, int, DateTimeOffset, CancellationToken)”Updates a subscription’s consecutive-failure counter, and disables the subscription if the threshold is exceeded.
public ValueTask<bool> RecordSubscriptionOutcomeAsync(Guid subscriptionId, bool succeeded, int disableThreshold, DateTimeOffset updatedAt, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”subscriptionId Guid
The subscription identifier.
succeeded bool
Whether the most recent delivery succeeded.
disableThreshold int
The subscription is disabled after this many consecutive failures.
updatedAt DateTimeOffset
The update time (UTC).
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”true if the subscription was disabled during this call.
SaveSubscriptionAsync(WebhookSubscription, CancellationToken)
Section titled “ SaveSubscriptionAsync(WebhookSubscription, CancellationToken)”Creates or updates a subscription.
public ValueTask<WebhookSubscription> SaveSubscriptionAsync(WebhookSubscription subscription, CancellationToken cancellationToken = default)Parameters
Section titled “Parameters”subscription WebhookSubscription
The subscription.
cancellationToken CancellationToken
The cancellation token.
Returns
Section titled “Returns”ValueTask<WebhookSubscription>
The saved subscription.