diff --git a/plugins/events-backend/src/service/hub/DatabaseEventBusStore.test.ts b/plugins/events-backend/src/service/hub/DatabaseEventBusStore.test.ts index c962fe75a0..3c8d2cb377 100644 --- a/plugins/events-backend/src/service/hub/DatabaseEventBusStore.test.ts +++ b/plugins/events-backend/src/service/hub/DatabaseEventBusStore.test.ts @@ -35,7 +35,7 @@ describe('DatabaseEventBusStore', () => { for (let i = 0; i < 10; ++i) { await store.publish({ - params: { topic: 'test', eventPayload: { n: i } }, + event: { topic: 'test', eventPayload: { n: i } }, }); } @@ -75,7 +75,7 @@ describe('DatabaseEventBusStore', () => { for (let i = 0; i < 10; ++i) { await store.publish({ - params: { topic: 'test', eventPayload: { n: i } }, + event: { topic: 'test', eventPayload: { n: i } }, }); } @@ -114,7 +114,7 @@ describe('DatabaseEventBusStore', () => { for (let i = 0; i < 10; ++i) { await store.publish({ - params: { topic: 'test', eventPayload: { n: i } }, + event: { topic: 'test', eventPayload: { n: i } }, }); } diff --git a/plugins/events-backend/src/service/hub/DatabaseEventBusStore.ts b/plugins/events-backend/src/service/hub/DatabaseEventBusStore.ts index a41e95733d..c94fa2aa2c 100644 --- a/plugins/events-backend/src/service/hub/DatabaseEventBusStore.ts +++ b/plugins/events-backend/src/service/hub/DatabaseEventBusStore.ts @@ -348,10 +348,10 @@ export class DatabaseEventBusStore implements EventBusStore { } async publish(options: { - params: EventParams; + event: EventParams; notifiedSubscribers?: string[]; }): Promise<{ eventId: string } | undefined> { - const topic = options.params.topic; + const topic = options.event.topic; const notifiedSubscribers = options.notifiedSubscribers ?? []; // This query inserts a new event into the database, but only if there are // subscribers to the topic that have not already been notified @@ -374,8 +374,8 @@ export class DatabaseEventBusStore implements EventBusStore { this.#db.raw('?', [topic]), this.#db.raw('?', [ JSON.stringify({ - payload: options.params.eventPayload, - metadata: options.params.metadata, + payload: options.event.eventPayload, + metadata: options.event.metadata, }), ]), this.#db.raw('?', [notifiedSubscribers]), diff --git a/plugins/events-backend/src/service/hub/MemoryEventBusStore.ts b/plugins/events-backend/src/service/hub/MemoryEventBusStore.ts index 6c7b4e6df7..2e4dba34bd 100644 --- a/plugins/events-backend/src/service/hub/MemoryEventBusStore.ts +++ b/plugins/events-backend/src/service/hub/MemoryEventBusStore.ts @@ -33,10 +33,10 @@ export class MemoryEventBusStore implements EventBusStore { }>(); async publish(options: { - params: EventParams; + event: EventParams; notifiedSubscribers: string[]; }): Promise<{ eventId: string } | undefined> { - const topic = options.params.topic; + const topic = options.event.topic; const notifiedSubscribers = new Set(options.notifiedSubscribers); let hasOtherSubscribers = false; @@ -51,7 +51,7 @@ export class MemoryEventBusStore implements EventBusStore { } const nextSeq = this.#getMaxSeq() + 1; - this.#events.push({ ...options.params, notifiedSubscribers, seq: nextSeq }); + this.#events.push({ ...options.event, notifiedSubscribers, seq: nextSeq }); for (const listener of this.#listeners) { if (listener.topics.has(topic)) { diff --git a/plugins/events-backend/src/service/hub/createEventBusRouter.ts b/plugins/events-backend/src/service/hub/createEventBusRouter.ts index 193c1108d5..b1e99596b1 100644 --- a/plugins/events-backend/src/service/hub/createEventBusRouter.ts +++ b/plugins/events-backend/src/service/hub/createEventBusRouter.ts @@ -160,7 +160,7 @@ export async function createEventBusRouter(options: { const topic = req.body.event.topic; const notifiedSubscribers = req.body.notifiedSubscribers; const result = await store.publish({ - params: { + event: { topic, eventPayload: req.body.event.payload, } as EventParams, diff --git a/plugins/events-backend/src/service/hub/types.ts b/plugins/events-backend/src/service/hub/types.ts index 3a4c8df9f8..0d363bec8b 100644 --- a/plugins/events-backend/src/service/hub/types.ts +++ b/plugins/events-backend/src/service/hub/types.ts @@ -18,7 +18,7 @@ import { EventParams } from '@backstage/plugin-events-node'; export type EventBusStore = { publish(options: { - params: EventParams; + event: EventParams; notifiedSubscribers?: string[]; }): Promise<{ eventId: string } | undefined>;