open-lineage-client
Version:
TypeScript/JavaScript client for creating and sending OpenLineage standard events.
69 lines (68 loc) • 2.78 kB
TypeScript
import { AxiosRequestConfig, AxiosResponse } from 'axios';
import { BaseEvent } from '../events/BaseEvent.js';
import { Transport } from './TransportInterface.js';
import { TransportConfig } from './Factory.js';
/**
* Configuration for HTTP transport.
*/
export declare class HttpConfig {
url: string;
options: AxiosRequestConfig;
token: string | null;
maxRetries: number;
initialRetryDelay: number;
maxRetryDelay: number;
retryStatusCodes: number[];
/**
* Constructs an HttpConfig instance.
* @param url - The URL for the HTTP transport.
* @param options - Additional Axios request options.
* @param token - Optional authorization token.
* @param maxRetries - Maximum number of retry attempts (default: 3).
* @param initialRetryDelay - Initial delay in milliseconds before retrying (default: 1000).
* @param maxRetryDelay - Maximum delay in milliseconds between retries (default: 30000).
* @param retryStatusCodes - HTTP status codes that should trigger a retry (default: [408, 429, 500, 502, 503, 504]).
*/
constructor(url: string, options?: AxiosRequestConfig, token?: string | null, maxRetries?: number, initialRetryDelay?: number, maxRetryDelay?: number, retryStatusCodes?: number[]);
}
/**
* HTTP transport implementation for emitting events.
*/
export declare class HttpTransport implements Transport {
private url;
private options;
private maxRetries;
private initialRetryDelay;
private maxRetryDelay;
private retryStatusCodes;
/**
* Constructs an HttpTransport instance.
* @param config - The HTTP configuration.
*/
constructor(config: HttpConfig);
/**
* Calculates the delay for the next retry attempt using exponential backoff with jitter.
* @param retryCount - The current retry attempt number (0-based).
* @returns The delay in milliseconds before the next retry.
*/
private calculateRetryDelay;
/**
* Determines if a request should be retried based on the error.
* @param error - The error from the failed request.
* @returns True if the request should be retried, false otherwise.
*/
private shouldRetry;
/**
* Emits an event to the configured HTTP endpoint with retry logic.
* @param event - The event to emit.
* @returns A promise that resolves with the Axios response.
*/
emit<T = AxiosResponse<unknown, unknown>>(event: BaseEvent): Promise<T>;
/**
* Creates an HttpTransport instance from a configuration object.
* @param config - The transport configuration.
* @returns A new HttpTransport instance.
* @throws {Error} If the configuration is invalid.
*/
static fromFile(config: TransportConfig): HttpTransport;
}