1 |
|
2 | import * as childProcess from "child_process";
|
3 | import { Message, PromiseResponseMessage } from "./provider";
|
4 | import { AsyncIterableQueue } from "./throttle";
|
5 | import { AnyFunction } from "./types";
|
6 | export declare const isGenerator: (fn: Function) => boolean;
|
7 | export declare const filename: string;
|
8 | export interface CallId {
|
9 | callId: string;
|
10 | }
|
11 | export interface Trampoline {
|
12 | trampoline: AnyFunction;
|
13 | }
|
14 | export interface TrampolineFactory {
|
15 | filename: string;
|
16 | makeTrampoline: (wrapper: Wrapper) => Trampoline;
|
17 | }
|
18 | export interface FunctionCall extends CallId {
|
19 | args: string;
|
20 | modulePath: string;
|
21 | name: string;
|
22 | ResponseQueueId: string;
|
23 | }
|
24 | export interface CallingContext {
|
25 | call: FunctionCall;
|
26 | startTime: number;
|
27 | logUrl?: string;
|
28 | executionId?: string;
|
29 | instanceId?: string;
|
30 | }
|
31 | export interface ModuleType {
|
32 | [name: string]: any;
|
33 | }
|
34 | export declare function createErrorResponse(err: any, { call, startTime, logUrl, executionId }: CallingContext): PromiseResponseMessage;
|
35 | export interface WrapperOptions {
|
36 | |
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 | wrapperLog?: (msg: string) => void;
|
44 | childProcess?: boolean;
|
45 | childProcessMemoryLimitMb?: number;
|
46 | childProcessTimeoutMs?: number;
|
47 | childProcessEnvironment?: {
|
48 | [key: string]: string;
|
49 | };
|
50 | childDir?: string;
|
51 | wrapperVerbose?: boolean;
|
52 | validateSerialization?: boolean;
|
53 | }
|
54 | export declare const WrapperOptionDefaults: Required<WrapperOptions>;
|
55 | declare type ErrorCallback = (err: Error) => Error;
|
56 | declare type MessageCallback = (msg: Message) => Promise<void>;
|
57 | export interface WrapperExecuteOptions {
|
58 | errorCallback?: ErrorCallback;
|
59 | onMessage: MessageCallback;
|
60 | measureCpuUsage?: boolean;
|
61 | }
|
62 | export declare class Wrapper {
|
63 | executing: boolean;
|
64 | protected verbose: boolean;
|
65 | protected funcs: ModuleType;
|
66 | protected child?: childProcess.ChildProcess;
|
67 | protected childPid?: number;
|
68 | protected log: (msg: string) => void;
|
69 | protected queue: AsyncIterableQueue<Message>;
|
70 | readonly options: Required<WrapperOptions>;
|
71 | protected monitoringTimer?: NodeJS.Timer;
|
72 | constructor(fModule: ModuleType, options?: WrapperOptions);
|
73 | protected lookupFunction(request: object): AnyFunction;
|
74 | protected stopCpuMonitoring(): void;
|
75 | protected startCpuMonitoring(pid: number, callId: string): void;
|
76 | stop(): void;
|
77 | execute(callingContext: CallingContext, { errorCallback, onMessage, measureCpuUsage }: WrapperExecuteOptions): Promise<void>;
|
78 | protected logLines: (msg: string) => void;
|
79 | protected setupChildProcess(): childProcess.ChildProcess;
|
80 | }
|
81 | export interface CpuMeasurement {
|
82 | stime: number;
|
83 | utime: number;
|
84 | elapsed: number;
|
85 | }
|
86 | export {};
|