import type { GrowContext } from "../context"; import type { Log } from "../logger/log-entry"; import type { LogLevel } from "../logger/logger"; import type { CloudApi } from "./api"; import type { RouterInput } from "./trpc"; export type ApiEventRequest = RouterInput["events"]["process"]; export type ApiEvent = ApiEventRequest["events"][number]; export type ApiEventName = Pick["name"]; export type GetApiEventPayload = Extract["payload"]; export type ApiDeployStatusEvent = GetApiEventPayload<"deployStatus">; export type ApiRunStatusEvent = GetApiEventPayload<"runStatus">; export type ApiActionStatusEvent = ApiDeployStatusEvent | ApiRunStatusEvent; export type ApiActionStatusEventName = Extract; export type ApiActionStatusDetailState = ApiActionStatusEvent["status"]["state"]; export interface BufferedEventStreamParams { log: Log; maxLogLevel: LogLevel; grow: GrowContext; commandRunId: string; cloudApi: CloudApi; sessionId: string; } /** * Buffers events and log entries and periodically POSTs them to Garden Cloud or another Garden service. * * Subscribes to logger events once, in the constructor. * * Subscribes to Garden events via the connect method, since we need to subscribe to the event bus of * new Garden instances (and unsubscribe from events from the previously connected Garden instance, if * any) e.g. when config changes during a watch-mode command. */ export declare class BufferedEventStream { protected log: Log; protected maxLogLevel: LogLevel; protected commandRunId: string; private grow; private closed; private intervalId; private bufferedEvents; private bufferedLogEntries; private eventListeners; private logListener; protected intervalMsec: number; private flushFailCount; private maxBatchBytes; private cloudApi; private sessionId; constructor({ log, maxLogLevel, grow, commandRunId, cloudApi, sessionId }: BufferedEventStreamParams); isClosed(): boolean; startInterval(): void; stopInterval(): void; close(): Promise; private streamEvent; private streamLogEntry; private flushEvents; private flushLogEntries; /** * Flushes all events and log entries until none remain, and returns a promise that resolves when all of them * have been posted to their targets. */ flushAll(): Promise; flushBuffered(): Promise; /** * Split the given buffer into batches and clear the buffer. */ makeBatches(buffered: B[]): B[][]; /** * Adds buffered records (events or log entries) to a batch until none remain or until their combined size * exceeds `MAX_MATCH_BYTES`, and returns the batch. */ makeBatch(buffered: B[]): B[]; }