Skip to main content

Crate shardline_provider_events

Crate shardline_provider_events 

Source
Expand description

Provider webhook event processing for the Shardline server.

This crate handles incoming provider webhook events (repository deleted, renamed, access changed, revision pushed) and applies the corresponding metadata mutations.

§Quick start

The outcome types are pure data describing what one webhook application did, so they are the easiest entry point:

use shardline_provider_events::{ProviderWebhookOutcome, ProviderWebhookOutcomeKind};
use shardline_vcs::ProviderKind;

let outcome = ProviderWebhookOutcome {
    provider: ProviderKind::GitHub,
    owner: "acme".to_owned(),
    repo: "assets".to_owned(),
    delivery_id: "delivery-123".to_owned(),
    event_kind: ProviderWebhookOutcomeKind::RepositoryDeleted,
    affected_file_versions: 12,
    affected_chunks: 34,
    applied_holds: 1,
    retention_seconds: Some(3600),
};

assert_eq!(outcome.owner, "acme");
assert!(matches!(outcome.event_kind, ProviderWebhookOutcomeKind::RepositoryDeleted));

A rename carries the new location:

use shardline_provider_events::ProviderWebhookOutcomeKind;

let kind = ProviderWebhookOutcomeKind::RepositoryRenamed {
    new_owner: "acme".to_owned(),
    new_repo: "assets-v2".to_owned(),
};
assert!(matches!(
    kind,
    ProviderWebhookOutcomeKind::RepositoryRenamed { new_repo, .. } if new_repo == "assets-v2"
));

To apply a webhook to real state, call apply_provider_webhook_with_stores with explicit record, index, and object-store adapters.

Structs§

PlannedPostgresProviderWebhook
Planned atomic Postgres mutation and its applied/duplicate protocol outcomes.
ProviderWebhookOutcome
Summary of one handled provider webhook.

Enums§

ProviderEventsError
Provider webhook event processing failure.
ProviderWebhookOutcomeKind
Publicly reportable webhook outcome kind.

Constants§

DEFAULT_LOCAL_GC_RETENTION_SECONDS
Default retention window for new local quarantine candidates. Default retention window for new local quarantine candidates.
WEBHOOK_DELIVERY_RETENTION_SECONDS
Default retention window for the provider webhook delivery replay-dedup table. Delivery claims older than this are purged to bound metadata-store growth; replay dedup within the window is unaffected.

Functions§

apply_provider_webhook_with_stores
Applies a normalized provider webhook to Shardline lifecycle state.
plan_postgres_provider_repository_webhook
Plans one Postgres repository webhook without changing durable metadata.
purge_expired_webhook_deliveries
Opportunistically purges webhook-delivery dedup rows older than the retention window, at most once per [WEBHOOK_DELIVERY_PURGE_INTERVAL_SECONDS].