From 839387991bd2be8b2f64d2c777371307bd0a1c7f Mon Sep 17 00:00:00 2001 From: "Dzianis Vashchuk (Chainlink)" Date: Wed, 27 May 2026 15:52:33 +0000 Subject: [PATCH 1/3] feat(beholder): add backward-compat type shims for durable event store MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Standalone type declarations (not aliases) in pkg/beholder that mirror the canonical types in pkg/durableemitter. This avoids breaking existing consumers that import from pkg/beholder while the migration to pkg/durableemitter completes. Uses standalone types instead of aliases to avoid an import cycle: durableemitter tests → servicetest → utils/tests → beholdertest → beholder. Tracked for removal in chainlink PR #22562. --- pkg/beholder/durable_event_store.go | 52 +++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 pkg/beholder/durable_event_store.go diff --git a/pkg/beholder/durable_event_store.go b/pkg/beholder/durable_event_store.go new file mode 100644 index 0000000000..1dc4026ac4 --- /dev/null +++ b/pkg/beholder/durable_event_store.go @@ -0,0 +1,52 @@ +package beholder + +import ( + "context" + "time" +) + +// Backward-compatibility types for downstream consumers (e.g. chainlink node). +// These were moved to pkg/durableemitter in PR #2081. They are re-declared here +// (not aliases) to avoid an import cycle through test utilities. +// +// TODO(SHARED-2644): Remove this file once chainlink node migrates imports to +// pkg/durableemitter (tracked in chainlink PR #22562). These duplicate declarations +// have no compile-time sync check against the canonical types. + +// DurableEvent represents a persisted event awaiting delivery to Chip. +type DurableEvent struct { + ID int64 + Payload []byte + CreatedAt time.Time +} + +// DurableQueueStats is a point-in-time snapshot of the pending queue for metrics. +type DurableQueueStats struct { + Depth int64 + PayloadBytes int64 + OldestPendingAge time.Duration + NearTTLCount int64 +} + +// DurableQueueObserver is optionally implemented by DurableEventStore implementations +// so DurableEmitter can export queue depth and age gauges when metrics are enabled. +type DurableQueueObserver interface { + ObserveDurableQueue(ctx context.Context, eventTTL, nearExpiryLead time.Duration) (DurableQueueStats, error) +} + +// BatchInserter is optionally implemented by DurableEventStore implementations +// to support multi-row inserts for higher throughput. +type BatchInserter interface { + InsertBatch(ctx context.Context, payloads [][]byte) ([]int64, error) +} + +// DurableEventStore abstracts the persistence layer for durable chip events. +type DurableEventStore interface { + Insert(ctx context.Context, payload []byte) (int64, error) + Delete(ctx context.Context, id int64) error + MarkDelivered(ctx context.Context, id int64) error + MarkDeliveredBatch(ctx context.Context, ids []int64) (int64, error) + PurgeDelivered(ctx context.Context, batchLimit int) (deleted int64, err error) + ListPending(ctx context.Context, createdBefore time.Time, limit int) ([]DurableEvent, error) + DeleteExpired(ctx context.Context, ttl time.Duration) (int64, error) +} From 1bf4298b9e87695729e9d489a9e4e1ee8e2ecee3 Mon Sep 17 00:00:00 2001 From: "Dzianis Vashchuk (Chainlink)" Date: Wed, 27 May 2026 16:16:52 +0000 Subject: [PATCH 2/3] ci: trigger fresh run after PR body fix From 780ef904d12d56706e9ca9b5c78bbaf389b87983 Mon Sep 17 00:00:00 2001 From: Dzianis Vashchuk Date: Thu, 28 May 2026 03:25:12 +0000 Subject: [PATCH 3/3] chore: exclude beholder compat shim from SonarQube duplication check The backward-compatibility type declarations in pkg/beholder/durable_event_store.go intentionally duplicate types from pkg/durableemitter/ to avoid an import cycle. Exclude this file from CPD (Copy-Paste Detection) so the Quality Gate passes. --- sonar-project.properties | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 3310f7904e..1cc2d54cd0 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -36,4 +36,6 @@ sonar.tests=. sonar.test.inclusions=**/*_test.go # Duplication exclusions -sonar.cpd.exclusions=**/observability-lib/**/* \ No newline at end of file +sonar.cpd.exclusions=\ +**/observability-lib/**/*,\ +pkg/beholder/durable_event_store.go