effect-cf 0.25.2 → 0.25.3
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/CHANGELOG.md +6 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +6 -6
- package/package.json +1 -1
- package/src/CloudflareOtlp.ts +3 -2
- package/src/DurableObject.ts +16 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# effect-cf
|
|
2
2
|
|
|
3
|
+
## 0.25.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#92](https://github.com/danieljvdm/effect-cf/pull/92) [`f174800`](https://github.com/danieljvdm/effect-cf/commit/f1748004e463d4e54c22e7c77fdea68ff8de7f82) Thanks [@danieljvdm](https://github.com/danieljvdm)! - Flush configured OTLP telemetry after Durable Object alarm handlers, including failed alarms, so buffered telemetry is exported consistently with fetch and native RPC handlers.
|
|
8
|
+
|
|
3
9
|
## 0.25.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1116,6 +1116,12 @@ interface DurableObjectOptions<RRuntime, REvent = never, EventLayerError = never
|
|
|
1116
1116
|
* the Durable Object's single managed runtime boundary.
|
|
1117
1117
|
*/
|
|
1118
1118
|
readonly alarms?: Effect.Effect<unknown, unknown, HandlerContext<RRuntime | REvent>>;
|
|
1119
|
+
/**
|
|
1120
|
+
* Optional raw alarm handler.
|
|
1121
|
+
*
|
|
1122
|
+
* After every invocation, the configured OTLP flusher is scheduled through
|
|
1123
|
+
* `DurableObjectState.waitUntil`, including when the handler fails.
|
|
1124
|
+
*/
|
|
1119
1125
|
readonly alarm?: (alarmInfo?: globalThis.AlarmInvocationInfo) => Effect.Effect<void, unknown, HandlerContext<RRuntime | REvent>>;
|
|
1120
1126
|
readonly webSocketMessage?: (socket: DurableWebSocket, message: string | ArrayBuffer) => Effect.Effect<void, unknown, HandlerContext<RRuntime | REvent>>;
|
|
1121
1127
|
readonly webSocketClose?: (socket: DurableWebSocket, code: number, reason: string, wasClean: boolean) => Effect.Effect<void, unknown, HandlerContext<RRuntime | REvent>>;
|
package/dist/index.mjs
CHANGED
|
@@ -683,8 +683,9 @@ const layer$14 = Layer.sync(CacheStorage, () => makeClient$11(caches));
|
|
|
683
683
|
*
|
|
684
684
|
* Every layer exposes {@link OtlpExporter.Flusher}, which drains buffered
|
|
685
685
|
* telemetry on demand. Cloudflare isolates can freeze before the periodic
|
|
686
|
-
* export interval fires. Effect-backed Worker fetch handlers
|
|
687
|
-
* Durable Object native RPC handlers
|
|
686
|
+
* export interval fires. Effect-backed Worker fetch handlers, Worker or
|
|
687
|
+
* Durable Object native RPC handlers, and Durable Object alarm handlers
|
|
688
|
+
* schedule this flusher automatically.
|
|
688
689
|
* Flush or scheduling failures do not replace the handler outcome and emit
|
|
689
690
|
* only bounded framework diagnostics without attaching the foreign cause.
|
|
690
691
|
* Other entrypoint lifecycles can flush explicitly or hand the flush to their
|
|
@@ -2118,12 +2119,11 @@ const make$7 = (layer, options = {}) => {
|
|
|
2118
2119
|
alarm(alarmInfo) {
|
|
2119
2120
|
const logicalAlarms = options.alarms?.pipe(Effect.asVoid);
|
|
2120
2121
|
const rawAlarm = options.alarm?.(alarmInfo);
|
|
2121
|
-
|
|
2122
|
+
const alarmEffect = logicalAlarms !== void 0 && rawAlarm !== void 0 ? Effect.gen(function* () {
|
|
2122
2123
|
yield* logicalAlarms;
|
|
2123
2124
|
yield* rawAlarm;
|
|
2124
|
-
})
|
|
2125
|
-
if (
|
|
2126
|
-
if (rawAlarm !== void 0) return this[RunSymbol](rawAlarm);
|
|
2125
|
+
}) : logicalAlarms ?? rawAlarm;
|
|
2126
|
+
if (alarmEffect !== void 0) return this[RunSymbol](alarmEffect.pipe(Effect.onExit(() => scheduleTelemetryFlush)));
|
|
2127
2127
|
}
|
|
2128
2128
|
webSocketMessage(socket, message) {
|
|
2129
2129
|
if (options.webSocketMessage !== void 0) return this[RunSymbol](options.webSocketMessage(fromWebSocket(socket), message));
|
package/package.json
CHANGED
package/src/CloudflareOtlp.ts
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Every layer exposes {@link OtlpExporter.Flusher}, which drains buffered
|
|
5
5
|
* telemetry on demand. Cloudflare isolates can freeze before the periodic
|
|
6
|
-
* export interval fires. Effect-backed Worker fetch handlers
|
|
7
|
-
* Durable Object native RPC handlers
|
|
6
|
+
* export interval fires. Effect-backed Worker fetch handlers, Worker or
|
|
7
|
+
* Durable Object native RPC handlers, and Durable Object alarm handlers
|
|
8
|
+
* schedule this flusher automatically.
|
|
8
9
|
* Flush or scheduling failures do not replace the handler outcome and emit
|
|
9
10
|
* only bounded framework diagnostics without attaching the foreign cause.
|
|
10
11
|
* Other entrypoint lifecycles can flush explicitly or hand the flush to their
|
package/src/DurableObject.ts
CHANGED
|
@@ -121,6 +121,12 @@ export interface DurableObjectOptions<
|
|
|
121
121
|
* the Durable Object's single managed runtime boundary.
|
|
122
122
|
*/
|
|
123
123
|
readonly alarms?: Effect.Effect<unknown, unknown, HandlerContext<RRuntime | REvent>>;
|
|
124
|
+
/**
|
|
125
|
+
* Optional raw alarm handler.
|
|
126
|
+
*
|
|
127
|
+
* After every invocation, the configured OTLP flusher is scheduled through
|
|
128
|
+
* `DurableObjectState.waitUntil`, including when the handler fails.
|
|
129
|
+
*/
|
|
124
130
|
readonly alarm?: (
|
|
125
131
|
alarmInfo?: globalThis.AlarmInvocationInfo,
|
|
126
132
|
) => Effect.Effect<void, unknown, HandlerContext<RRuntime | REvent>>;
|
|
@@ -204,22 +210,16 @@ export const make = <
|
|
|
204
210
|
alarm(alarmInfo?: globalThis.AlarmInvocationInfo): Promise<void> | void {
|
|
205
211
|
const logicalAlarms = options.alarms?.pipe(Effect.asVoid);
|
|
206
212
|
const rawAlarm = options.alarm?.(alarmInfo);
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
if (logicalAlarms !== undefined) {
|
|
218
|
-
return this[RunSymbol](logicalAlarms);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
if (rawAlarm !== undefined) {
|
|
222
|
-
return this[RunSymbol](rawAlarm);
|
|
213
|
+
const alarmEffect =
|
|
214
|
+
logicalAlarms !== undefined && rawAlarm !== undefined
|
|
215
|
+
? Effect.gen(function* () {
|
|
216
|
+
yield* logicalAlarms;
|
|
217
|
+
yield* rawAlarm;
|
|
218
|
+
})
|
|
219
|
+
: (logicalAlarms ?? rawAlarm);
|
|
220
|
+
|
|
221
|
+
if (alarmEffect !== undefined) {
|
|
222
|
+
return this[RunSymbol](alarmEffect.pipe(Effect.onExit(() => scheduleTelemetryFlush)));
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
|