effect-cf 0.51.0 → 0.52.0
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
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# effect-cf
|
|
2
2
|
|
|
3
|
+
## 0.52.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#201](https://github.com/danieljvdm/effect-cf/pull/201) [`346d424`](https://github.com/danieljvdm/effect-cf/commit/346d42473a9ef76f85bd2bd7e3ebaa6a1467a87f) Thanks [@danieljvdm](https://github.com/danieljvdm)! - Add `ContainerTcpPort.connectScoped` to close native TCP sockets when their Effect scope ends. Cleanup awaits `socket.close()` on success, failure, or interruption and preserves close failures as `ContainerError` defects. The existing `connect` method remains caller-owned.
|
|
8
|
+
|
|
3
9
|
## 0.51.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -92,6 +92,8 @@ interface ContainerTcpPort {
|
|
|
92
92
|
readonly proxy: (request: Request) => Effect.Effect<Response, ContainerError>;
|
|
93
93
|
/** The caller owns the returned socket and must close it. */
|
|
94
94
|
readonly connect: (...args: Parameters<globalThis.Fetcher["connect"]>) => Effect.Effect<ReturnType<globalThis.Fetcher["connect"]>, ContainerError>;
|
|
95
|
+
/** Closes the socket when the scope ends, awaiting cleanup and preserving close failures as defects. */
|
|
96
|
+
readonly connectScoped: (...args: Parameters<globalThis.Fetcher["connect"]>) => Effect.Effect<ReturnType<globalThis.Fetcher["connect"]>, ContainerError, Scope.Scope>;
|
|
95
97
|
}
|
|
96
98
|
/** Direct container control inside a Durable Object; lifecycle policy belongs to the application. */
|
|
97
99
|
interface DurableObjectContainerService {
|
|
@@ -99,6 +99,7 @@ const fromTcpPort = (port) => {
|
|
|
99
99
|
signal: callerSignal === null || callerSignal === void 0 ? signal : AbortSignal.any([callerSignal, signal])
|
|
100
100
|
});
|
|
101
101
|
});
|
|
102
|
+
const connect = (...args) => attempt("getTcpPort.connect", () => port.connect(...args));
|
|
102
103
|
return {
|
|
103
104
|
raw: port,
|
|
104
105
|
fetch,
|
|
@@ -107,7 +108,8 @@ const fromTcpPort = (port) => {
|
|
|
107
108
|
url.protocol = "http:";
|
|
108
109
|
return new Request(url, request);
|
|
109
110
|
}).pipe(Effect.flatMap((forwarded) => fetch(forwarded))),
|
|
110
|
-
connect
|
|
111
|
+
connect,
|
|
112
|
+
connectScoped: (...args) => Effect.acquireRelease(connect(...args), (socket) => attemptPromise("getTcpPort.close", () => socket.close()).pipe(Effect.orDie))
|
|
111
113
|
};
|
|
112
114
|
};
|
|
113
115
|
/** Wraps `ctx.container` without starting it or taking ownership of its lifecycle. */
|
package/package.json
CHANGED
|
@@ -102,6 +102,10 @@ export interface ContainerTcpPort {
|
|
|
102
102
|
readonly connect: (
|
|
103
103
|
...args: Parameters<globalThis.Fetcher["connect"]>
|
|
104
104
|
) => Effect.Effect<ReturnType<globalThis.Fetcher["connect"]>, ContainerError>;
|
|
105
|
+
/** Closes the socket when the scope ends, awaiting cleanup and preserving close failures as defects. */
|
|
106
|
+
readonly connectScoped: (
|
|
107
|
+
...args: Parameters<globalThis.Fetcher["connect"]>
|
|
108
|
+
) => Effect.Effect<ReturnType<globalThis.Fetcher["connect"]>, ContainerError, Scope.Scope>;
|
|
105
109
|
}
|
|
106
110
|
|
|
107
111
|
/** Direct container control inside a Durable Object; lifecycle policy belongs to the application. */
|
|
@@ -248,6 +252,9 @@ const fromTcpPort = (port: globalThis.Fetcher): ContainerTcpPort => {
|
|
|
248
252
|
});
|
|
249
253
|
});
|
|
250
254
|
|
|
255
|
+
const connect: ContainerTcpPort["connect"] = (...args) =>
|
|
256
|
+
attempt("getTcpPort.connect", () => port.connect(...args));
|
|
257
|
+
|
|
251
258
|
return {
|
|
252
259
|
raw: port,
|
|
253
260
|
fetch,
|
|
@@ -259,7 +266,11 @@ const fromTcpPort = (port: globalThis.Fetcher): ContainerTcpPort => {
|
|
|
259
266
|
|
|
260
267
|
return new Request(url, request);
|
|
261
268
|
}).pipe(Effect.flatMap((forwarded) => fetch(forwarded))),
|
|
262
|
-
connect
|
|
269
|
+
connect,
|
|
270
|
+
connectScoped: (...args) =>
|
|
271
|
+
Effect.acquireRelease(connect(...args), (socket) =>
|
|
272
|
+
attemptPromise("getTcpPort.close", () => socket.close()).pipe(Effect.orDie),
|
|
273
|
+
),
|
|
263
274
|
};
|
|
264
275
|
};
|
|
265
276
|
|