Apply suggestions from code review

Co-authored-by: Patrick Jungermann <patrick.jungermann@gmail.com>
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2024-09-12 20:46:30 +02:00
parent 0de66764e4
commit b9daa73fed
3 changed files with 7 additions and 7 deletions
@@ -233,7 +233,7 @@ describe('eventsPlugin', () => {
events: [{ topic: 'test', payload: { n: 1 } }],
});
// Two clients for subscriber 2, only one gets the event
// Two clients for subscriber 2, only one gets the event
const res1 = helper.readEvents('tester-2');
const res2 = helper.readEvents('tester-2');
@@ -261,7 +261,7 @@ describe('eventsPlugin', () => {
);
it.each(databases.eachSupportedId())(
'should should not notify subscribers that have already consumed the event, %p',
'should not notify subscribers that have already consumed the event, %p',
async databaseId => {
const backend = await startTestBackend({
features: [eventsPlugin(), await mockKnexFactory(databaseId)],
@@ -296,7 +296,7 @@ describe('eventsPlugin', () => {
await helper.readEvents('tester-1').expect(200, {
events: [{ topic: 'test', payload: { for: 'tester-1' } }],
});
// Single client for subscriber 1 gets the event
// Single client for subscriber 2 gets the event
await helper.readEvents('tester-2').expect(200, {
events: [{ topic: 'test', payload: { for: 'tester-2' } }],
});
@@ -316,7 +316,7 @@ describe('eventsPlugin', () => {
// 2 subscribers
await helper.subscribe('tester', ['test']).expect(201);
// A single event for each subscriber, that should not be sent to the other one
// A sequence of events published one at a time
for (let n = 0; n < 15; ++n) {
await helper.publish('test', { n }).expect(201);
}
@@ -26,7 +26,7 @@ import {
import { ForwardedError, NotFoundError } from '@backstage/errors';
import { HumanDuration, durationToMilliseconds } from '@backstage/types';
const WINDOW_SIZE_DEFAULT = 10000;
const WINDOW_SIZE_DEFAULT = 10_000;
const WINDOW_MIN_AGE_DEFAULT = { minutes: 10 };
const WINDOW_MAX_AGE_DEFAULT = { days: 1 };
@@ -203,14 +203,14 @@ export async function createEventBusRouter(options: {
// By setting up the listener first we make sure we don't miss any events
// that are published while reading. If an event is published we'll receive
// a notification, which depending on the outcome of the read we may ignore
// a notification, which we may ignore depending on the outcome of the read
const listener = await store.setupListener(id, {
signal: controller.signal,
});
// By timing out requests we make sure they don't stall or that events get stuck.
// For the caller there's no difference between a timeout and a
// notifications, either way they should try reading again.
// notification, either way they should try reading again.
const timeout = setTimeout(() => {
controller.abort();
}, notifyTimeoutMs);