mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 19:07:08 +00:00
🤖 Merge PR #45311 Update lightship types to 6.1 by @janslow
This commit is contained in:
parent
bbe9e4c6f9
commit
b231833da8
64
types/lightship/index.d.ts
vendored
64
types/lightship/index.d.ts
vendored
@ -1,6 +1,6 @@
|
||||
// Type definitions for lightship 4.0
|
||||
// Type definitions for lightship 6.1
|
||||
// Project: https://github.com/gajus/lightship#readme
|
||||
// Definitions by: Scott Chang <https://github.com/purmac>, Karoun Kasraie <https://github.com/karoun>
|
||||
// Definitions by: Scott Chang <https://github.com/purmac>, Karoun Kasraie <https://github.com/karoun>, Jay Anslow <https://github.com/janslow>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
/// <reference types="node" />
|
||||
|
||||
@ -10,7 +10,7 @@ import { Server } from 'http';
|
||||
* A teardown function called when shutdown is initialized.
|
||||
* @param userConfiguration User configuration object
|
||||
*/
|
||||
export function createLightship(userConfiguration?: UserConfigurationType): LightshipType;
|
||||
export function createLightship(configuration?: ConfigurationInputType): LightshipType;
|
||||
|
||||
export type BeaconContextType = object;
|
||||
|
||||
@ -18,22 +18,49 @@ export interface BeaconControllerType {
|
||||
die: () => Promise<void>;
|
||||
}
|
||||
|
||||
export interface UserConfigurationType {
|
||||
/* Run Lightship in local mode when Kubernetes is not detected. Default: true. */
|
||||
export interface ConfigurationInputType {
|
||||
/**
|
||||
* Run Lightship in local mode when Kubernetes is not detected.
|
||||
* @default true.
|
||||
*/
|
||||
detectKubernetes?: boolean;
|
||||
/* The port on which the Lightship service listens. This port must be different than your main service port, if any. The default port is 9000. */
|
||||
/**
|
||||
* A number of milliseconds before forcefull termination if process does not gracefully exit.
|
||||
* The timer starts when `lightship.shutdown()` is called. This includes the time allowed to live beacons.
|
||||
* @default 60_000
|
||||
*/
|
||||
gracefulShutdownTimeout?: number;
|
||||
/**
|
||||
* The port on which the Lightship service listens. This port must be different than your main service port, if any.
|
||||
* @default 9000
|
||||
*/
|
||||
port?: number;
|
||||
/* An a array of [signal events]{@link https://nodejs.org/api/process.html#process_signal_events}. Default: [SIGTERM, SIGHUP, SIGINT]. */
|
||||
/**
|
||||
* A number of milliseconds before forceful termination if shutdown handlers do not complete. The timer starts when the first shutdown handler is called.
|
||||
* @default 5000
|
||||
*/
|
||||
shutdownHandlerTimeout?: number;
|
||||
/**
|
||||
* An a array of [signal events](https://nodejs.org/api/process.html#process_signal_events).
|
||||
* @default [SIGTERM, SIGHUP, SIGINT].
|
||||
*/
|
||||
signals?: ReadonlyArray<NodeJS.Signals>;
|
||||
/* A number of milliseconds before forceful termination. Default: 60000. */
|
||||
timeout?: number;
|
||||
/**
|
||||
* Method used to terminate Node.js process
|
||||
* @default `() => { process.exit(1) };`
|
||||
*/
|
||||
terminate?: () => void;
|
||||
}
|
||||
|
||||
export interface LightshipType {
|
||||
createBeacon: (context?: BeaconContextType) => BeaconControllerType;
|
||||
/* Checks if server is in SERVER_IS_READY state */
|
||||
/**
|
||||
* Checks if server is in SERVER_IS_READY state.
|
||||
*/
|
||||
isServerReady: () => boolean;
|
||||
/* Checks if server is in SERVER_IS_SHUTTING_DOWN state */
|
||||
/**
|
||||
* Checks if server is in SERVER_IS_SHUTTING_DOWN state.
|
||||
*/
|
||||
isServerShuttingDown: () => boolean;
|
||||
/**
|
||||
* Registers teardown functions that are called when shutdown is initialized.
|
||||
@ -42,12 +69,21 @@ export interface LightshipType {
|
||||
*/
|
||||
registerShutdownHandler: (shutdownHandler: ShutdownHandlerType) => void;
|
||||
readonly server: Server;
|
||||
/* Changes server state to SERVER_IS_SHUTTING_DOWN and initialises the shutdown of the application.*/
|
||||
/**
|
||||
* Changes server state to SERVER_IS_SHUTTING_DOWN and initialises the shutdown of the application.
|
||||
*/
|
||||
shutdown: () => Promise<void>;
|
||||
/* Changes server state to SERVER_IS_NOT_READY. */
|
||||
/**
|
||||
* Changes server state to SERVER_IS_NOT_READY.
|
||||
*/
|
||||
signalNotReady: () => void;
|
||||
/* Changes server state to SERVER_IS_READY. */
|
||||
/**
|
||||
* Changes server state to SERVER_IS_READY.
|
||||
*/
|
||||
signalReady: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* A teardown function called when shutdown is initialized.
|
||||
*/
|
||||
export type ShutdownHandlerType = () => Promise<void> | void;
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
import { createLightship, BeaconControllerType, UserConfigurationType, LightshipType } from 'lightship';
|
||||
import { createLightship, BeaconControllerType, ConfigurationInputType, LightshipType } from 'lightship';
|
||||
|
||||
const lightshipParams: UserConfigurationType = {
|
||||
const lightshipParams: ConfigurationInputType = {
|
||||
detectKubernetes: false,
|
||||
timeout: 1000,
|
||||
gracefulShutdownTimeout: 5_000,
|
||||
shutdownHandlerTimeout: 2_000,
|
||||
port: 50,
|
||||
signals: ['SIGBUS'],
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user