@@ -29,6 +29,14 @@ export enum RuntimeWorkerState {
29
29
FINISHED = "FINISHED" ,
30
30
}
31
31
32
+ /**
33
+ * Given no trigger key, worker is given this special key.
34
+ *
35
+ * This is useful when running the Functions Emulator in debug mode
36
+ * where single process shared amongst all triggers.
37
+ */
38
+ const FREE_WORKER_KEY = "~free~" ;
39
+
32
40
export class RuntimeWorker {
33
41
readonly id : string ;
34
42
readonly triggerKey : string ;
@@ -46,7 +54,7 @@ export class RuntimeWorker {
46
54
readonly timeoutSeconds ?: number
47
55
) {
48
56
this . id = uuid . v4 ( ) ;
49
- this . triggerKey = triggerId || "~free~" ;
57
+ this . triggerKey = triggerId || FREE_WORKER_KEY ;
50
58
this . runtime = runtime ;
51
59
52
60
const childProc = this . runtime . process ;
@@ -118,14 +126,14 @@ export class RuntimeWorker {
118
126
}
119
127
120
128
request ( req : http . RequestOptions , resp : http . ServerResponse , body ?: unknown ) : Promise < void > {
121
- if ( this . triggerKey !== "~free~" ) {
129
+ if ( this . triggerKey !== FREE_WORKER_KEY ) {
122
130
this . logInfo ( `Beginning execution of "${ this . triggerKey } "` ) ;
123
131
}
124
132
const startHrTime = process . hrtime ( ) ;
125
133
126
134
this . state = RuntimeWorkerState . BUSY ;
127
135
const onFinish = ( ) : void => {
128
- if ( this . triggerKey !== "~free~" ) {
136
+ if ( this . triggerKey !== FREE_WORKER_KEY ) {
129
137
const elapsedHrTime = process . hrtime ( startHrTime ) ;
130
138
this . logInfo (
131
139
`Finished "${ this . triggerKey } " in ${
0 commit comments