fluxion-ts 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/index.d.ts +95 -114
- package/dist/index.mjs +717 -1533
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -166,9 +166,17 @@ Main `fluxion({...})` options:
|
|
|
166
166
|
- `dir`: dynamic directory (handler root)
|
|
167
167
|
- `host`: listen host
|
|
168
168
|
- `port`: listen port
|
|
169
|
+
- `metaPort`: primary meta API port (defaults to `port + 1`)
|
|
169
170
|
- `maxRequestBytes`: max request body size (returns 413 when exceeded)
|
|
170
171
|
- `logger`: `one-line` / `json-line` / custom function
|
|
171
172
|
|
|
173
|
+
## Meta APIs
|
|
174
|
+
|
|
175
|
+
Meta APIs are served by the primary process on `metaPort`:
|
|
176
|
+
|
|
177
|
+
- `GET /_fluxion/healthz`
|
|
178
|
+
- `GET /_fluxion/workers` (worker status + cpu/memory stats)
|
|
179
|
+
|
|
172
180
|
## Important
|
|
173
181
|
|
|
174
182
|
Legacy handler-level `db` declarations are removed:
|
package/dist/index.d.ts
CHANGED
|
@@ -1,126 +1,107 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
interface InjectionConfig {
|
|
2
|
+
/**
|
|
3
|
+
* Name that you can use to refer to this injected dependency in your handlers.
|
|
4
|
+
*/
|
|
5
|
+
name: string;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The `.mjs` path that exports the factory function to create the dependency instance.
|
|
9
|
+
*/
|
|
10
|
+
modulePath: string;
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
type
|
|
13
|
-
type LoggerOption = LoggerMode | LoggerSink;
|
|
12
|
+
|
|
13
|
+
type LoggerOption = 'one-line' | 'json-line' | InjectionConfig;
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Worker runtime tuning options.
|
|
17
17
|
*/
|
|
18
|
-
interface
|
|
19
|
-
|
|
20
|
-
* Request timeout in milliseconds.
|
|
21
|
-
*/
|
|
22
|
-
requestTimeoutMs: number;
|
|
23
|
-
/**
|
|
24
|
-
* Maximum concurrent requests allowed in the pool.
|
|
25
|
-
*/
|
|
26
|
-
maxInflight: number;
|
|
27
|
-
/**
|
|
28
|
-
* Soft heap threshold in MB. Idle worker may restart after crossing it.
|
|
29
|
-
*/
|
|
30
|
-
memorySoftLimitMb: number;
|
|
31
|
-
/**
|
|
32
|
-
* ! Hard heap threshold in MB. Worker is restarted once reached.
|
|
33
|
-
*/
|
|
34
|
-
memoryHardLimitMb: number;
|
|
35
|
-
/**
|
|
36
|
-
* Memory telemetry interval in milliseconds.
|
|
37
|
-
*/
|
|
38
|
-
memorySampleIntervalMs: number;
|
|
39
|
-
/**
|
|
40
|
-
* ! V8 old-generation limit per worker in MB.
|
|
41
|
-
*/
|
|
42
|
-
maxOldGenerationSizeMb: number;
|
|
43
|
-
/**
|
|
44
|
-
* ! V8 young-generation limit per worker in MB.
|
|
45
|
-
*/
|
|
46
|
-
maxYoungGenerationSizeMb: number;
|
|
47
|
-
/**
|
|
48
|
-
* Worker stack size in MB.
|
|
49
|
-
*/
|
|
50
|
-
stackSizeMb: number;
|
|
51
|
-
/**
|
|
52
|
-
* ! Maximum response payload bytes allowed from worker to main thread.
|
|
53
|
-
*/
|
|
54
|
-
maxResponseBytes: number;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Custom worker item used by `workerStrategy`.
|
|
58
|
-
*/
|
|
59
|
-
interface WorkerStrategyCustomItem extends Partial<ExecutorOptions> {
|
|
60
|
-
/**
|
|
61
|
-
* Stable worker id.
|
|
62
|
-
*/
|
|
63
|
-
id: string;
|
|
64
|
-
/**
|
|
65
|
-
* Database names this worker can access.
|
|
66
|
-
*/
|
|
67
|
-
db: string[];
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Worker strategy selector.
|
|
71
|
-
*/
|
|
72
|
-
type WorkerStrategy = 'all' | WorkerStrategyCustomItem[];
|
|
18
|
+
interface WorkerOptions {
|
|
19
|
+
maxWorkerCount: number;
|
|
73
20
|
|
|
74
|
-
/**
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Request timeout in milliseconds.
|
|
23
|
+
*/
|
|
24
|
+
requestTimeoutMs: number;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Maximum concurrent requests allowed in the pool.
|
|
28
|
+
*/
|
|
29
|
+
maxInflight: number;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Soft heap threshold in MB. Idle worker may restart after crossing it.
|
|
33
|
+
*/
|
|
34
|
+
memorySoftLimitMb: number;
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* ! Hard heap threshold in MB. Worker is restarted once reached.
|
|
38
|
+
*/
|
|
39
|
+
memoryHardLimitMb: number;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Memory telemetry interval in milliseconds.
|
|
43
|
+
*/
|
|
44
|
+
memorySampleIntervalMs: number;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* ! V8 old-generation limit per worker in MB.
|
|
48
|
+
*/
|
|
49
|
+
maxOldGenerationSizeMb: number;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* ! V8 young-generation limit per worker in MB.
|
|
53
|
+
*/
|
|
54
|
+
maxYoungGenerationSizeMb: number;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Worker stack size in MB.
|
|
58
|
+
*/
|
|
59
|
+
stackSizeMb: number;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* ! Maximum response payload bytes allowed from worker to main thread.
|
|
63
|
+
*/
|
|
64
|
+
maxResponseBytes: number;
|
|
82
65
|
}
|
|
83
|
-
|
|
84
|
-
* User-provided database config input.
|
|
85
|
-
*/
|
|
86
|
-
type FluxionDatabaseInput = string | FluxionDatabaseConfig;
|
|
66
|
+
|
|
87
67
|
interface FluxionOptions {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
68
|
+
/**
|
|
69
|
+
* The directory where dynamic files (e.g. uploaded files) will be stored. It will be created if it doesn't exist.
|
|
70
|
+
* It is recommended to use an empty directory that is not used for any other purpose, to avoid potential conflicts or security issues.
|
|
71
|
+
*/
|
|
72
|
+
dir: string;
|
|
73
|
+
|
|
74
|
+
host: string;
|
|
75
|
+
|
|
76
|
+
port: number;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Port listened by primary process for meta APIs.
|
|
80
|
+
* Defaults to `port + 1`.
|
|
81
|
+
*/
|
|
82
|
+
metaPort?: number;
|
|
83
|
+
|
|
84
|
+
injections?: InjectionConfig[];
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Base worker runtime option overrides.
|
|
88
|
+
*/
|
|
89
|
+
workerOptions?: Partial<WorkerOptions>;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Maximum request body bytes accepted by dynamic handlers.
|
|
93
|
+
* Requests larger than this limit will return 413.
|
|
94
|
+
*/
|
|
95
|
+
maxRequestBytes?: number;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Logger output mode or custom logger sink.
|
|
99
|
+
* Defaults to `one-line`.
|
|
100
|
+
*/
|
|
101
|
+
logger?: LoggerOption;
|
|
122
102
|
}
|
|
123
|
-
|
|
103
|
+
|
|
104
|
+
declare function fluxion(options: FluxionOptions): Promise<void>;
|
|
124
105
|
|
|
125
106
|
export { fluxion };
|
|
126
107
|
export type { FluxionOptions };
|