events-backend: made some names in EventBusStore more explicit

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-09-13 09:15:29 +02:00
parent d75fdf178e
commit ab0afa9bac
4 changed files with 8 additions and 8 deletions
@@ -350,7 +350,7 @@ export class DatabaseEventBusStore implements EventBusStore {
async publish(options: {
params: EventParams;
consumedBy?: string[];
}): Promise<{ id: string } | undefined> {
}): Promise<{ eventId: string } | undefined> {
const topic = options.params.topic;
const consumedBy = options.consumedBy ?? [];
// This query inserts a new event into the database, but only if there are
@@ -410,7 +410,7 @@ export class DatabaseEventBusStore implements EventBusStore {
);
}
return { id };
return { eventId: id };
}
async upsertSubscription(id: string, topics: string[]): Promise<void> {
@@ -33,7 +33,7 @@ export class MemoryEventBusStore implements EventBusStore {
async publish(options: {
params: EventParams;
consumedBy: string[];
}): Promise<{ id: string } | undefined> {
}): Promise<{ eventId: string } | undefined> {
const topic = options.params.topic;
const consumedBy = new Set(options.consumedBy);
@@ -57,7 +57,7 @@ export class MemoryEventBusStore implements EventBusStore {
this.#listeners.delete(listener);
}
}
return { id: String(nextSeq) };
return { eventId: String(nextSeq) };
}
#getMaxSeq() {
@@ -167,7 +167,7 @@ export async function createEventBusRouter(options: {
consumedBy: req.body.consumedBy,
});
if (result) {
logger.info(`Published event to '${topic}' with ID '${result.id}'`, {
logger.info(`Published event to '${topic}' with ID '${result.eventId}'`, {
subject: credentials.principal.subject,
});
res.status(201).end();
@@ -20,11 +20,11 @@ export type EventBusStore = {
publish(options: {
params: EventParams;
consumedBy?: string[];
}): Promise<{ id: string } | undefined>;
}): Promise<{ eventId: string } | undefined>;
upsertSubscription(id: string, topics: string[]): Promise<void>;
upsertSubscription(subscriptionId: string, topics: string[]): Promise<void>;
readSubscription(id: string): Promise<{ events: EventParams[] }>;
readSubscription(subscriptionId: string): Promise<{ events: EventParams[] }>;
setupListener(
subscriptionId: string,