mirror of
https://github.com/fosrl/pangolin.git
synced 2026-04-01 07:26:38 +00:00
Handle backlog better
This commit is contained in:
@@ -15,6 +15,7 @@ import { Request, Response, NextFunction } from "express";
|
||||
import { z } from "zod";
|
||||
import { db } from "@server/db";
|
||||
import { eventStreamingDestinations } from "@server/db";
|
||||
import { logStreamingManager } from "#private/lib/logStreaming";
|
||||
import response from "@server/lib/response";
|
||||
import HttpCode from "@server/types/HttpCode";
|
||||
import createHttpError from "http-errors";
|
||||
@@ -106,6 +107,19 @@ export async function createEventStreamingDestination(
|
||||
})
|
||||
.returning();
|
||||
|
||||
// Seed cursors at the current max row id for every log type so this
|
||||
// destination only receives events written *after* it was created.
|
||||
// Fire-and-forget: a failure here is non-fatal; the manager has a lazy
|
||||
// fallback that will seed at the next poll if these rows are missing.
|
||||
logStreamingManager
|
||||
.initializeCursorsForDestination(destination.destinationId, orgId)
|
||||
.catch((err) =>
|
||||
logger.error(
|
||||
"createEventStreamingDestination: failed to initialise streaming cursors",
|
||||
err
|
||||
)
|
||||
);
|
||||
|
||||
return response<CreateEventStreamingDestinationResponse>(res, {
|
||||
data: {
|
||||
destinationId: destination.destinationId
|
||||
|
||||
Reference in New Issue
Block a user