Skip to content

InMemoryWebhookStore

Namespace AgentPrism · Assembly AgentPrism.Core.dll

The default implementation that keeps webhook subscriptions and delivery history in process memory.

public sealed class InMemoryWebhookStore : IWebhookStore

objectInMemoryWebhookStore

IWebhookStore

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

For single-process deployments and tests. UsePostgreSql replaces it with PostgresWebhookStore.

public InMemoryWebhookStore()

CreateDeliveryAsync(WebhookDelivery, CancellationToken)

Section titled “ CreateDeliveryAsync(WebhookDelivery, CancellationToken)”

Creates a delivery record.

public ValueTask<WebhookDelivery> CreateDeliveryAsync(WebhookDelivery delivery, CancellationToken cancellationToken = default)

delivery WebhookDelivery

The delivery.

cancellationToken CancellationToken

The cancellation token.

ValueTask<WebhookDelivery>

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)

tenantId string

The tenant identifier.

name string

The subscription name.

cancellationToken CancellationToken

The cancellation token.

ValueTask<bool>

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)

tenantId string

The tenant identifier.

eventType string

The event name.

cancellationToken CancellationToken

The cancellation token.

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)

deliveryId Guid

The delivery identifier.

cancellationToken CancellationToken

The cancellation token.

ValueTask<WebhookDelivery?>

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)

tenantId string

The tenant identifier.

name string

The subscription name.

cancellationToken CancellationToken

The cancellation token.

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)

tenantId string

The tenant identifier.

cancellationToken CancellationToken

The cancellation token.

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)

query WebhookDeliveryQuery

The filter.

cancellationToken CancellationToken

The cancellation token.

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)

result WebhookDeliveryResult

The result.

cancellationToken CancellationToken

The cancellation token.

ValueTask

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)

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.

ValueTask<bool>

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)

subscription WebhookSubscription

The subscription.

cancellationToken CancellationToken

The cancellation token.

ValueTask<WebhookSubscription>

The saved subscription.