@natsail/effect 0.0.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/LICENSE +201 -0
- package/README.md +48 -0
- package/dist/index.d.ts +79 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +154 -0
- package/dist/index.js.map +1 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Do not include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 The NATSail Authors
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @natsail/effect
|
|
2
|
+
|
|
3
|
+
`@natsail/effect` gives Effect programs one scoped NATSail service, typed failures, cancellable event Streams, and reference-counted shared-session Streams.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
pnpm add effect @natsail/core @natsail/session @natsail/effect
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
The package targets stable Effect v3. It does not create a second connection, retry loop, checkpoint system, or consumer lifecycle. NATSail still owns those policies; Effect owns dependency injection, structured concurrency, interruption, and scope finalization.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { Effect, Stream } from 'effect'
|
|
13
|
+
|
|
14
|
+
import { createNatsRuntime } from '@natsail/core'
|
|
15
|
+
import { Natsail, makeNatsailScopedLayer } from '@natsail/effect'
|
|
16
|
+
import { createSessionRegistry } from '@natsail/session'
|
|
17
|
+
|
|
18
|
+
const NatsLive = makeNatsailScopedLayer(
|
|
19
|
+
Effect.sync(() => ({
|
|
20
|
+
runtime: createNatsRuntime({ connect: connectToNats }),
|
|
21
|
+
sessions: createSessionRegistry({ idleCloseMs: 250 }),
|
|
22
|
+
}))
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
const program = Effect.gen(function* () {
|
|
26
|
+
const nats = yield* Natsail
|
|
27
|
+
|
|
28
|
+
yield* nats.publish('chat.room.123', encodedMessage)
|
|
29
|
+
|
|
30
|
+
yield* nats
|
|
31
|
+
.sessionValues(conversationDefinition)
|
|
32
|
+
.pipe(Stream.runForEach((conversation) => Effect.log(conversation)))
|
|
33
|
+
}).pipe(Effect.provide(NatsLive))
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`makeNatsailScopedLayer()` closes the session registry and runtime when the Layer scope exits, including failure or fiber interruption. `makeNatsailLayer()` supplies application-owned objects without closing them.
|
|
37
|
+
|
|
38
|
+
`sessionSnapshots()` and `sessionValues()` are cold Streams. Each Effect consumer retains one registry handle; consumers of the same validated definition still share one underlying NATS source. The handle is released whenever the stream completes, fails, or is interrupted.
|
|
39
|
+
|
|
40
|
+
Session Streams queue at most 32 snapshots by default. Overflow fails with `NatsailStreamBufferOverflowError` instead of silently losing state. Applications may choose `dropping`, `sliding`, a different bound, or an explicit `unbounded` buffer.
|
|
41
|
+
|
|
42
|
+
`NatsailOperationError` covers Promise operations and event iterators. `NatsailSessionError` distinguishes session acquisition from source failure. Both retain the original cause for tagged Effect recovery.
|
|
43
|
+
|
|
44
|
+
The service exposes `runtime` and `sessions` as escape hatches. Advanced nats.js, JetStream manager, explicit-ack processor, and custom session operations remain available without leaving the Layer-owned lifecycle.
|
|
45
|
+
|
|
46
|
+
## License
|
|
47
|
+
|
|
48
|
+
Apache-2.0
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Context, Effect, Layer, Stream } from 'effect';
|
|
2
|
+
import type { CoreRequestOptions, NatsConnection, NatsRuntime, NatsRuntimeEvent, NatsRuntimeReconnectOptions, NatsRuntimeStatusEvent } from '@natsail/core';
|
|
3
|
+
import type { SessionDefinition, SessionRegistry, SessionRegistryEvent, SessionSnapshot } from '@natsail/session';
|
|
4
|
+
export type NatsailOperation = 'connection' | 'publish' | 'reconnect' | 'request' | 'restart-session' | 'runtime-events' | 'session-events';
|
|
5
|
+
declare const NatsailOperationError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
6
|
+
readonly _tag: "NatsailOperationError";
|
|
7
|
+
} & Readonly<A>;
|
|
8
|
+
export declare class NatsailOperationError extends NatsailOperationError_base<{
|
|
9
|
+
readonly operation: NatsailOperation;
|
|
10
|
+
readonly message: string;
|
|
11
|
+
readonly cause: unknown;
|
|
12
|
+
}> {
|
|
13
|
+
}
|
|
14
|
+
export type NatsailSessionErrorStage = 'acquire' | 'source';
|
|
15
|
+
declare const NatsailSessionError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
16
|
+
readonly _tag: "NatsailSessionError";
|
|
17
|
+
} & Readonly<A>;
|
|
18
|
+
export declare class NatsailSessionError extends NatsailSessionError_base<{
|
|
19
|
+
readonly key: string;
|
|
20
|
+
readonly stage: NatsailSessionErrorStage;
|
|
21
|
+
readonly message: string;
|
|
22
|
+
readonly cause: unknown;
|
|
23
|
+
}> {
|
|
24
|
+
}
|
|
25
|
+
declare const NatsailStreamBufferOverflowError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
26
|
+
readonly _tag: "NatsailStreamBufferOverflowError";
|
|
27
|
+
} & Readonly<A>;
|
|
28
|
+
export declare class NatsailStreamBufferOverflowError extends NatsailStreamBufferOverflowError_base<{
|
|
29
|
+
readonly stream: string;
|
|
30
|
+
readonly capacity: number;
|
|
31
|
+
readonly message: string;
|
|
32
|
+
}> {
|
|
33
|
+
}
|
|
34
|
+
export type NatsailSessionStreamError = NatsailSessionError | NatsailStreamBufferOverflowError;
|
|
35
|
+
export type NatsailStreamOverflowStrategy = 'error' | 'dropping' | 'sliding';
|
|
36
|
+
export interface NatsailSessionStreamOptions {
|
|
37
|
+
/** Maximum queued snapshots. Defaults to 32. Use `unbounded` only deliberately. */
|
|
38
|
+
readonly bufferSize?: number | 'unbounded';
|
|
39
|
+
/** Defaults to a typed `error` instead of silently losing state. */
|
|
40
|
+
readonly overflowStrategy?: NatsailStreamOverflowStrategy;
|
|
41
|
+
}
|
|
42
|
+
export interface NatsailResource {
|
|
43
|
+
readonly runtime: NatsRuntime;
|
|
44
|
+
readonly sessions: SessionRegistry;
|
|
45
|
+
/** Replaces the default registry-then-runtime shutdown sequence. */
|
|
46
|
+
close?(): Promise<void>;
|
|
47
|
+
}
|
|
48
|
+
export interface NatsailService {
|
|
49
|
+
/** Escape hatch for NATSail or nats.js operations not wrapped by this adapter. */
|
|
50
|
+
readonly runtime: NatsRuntime;
|
|
51
|
+
/** Escape hatch for inspection and advanced shared-session operations. */
|
|
52
|
+
readonly sessions: SessionRegistry;
|
|
53
|
+
readonly runtimeEvents: Stream.Stream<NatsRuntimeEvent, NatsailOperationError>;
|
|
54
|
+
readonly runtimeStatus: Stream.Stream<NatsRuntimeStatusEvent, NatsailOperationError>;
|
|
55
|
+
readonly sessionEvents: Stream.Stream<SessionRegistryEvent, NatsailOperationError>;
|
|
56
|
+
connection(): Effect.Effect<NatsConnection, NatsailOperationError>;
|
|
57
|
+
reconnect(options?: NatsRuntimeReconnectOptions): Effect.Effect<NatsConnection, NatsailOperationError>;
|
|
58
|
+
publish(subject: string, data?: Parameters<NatsRuntime['publish']>[1], options?: Parameters<NatsRuntime['publish']>[2]): Effect.Effect<void, NatsailOperationError>;
|
|
59
|
+
request<T>(options: CoreRequestOptions<T>): Effect.Effect<T, NatsailOperationError>;
|
|
60
|
+
restartSession(key: string): Effect.Effect<void, NatsailOperationError>;
|
|
61
|
+
sessionSnapshots<T>(definition: SessionDefinition<T>, options?: NatsailSessionStreamOptions): Stream.Stream<SessionSnapshot<T>, NatsailSessionStreamError>;
|
|
62
|
+
sessionValues<T>(definition: SessionDefinition<T>, options?: NatsailSessionStreamOptions): Stream.Stream<T, NatsailSessionStreamError>;
|
|
63
|
+
}
|
|
64
|
+
declare const Natsail_base: Context.TagClass<Natsail, "@natsail/effect/Natsail", NatsailService>;
|
|
65
|
+
/** Context service supplied by a NATSail Effect Layer. */
|
|
66
|
+
export declare class Natsail extends Natsail_base {
|
|
67
|
+
}
|
|
68
|
+
/** Creates a service over application-owned runtime and registry objects. */
|
|
69
|
+
export declare function makeNatsail(resource: NatsailResource): NatsailService;
|
|
70
|
+
/** Supplies an existing resource without taking ownership of it. */
|
|
71
|
+
export declare function makeNatsailLayer(resource: NatsailResource): Layer.Layer<Natsail>;
|
|
72
|
+
/**
|
|
73
|
+
* Acquires one Layer-owned resource and closes it when the Layer scope exits.
|
|
74
|
+
* The default finalizer closes the registry first and always attempts to close
|
|
75
|
+
* the runtime, even if registry shutdown fails.
|
|
76
|
+
*/
|
|
77
|
+
export declare function makeNatsailScopedLayer<E, R>(acquire: Effect.Effect<NatsailResource, E, R>): Layer.Layer<Natsail, E, R>;
|
|
78
|
+
export {};
|
|
79
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAQ,MAAM,EAAE,KAAK,EAAU,MAAM,EAAE,MAAM,QAAQ,CAAA;AAErE,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACd,WAAW,EACX,gBAAgB,EAChB,2BAA2B,EAC3B,sBAAsB,EACvB,MAAM,eAAe,CAAA;AACtB,OAAO,KAAK,EACV,iBAAiB,EACjB,eAAe,EACf,oBAAoB,EACpB,eA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E,iBAAiB,CAAC,CAAC,CAAC,EAChC,OAAO,CAAC,EAAE,2BAA2B,GACpC,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,yBAAyB,CAAC,CAAA;IAC/D,aAAa,CAAC,CAAC,EACb,UAAU,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAChC,OAAO,CAAC,EAAE,2BAA2B,GACpC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,yBAAyB,CAAC,CAAA;CAC/C;;AAED,0DAA0D;AAC1D,qBAAa,OAAQ,SAAQ,YAAiE;CAAG;AAuIjG,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,QAAQ,EAAE,eAAe,GAAG,cAAc,CA+CrE;AAED,oEAAoE;AACpE,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,eAAe,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAEhF;AA0BD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,CAAC,EACzC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC,EAAE,CAAC,CAAC,GAC5C,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,CAO5B"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { Context, Data, Effect, Layer, Option, Stream } from 'effect';
|
|
2
|
+
export class NatsailOperationError extends Data.TaggedError('NatsailOperationError') {
|
|
3
|
+
}
|
|
4
|
+
export class NatsailSessionError extends Data.TaggedError('NatsailSessionError') {
|
|
5
|
+
}
|
|
6
|
+
export class NatsailStreamBufferOverflowError extends Data.TaggedError('NatsailStreamBufferOverflowError') {
|
|
7
|
+
}
|
|
8
|
+
/** Context service supplied by a NATSail Effect Layer. */
|
|
9
|
+
export class Natsail extends Context.Tag('@natsail/effect/Natsail')() {
|
|
10
|
+
}
|
|
11
|
+
const DEFAULT_STREAM_BUFFER_SIZE = 32;
|
|
12
|
+
function describeCause(cause) {
|
|
13
|
+
return cause instanceof Error ? cause.message : String(cause);
|
|
14
|
+
}
|
|
15
|
+
function operationError(operation, cause) {
|
|
16
|
+
return new NatsailOperationError({
|
|
17
|
+
operation,
|
|
18
|
+
cause,
|
|
19
|
+
message: `NATSail ${operation} failed: ${describeCause(cause)}`,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function sessionError(key, stage, cause) {
|
|
23
|
+
return new NatsailSessionError({
|
|
24
|
+
key,
|
|
25
|
+
stage,
|
|
26
|
+
cause,
|
|
27
|
+
message: `NATSail session ${key} ${stage} failed: ${describeCause(cause)}`,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
function tryRuntimePromise(operation, run) {
|
|
31
|
+
return Effect.tryPromise({
|
|
32
|
+
try: run,
|
|
33
|
+
catch: (cause) => operationError(operation, cause),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function resolveStreamOptions(options = {}) {
|
|
37
|
+
const bufferSize = options.bufferSize ?? DEFAULT_STREAM_BUFFER_SIZE;
|
|
38
|
+
const overflowStrategy = options.overflowStrategy ?? 'error';
|
|
39
|
+
if (bufferSize !== 'unbounded' && (!Number.isSafeInteger(bufferSize) || bufferSize <= 0)) {
|
|
40
|
+
throw new TypeError('NATSail Effect stream bufferSize must be a positive safe integer');
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
bufferSize,
|
|
44
|
+
overflowStrategy,
|
|
45
|
+
pushOptions: bufferSize === 'unbounded'
|
|
46
|
+
? { bufferSize: 'unbounded' }
|
|
47
|
+
: {
|
|
48
|
+
bufferSize,
|
|
49
|
+
strategy: overflowStrategy === 'sliding' ? 'sliding' : 'dropping',
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function createSessionSnapshotStream(sessions, definition, options) {
|
|
54
|
+
const resolved = resolveStreamOptions(options);
|
|
55
|
+
return Stream.asyncPush((emit) => Effect.gen(function* () {
|
|
56
|
+
const handle = yield* Effect.acquireRelease(Effect.try({
|
|
57
|
+
try: () => sessions.acquire(definition),
|
|
58
|
+
catch: (cause) => sessionError(definition.key, 'acquire', cause),
|
|
59
|
+
}), (active) => Effect.promise(() => active.release()));
|
|
60
|
+
let terminal = false;
|
|
61
|
+
const emitSnapshot = () => {
|
|
62
|
+
if (terminal)
|
|
63
|
+
return;
|
|
64
|
+
const snapshot = handle.getSnapshot();
|
|
65
|
+
const accepted = emit.single(snapshot);
|
|
66
|
+
if (!accepted &&
|
|
67
|
+
resolved.bufferSize !== 'unbounded' &&
|
|
68
|
+
resolved.overflowStrategy === 'error') {
|
|
69
|
+
terminal = true;
|
|
70
|
+
emit.fail(new NatsailStreamBufferOverflowError({
|
|
71
|
+
stream: `session:${definition.key}`,
|
|
72
|
+
capacity: resolved.bufferSize,
|
|
73
|
+
message: `NATSail session ${definition.key} exceeded its ${resolved.bufferSize}-snapshot Effect buffer`,
|
|
74
|
+
}));
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (snapshot.phase === 'error') {
|
|
78
|
+
terminal = true;
|
|
79
|
+
emit.fail(sessionError(definition.key, 'source', snapshot.error ?? new Error('The session source failed')));
|
|
80
|
+
}
|
|
81
|
+
else if (snapshot.phase === 'closed') {
|
|
82
|
+
terminal = true;
|
|
83
|
+
emit.end();
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
yield* Effect.acquireRelease(Effect.sync(() => handle.subscribe(emitSnapshot)), (unsubscribe) => Effect.sync(unsubscribe));
|
|
87
|
+
emitSnapshot();
|
|
88
|
+
}), resolved.pushOptions);
|
|
89
|
+
}
|
|
90
|
+
/** Creates a service over application-owned runtime and registry objects. */
|
|
91
|
+
export function makeNatsail(resource) {
|
|
92
|
+
const { runtime, sessions } = resource;
|
|
93
|
+
const runtimeEvents = Stream.fromAsyncIterable(runtime.events, (cause) => operationError('runtime-events', cause));
|
|
94
|
+
return {
|
|
95
|
+
runtime,
|
|
96
|
+
sessions,
|
|
97
|
+
runtimeEvents,
|
|
98
|
+
runtimeStatus: runtimeEvents.pipe(Stream.filter((event) => event.type === 'status'), Stream.changesWith((previous, next) => previous.state === next.state && previous.server === next.server)),
|
|
99
|
+
sessionEvents: Stream.fromAsyncIterable(sessions.events, (cause) => operationError('session-events', cause)),
|
|
100
|
+
connection: () => tryRuntimePromise('connection', () => runtime.connection()),
|
|
101
|
+
reconnect: (options) => tryRuntimePromise('reconnect', () => runtime.reconnect(options)),
|
|
102
|
+
publish: (subject, data, options) => tryRuntimePromise('publish', () => runtime.publish(subject, data, options)),
|
|
103
|
+
request: (options) => tryRuntimePromise('request', (effectSignal) => runtime.request({
|
|
104
|
+
...options,
|
|
105
|
+
signal: options.signal ? AbortSignal.any([options.signal, effectSignal]) : effectSignal,
|
|
106
|
+
})),
|
|
107
|
+
restartSession: (key) => tryRuntimePromise('restart-session', () => sessions.restart(key)),
|
|
108
|
+
sessionSnapshots: (definition, options) => createSessionSnapshotStream(sessions, definition, options),
|
|
109
|
+
sessionValues: (definition, options) => createSessionSnapshotStream(sessions, definition, options).pipe(Stream.mapAccum(-1, (valueRevision, snapshot) => {
|
|
110
|
+
if (snapshot.valueRevision !== valueRevision &&
|
|
111
|
+
Object.prototype.hasOwnProperty.call(snapshot, 'value')) {
|
|
112
|
+
return [snapshot.valueRevision, Option.some(snapshot.value)];
|
|
113
|
+
}
|
|
114
|
+
return [valueRevision, Option.none()];
|
|
115
|
+
}), Stream.filterMap((value) => value)),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/** Supplies an existing resource without taking ownership of it. */
|
|
119
|
+
export function makeNatsailLayer(resource) {
|
|
120
|
+
return Layer.succeed(Natsail, makeNatsail(resource));
|
|
121
|
+
}
|
|
122
|
+
async function closeResource(resource) {
|
|
123
|
+
if (resource.close) {
|
|
124
|
+
await resource.close();
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
const failures = [];
|
|
128
|
+
try {
|
|
129
|
+
await resource.sessions.close();
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
failures.push(error);
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
await resource.runtime.close();
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
failures.push(error);
|
|
139
|
+
}
|
|
140
|
+
if (failures.length === 1)
|
|
141
|
+
throw failures[0];
|
|
142
|
+
if (failures.length > 1) {
|
|
143
|
+
throw new AggregateError(failures, 'NATSail registry and runtime shutdown both failed');
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Acquires one Layer-owned resource and closes it when the Layer scope exits.
|
|
148
|
+
* The default finalizer closes the registry first and always attempts to close
|
|
149
|
+
* the runtime, even if registry shutdown fails.
|
|
150
|
+
*/
|
|
151
|
+
export function makeNatsailScopedLayer(acquire) {
|
|
152
|
+
return Layer.scoped(Natsail, Effect.acquireRelease(acquire, (resource) => Effect.promise(() => closeResource(resource))).pipe(Effect.map(makeNatsail)));
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AA0BrE,MAAM,OAAO,qBAAsB,SAAQ,IAAI,CAAC,WAAW,CAAC,uBAAuB,CAIjF;CAAG;AAIL,MAAM,OAAO,mBAAoB,SAAQ,IAAI,CAAC,WAAW,CAAC,qBAAqB,CAK7E;CAAG;AAEL,MAAM,OAAO,gCAAiC,SAAQ,IAAI,CAAC,WAAW,CACpE,kCAAkC,CAKlC;CAAG;AAiDL,0DAA0D;AAC1D,MAAM,OAAO,OAAQ,SAAQ,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,EAA2B;CAAG;AAYjG,MAAM,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,GAAc,EAAE,CAAA;IAC9B,IAAI,CAAC;QACH,MAAM,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAA;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACtB,CAAC;IACD,IAAI,CAAC;QACH,MAAM,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;IAChC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACtB,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,QAAQ,CAAC,CAAC,CAAC,CAAA;IAC5C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,cAAc,CAAC,QAAQ,EAAE,mDAAmD,CAAC,CAAA;IACzF,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAA6C;IAE7C,OAAO,KAAK,CAAC,MAAM,CACjB,OAAO,EACP,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE,CAC1C,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,CAC9C,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAChC,CAAA;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@natsail/effect",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Scoped Effect services and Streams for NATSail runtimes and shared sessions.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"nats",
|
|
7
|
+
"effect",
|
|
8
|
+
"stream",
|
|
9
|
+
"resource-management",
|
|
10
|
+
"subscription"
|
|
11
|
+
],
|
|
12
|
+
"license": "Apache-2.0",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"module": "./dist/index.js",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/thedonmon/natsail.git",
|
|
30
|
+
"directory": "packages/effect"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/thedonmon/natsail/tree/main/packages/effect#readme",
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/thedonmon/natsail/issues"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public",
|
|
38
|
+
"registry": "https://registry.npmjs.org/"
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@natsail/core": "^0.2.0",
|
|
42
|
+
"@natsail/session": "^0.2.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"effect": "^3.22.0"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "tsc -p tsconfig.json"
|
|
49
|
+
}
|
|
50
|
+
}
|