DVWebhooks class

DV.Webhooks.

Subscriptions, deliveries and payloads are rows in DV.Database, so the record of what was sent -- and what is still owed -- outlives the process that emitted it. The queue carries only "attempt the head of this endpoint's line"; everything that job needs to know is read from the database when it runs, so a job queued before a restart, or re-queued by drain after the queue itself was lost, does the same thing.

Constructors

DVWebhooks()
const

Properties

catalog → List<DVWebhookEvent>
no setter
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

declare(DVWebhookEvent event) → void
deliveries(String subscriptionId) → Future<List<DVWebhookDelivery>>
subscriptionId's deliveries in the order they were emitted.
delivery(String id) → Future<DVWebhookDelivery?>
drain(String subscriptionId) → Future<void>
Works subscriptionId's queue until nothing is left in it.
drainAll() → Future<void>
Drains every subscription at once, each in its own line, so an endpoint that takes thirty seconds to answer delays its own deliveries and nobody else's.
drainOnce(String subscriptionId) → Future<void>
Runs one queued attempt for subscriptionId.
emit(String event, Object? payload) → Future<List<DVWebhookDelivery>>
Records a delivery of event to every enabled subscription that asked for it, and queues them.
enable(String subscriptionId) → Future<void>
Re-enables a disabled endpoint and resumes its pending deliveries.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
purgeExpiredPayloads() → Future<int>
Drops the payload of every finished delivery older than the retention window, keeping the record. Returns how many were dropped.
replay(String deliveryId) → Future<DVWebhookDelivery>
Sends a delivery again, as the same delivery, while its payload is kept.
resume() → Future<void>
Queues whatever every enabled endpoint is still owed. For a process starting up: deliveries that were pending when the last one stopped continue from the attempts already recorded.
rotateSigningKey(String subscriptionId, String newSecret, {required Duration overlap}) → Future<DVWebhookSubscription>
Signs with newSecret from now on, and with the current key as well until overlap has passed (DV-WEBHOOK-007), so a customer can switch keys without a window in which every delivery fails verification.
subscribe({required String url, required Set<String> events, required String signingSecret, String? tenant, String? id}) → Future<DVWebhookSubscription>
Subscribes url to events, after checking the address.
subscription(String id) → Future<DVWebhookSubscription?>
subscriptions() → Future<List<DVWebhookSubscription>>
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

clock ↔ DateTime Function()
Injectable for tests, like DVHttp.clock.
getter/setter pair
config ↔ DVWebhooksConfig
getter/setter pair
database ↔ DVDatabaseAdapter?
Where the record is kept. Null means DV.Database's adapter, resolved on each use so a tenant's database is the tenant's.
getter/setter pair
onDisabled ↔ Future<void> Function(DVWebhookSubscription subscription)?
Called when an endpoint is disabled, for telling its owner — wire it to DV.Notifications.
getter/setter pair
resolveHost ↔ Future<List<String>> Function(String host)
Every address a host resolves to. Injectable so a test can put a name on a private address without a DNS server.
getter/setter pair

Static Methods

reset() → void
Forgets what this process holds -- declarations, configuration, hooks -- and none of what the database holds.

Constants

drainJobCodec → const String
The job's codec name. Written into a durable queue and read back after a restart, so it does not change.