effect 4.0.0-beta.37 → 4.0.0-beta.39
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/dist/ErrorReporter.d.ts.map +1 -1
- package/dist/ErrorReporter.js +3 -2
- package/dist/ErrorReporter.js.map +1 -1
- package/dist/Queue.d.ts +5 -2
- package/dist/Queue.d.ts.map +1 -1
- package/dist/Queue.js +5 -2
- package/dist/Queue.js.map +1 -1
- package/dist/References.d.ts +235 -224
- package/dist/References.d.ts.map +1 -1
- package/dist/References.js +234 -246
- package/dist/References.js.map +1 -1
- package/dist/Schedule.d.ts +6 -202
- package/dist/Schedule.d.ts.map +1 -1
- package/dist/Schedule.js +6 -71
- package/dist/Schedule.js.map +1 -1
- package/dist/Schema.d.ts +6 -6
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +9 -13
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +5 -0
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +7 -2
- package/dist/SchemaParser.js.map +1 -1
- package/dist/Stream.d.ts +1 -1
- package/dist/Stream.js +1 -1
- package/dist/Struct.d.ts +7 -7
- package/dist/Struct.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/effect.js +1 -5
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/references.d.ts +2 -0
- package/dist/internal/references.d.ts.map +1 -0
- package/dist/internal/references.js +51 -0
- package/dist/internal/references.js.map +1 -0
- package/dist/unstable/cluster/EntityAddress.d.ts.map +1 -1
- package/dist/unstable/cluster/EntityAddress.js +1 -1
- package/dist/unstable/cluster/EntityAddress.js.map +1 -1
- package/dist/unstable/cluster/Runner.d.ts.map +1 -1
- package/dist/unstable/cluster/Runner.js +1 -1
- package/dist/unstable/cluster/Runner.js.map +1 -1
- package/dist/unstable/cluster/RunnerAddress.d.ts.map +1 -1
- package/dist/unstable/cluster/RunnerAddress.js +1 -1
- package/dist/unstable/cluster/RunnerAddress.js.map +1 -1
- package/dist/unstable/cluster/ShardId.js +3 -3
- package/dist/unstable/cluster/ShardId.js.map +1 -1
- package/dist/unstable/eventlog/EventJournal.js +2 -2
- package/dist/unstable/eventlog/EventJournal.js.map +1 -1
- package/dist/unstable/eventlog/EventLog.js +1 -1
- package/dist/unstable/eventlog/EventLog.js.map +1 -1
- package/dist/unstable/eventlog/SqlEventLogJournal.js +2 -2
- package/dist/unstable/eventlog/SqlEventLogJournal.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +9 -8
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.d.ts +36 -20
- package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiClient.js +49 -18
- package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts +186 -67
- package/dist/unstable/httpapi/HttpApiEndpoint.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiEndpoint.js +44 -29
- package/dist/unstable/httpapi/HttpApiEndpoint.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.d.ts +5 -0
- package/dist/unstable/httpapi/HttpApiSchema.d.ts.map +1 -1
- package/dist/unstable/httpapi/HttpApiSchema.js +20 -2
- package/dist/unstable/httpapi/HttpApiSchema.js.map +1 -1
- package/dist/unstable/httpapi/OpenApi.d.ts.map +1 -1
- package/dist/unstable/httpapi/OpenApi.js +2 -5
- package/dist/unstable/httpapi/OpenApi.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +11 -7
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js +6 -6
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts +1 -1
- package/dist/unstable/schema/VariantSchema.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ErrorReporter.ts +3 -2
- package/src/Queue.ts +5 -2
- package/src/References.ts +276 -285
- package/src/Schedule.ts +7 -212
- package/src/Schema.ts +8 -12
- package/src/SchemaAST.ts +6 -0
- package/src/SchemaParser.ts +7 -2
- package/src/Stream.ts +1 -1
- package/src/Struct.ts +7 -7
- package/src/index.ts +1 -1
- package/src/internal/effect.ts +14 -21
- package/src/internal/references.ts +72 -0
- package/src/unstable/cluster/EntityAddress.ts +1 -1
- package/src/unstable/cluster/Runner.ts +1 -1
- package/src/unstable/cluster/RunnerAddress.ts +1 -1
- package/src/unstable/cluster/ShardId.ts +2 -2
- package/src/unstable/eventlog/EventJournal.ts +2 -2
- package/src/unstable/eventlog/EventLog.ts +1 -1
- package/src/unstable/eventlog/SqlEventLogJournal.ts +2 -2
- package/src/unstable/httpapi/HttpApiBuilder.ts +15 -9
- package/src/unstable/httpapi/HttpApiClient.ts +118 -55
- package/src/unstable/httpapi/HttpApiEndpoint.ts +164 -36
- package/src/unstable/httpapi/HttpApiSchema.ts +20 -2
- package/src/unstable/httpapi/OpenApi.ts +2 -6
- package/src/unstable/reactivity/AtomHttpApi.ts +22 -17
- package/src/unstable/schema/VariantSchema.ts +1 -1
package/src/References.ts
CHANGED
|
@@ -10,11 +10,13 @@
|
|
|
10
10
|
*
|
|
11
11
|
* @since 4.0.0
|
|
12
12
|
*/
|
|
13
|
-
import
|
|
13
|
+
import * as internalEffect from "./internal/effect.ts"
|
|
14
|
+
import * as references from "./internal/references.ts"
|
|
15
|
+
import type { Logger } from "./Logger.ts"
|
|
14
16
|
import type { LogLevel, Severity } from "./LogLevel.ts"
|
|
15
17
|
import type { ReadonlyRecord } from "./Record.ts"
|
|
16
18
|
import { MaxOpsBeforeYield, PreventSchedulerYield } from "./Scheduler.ts"
|
|
17
|
-
import * as ServiceMap from "./ServiceMap.ts"
|
|
19
|
+
import type * as ServiceMap from "./ServiceMap.ts"
|
|
18
20
|
import { CurrentTraceLevel, DisablePropagation, MinimumTraceLevel, type SpanLink, Tracer } from "./Tracer.ts"
|
|
19
21
|
|
|
20
22
|
export {
|
|
@@ -88,144 +90,261 @@ export {
|
|
|
88
90
|
* @category references
|
|
89
91
|
* @since 4.0.0
|
|
90
92
|
*/
|
|
91
|
-
export const CurrentConcurrency
|
|
92
|
-
defaultValue: () => "unbounded"
|
|
93
|
-
})
|
|
93
|
+
export const CurrentConcurrency: ServiceMap.Reference<number | "unbounded"> = references.CurrentConcurrency
|
|
94
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
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Reference for managing log annotations that are automatically added to all log entries.
|
|
97
|
+
* These annotations provide contextual metadata that appears in every log message.
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* import { Console, Effect, References } from "effect"
|
|
102
|
+
*
|
|
103
|
+
* const logAnnotationExample = Effect.gen(function*() {
|
|
104
|
+
* // Get current annotations (empty by default)
|
|
105
|
+
* const current = yield* References.CurrentLogAnnotations
|
|
106
|
+
* console.log(current) // {}
|
|
107
|
+
*
|
|
108
|
+
* // Run with custom log annotations
|
|
109
|
+
* yield* Effect.provideService(
|
|
110
|
+
* Effect.gen(function*() {
|
|
111
|
+
* const annotations = yield* References.CurrentLogAnnotations
|
|
112
|
+
* console.log(annotations) // { requestId: "req-123", userId: "user-456", version: "1.0.0" }
|
|
113
|
+
*
|
|
114
|
+
* // All log entries will include these annotations
|
|
115
|
+
* yield* Console.log("Starting operation")
|
|
116
|
+
* yield* Console.info("Processing data")
|
|
117
|
+
* }),
|
|
118
|
+
* References.CurrentLogAnnotations,
|
|
119
|
+
* {
|
|
120
|
+
* requestId: "req-123",
|
|
121
|
+
* userId: "user-456",
|
|
122
|
+
* version: "1.0.0"
|
|
123
|
+
* }
|
|
124
|
+
* )
|
|
125
|
+
*
|
|
126
|
+
* // Run with extended annotations
|
|
127
|
+
* yield* Effect.provideService(
|
|
128
|
+
* Effect.gen(function*() {
|
|
129
|
+
* const extended = yield* References.CurrentLogAnnotations
|
|
130
|
+
* console.log(extended) // { requestId: "req-123", userId: "user-456", version: "1.0.0", operation: "data-sync", timestamp: 1234567890 }
|
|
131
|
+
*
|
|
132
|
+
* yield* Console.log("Operation completed with extended context")
|
|
133
|
+
* }),
|
|
134
|
+
* References.CurrentLogAnnotations,
|
|
135
|
+
* {
|
|
136
|
+
* requestId: "req-123",
|
|
137
|
+
* userId: "user-456",
|
|
138
|
+
* version: "1.0.0",
|
|
139
|
+
* operation: "data-sync",
|
|
140
|
+
* timestamp: 1234567890
|
|
141
|
+
* }
|
|
142
|
+
* )
|
|
143
|
+
* })
|
|
144
|
+
* ```
|
|
145
|
+
*
|
|
146
|
+
* @since 4.0.0
|
|
147
|
+
* @category references
|
|
148
|
+
*/
|
|
149
|
+
export const CurrentLogAnnotations: ServiceMap.Reference<ReadonlyRecord<string, unknown>> =
|
|
150
|
+
references.CurrentLogAnnotations
|
|
129
151
|
|
|
130
152
|
/**
|
|
153
|
+
* Reference for controlling the current log level for dynamic filtering.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```ts
|
|
157
|
+
* import { Console, Effect, References } from "effect"
|
|
158
|
+
*
|
|
159
|
+
* const dynamicLogging = Effect.gen(function*() {
|
|
160
|
+
* // Get current log level (default is "Info")
|
|
161
|
+
* const current = yield* References.CurrentLogLevel
|
|
162
|
+
* console.log(current) // "Info"
|
|
163
|
+
*
|
|
164
|
+
* // Set log level to Debug for detailed logging
|
|
165
|
+
* yield* Effect.provideService(
|
|
166
|
+
* Effect.gen(function*() {
|
|
167
|
+
* const level = yield* References.CurrentLogLevel
|
|
168
|
+
* console.log(level) // "Debug"
|
|
169
|
+
* yield* Console.debug("This debug message will be shown")
|
|
170
|
+
* }),
|
|
171
|
+
* References.CurrentLogLevel,
|
|
172
|
+
* "Debug"
|
|
173
|
+
* )
|
|
174
|
+
*
|
|
175
|
+
* // Change to Error level to reduce noise
|
|
176
|
+
* yield* Effect.provideService(
|
|
177
|
+
* Effect.gen(function*() {
|
|
178
|
+
* const level = yield* References.CurrentLogLevel
|
|
179
|
+
* console.log(level) // "Error"
|
|
180
|
+
* yield* Console.info("This info message will be filtered out")
|
|
181
|
+
* yield* Console.error("This error message will be shown")
|
|
182
|
+
* }),
|
|
183
|
+
* References.CurrentLogLevel,
|
|
184
|
+
* "Error"
|
|
185
|
+
* )
|
|
186
|
+
* })
|
|
187
|
+
* ```
|
|
188
|
+
*
|
|
189
|
+
* @category references
|
|
190
|
+
* @since 4.0.0
|
|
191
|
+
*/
|
|
192
|
+
export const CurrentLogLevel: ServiceMap.Reference<Severity> = references.CurrentLogLevel
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Reference for managing log spans that track the duration and hierarchy of operations.
|
|
196
|
+
* Each span represents a labeled time period for performance analysis and debugging.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* import { Console, Effect, References } from "effect"
|
|
201
|
+
*
|
|
202
|
+
* const logSpanExample = Effect.gen(function*() {
|
|
203
|
+
* // Get current spans (empty by default)
|
|
204
|
+
* const current = yield* References.CurrentLogSpans
|
|
205
|
+
* console.log(current.length) // 0
|
|
206
|
+
*
|
|
207
|
+
* // Add a log span manually
|
|
208
|
+
* const startTime = Date.now()
|
|
209
|
+
* yield* Effect.provideService(
|
|
210
|
+
* Effect.gen(function*() {
|
|
211
|
+
* // Simulate some work
|
|
212
|
+
* yield* Effect.sleep("100 millis")
|
|
213
|
+
* yield* Console.log("Database operation in progress")
|
|
214
|
+
*
|
|
215
|
+
* const spans = yield* References.CurrentLogSpans
|
|
216
|
+
* console.log("Active spans:", spans.map(([label]) => label)) // ["database-connection"]
|
|
217
|
+
* }),
|
|
218
|
+
* References.CurrentLogSpans,
|
|
219
|
+
* [["database-connection", startTime]]
|
|
220
|
+
* )
|
|
221
|
+
*
|
|
222
|
+
* // Add another span
|
|
223
|
+
* yield* Effect.provideService(
|
|
224
|
+
* Effect.gen(function*() {
|
|
225
|
+
* const spans = yield* References.CurrentLogSpans
|
|
226
|
+
* console.log("Active spans:", spans.map(([label]) => label)) // ["database-connection", "data-processing"]
|
|
227
|
+
*
|
|
228
|
+
* yield* Console.log("Multiple operations in progress")
|
|
229
|
+
* }),
|
|
230
|
+
* References.CurrentLogSpans,
|
|
231
|
+
* [
|
|
232
|
+
* ["database-connection", startTime],
|
|
233
|
+
* ["data-processing", Date.now()]
|
|
234
|
+
* ]
|
|
235
|
+
* )
|
|
236
|
+
*
|
|
237
|
+
* // Clear spans when operations complete
|
|
238
|
+
* yield* Effect.provideService(
|
|
239
|
+
* Effect.gen(function*() {
|
|
240
|
+
* const spans = yield* References.CurrentLogSpans
|
|
241
|
+
* console.log("Active spans:", spans.length) // 0
|
|
242
|
+
* }),
|
|
243
|
+
* References.CurrentLogSpans,
|
|
244
|
+
* []
|
|
245
|
+
* )
|
|
246
|
+
* })
|
|
247
|
+
* ```
|
|
248
|
+
*
|
|
131
249
|
* @since 4.0.0
|
|
132
250
|
* @category references
|
|
133
251
|
*/
|
|
134
|
-
export
|
|
135
|
-
|
|
136
|
-
readonly stack: () => string | undefined
|
|
137
|
-
readonly parent: StackFrame | undefined
|
|
138
|
-
}
|
|
252
|
+
export const CurrentLogSpans: ServiceMap.Reference<ReadonlyArray<[label: string, timestamp: number]>> =
|
|
253
|
+
references.CurrentLogSpans
|
|
139
254
|
|
|
140
255
|
/**
|
|
141
256
|
* @since 4.0.0
|
|
142
257
|
* @category references
|
|
143
258
|
*/
|
|
144
|
-
export const CurrentStackFrame
|
|
145
|
-
defaultValue: constUndefined
|
|
146
|
-
})
|
|
259
|
+
export const CurrentStackFrame: ServiceMap.Reference<StackFrame | undefined> = references.CurrentStackFrame
|
|
147
260
|
|
|
148
261
|
/**
|
|
149
|
-
* Reference for
|
|
150
|
-
*
|
|
262
|
+
* Reference for setting the minimum log level threshold. Log entries below this
|
|
263
|
+
* level will be filtered out completely.
|
|
151
264
|
*
|
|
152
265
|
* @example
|
|
153
266
|
* ```ts
|
|
154
|
-
* import { Effect, References } from "effect"
|
|
267
|
+
* import { Console, Effect, References } from "effect"
|
|
155
268
|
*
|
|
156
|
-
* const
|
|
157
|
-
* //
|
|
158
|
-
* const current = yield* References.
|
|
159
|
-
* console.log(current) //
|
|
269
|
+
* const configureMinimumLogging = Effect.gen(function*() {
|
|
270
|
+
* // Get current minimum level (default is "Info")
|
|
271
|
+
* const current = yield* References.MinimumLogLevel
|
|
272
|
+
* console.log(current) // "Info"
|
|
160
273
|
*
|
|
161
|
-
* //
|
|
274
|
+
* // Set minimum level to Warn - Debug and Info will be filtered
|
|
162
275
|
* yield* Effect.provideService(
|
|
163
276
|
* Effect.gen(function*() {
|
|
164
|
-
* const
|
|
165
|
-
* console.log(
|
|
277
|
+
* const minLevel = yield* References.MinimumLogLevel
|
|
278
|
+
* console.log(minLevel) // "Warn"
|
|
166
279
|
*
|
|
167
|
-
* //
|
|
168
|
-
* yield*
|
|
280
|
+
* // These won't be processed at all
|
|
281
|
+
* yield* Console.debug("Debug message") // Filtered out
|
|
282
|
+
* yield* Console.info("Info message") // Filtered out
|
|
283
|
+
*
|
|
284
|
+
* // These will be processed
|
|
285
|
+
* yield* Console.warn("Warning message") // Shown
|
|
286
|
+
* yield* Console.error("Error message") // Shown
|
|
169
287
|
* }),
|
|
170
|
-
* References.
|
|
171
|
-
*
|
|
288
|
+
* References.MinimumLogLevel,
|
|
289
|
+
* "Warn"
|
|
172
290
|
* )
|
|
173
291
|
*
|
|
174
|
-
* //
|
|
292
|
+
* // Reset to default Info level
|
|
175
293
|
* yield* Effect.provideService(
|
|
176
294
|
* Effect.gen(function*() {
|
|
177
|
-
* const
|
|
178
|
-
* console.log(
|
|
295
|
+
* const minLevel = yield* References.MinimumLogLevel
|
|
296
|
+
* console.log(minLevel) // "Info"
|
|
179
297
|
*
|
|
180
|
-
* //
|
|
181
|
-
* yield*
|
|
298
|
+
* // Now info messages will be processed
|
|
299
|
+
* yield* Console.info("Info message") // Shown
|
|
182
300
|
* }),
|
|
183
|
-
* References.
|
|
184
|
-
*
|
|
301
|
+
* References.MinimumLogLevel,
|
|
302
|
+
* "Info"
|
|
185
303
|
* )
|
|
186
304
|
* })
|
|
187
305
|
* ```
|
|
188
306
|
*
|
|
189
|
-
* @since 4.0.0
|
|
190
307
|
* @category references
|
|
308
|
+
* @since 4.0.0
|
|
191
309
|
*/
|
|
192
|
-
export const
|
|
193
|
-
defaultValue: constTrue
|
|
194
|
-
})
|
|
310
|
+
export const MinimumLogLevel: ServiceMap.Reference<LogLevel> = references.MinimumLogLevel
|
|
195
311
|
|
|
196
312
|
/**
|
|
197
|
-
* Reference for controlling whether
|
|
198
|
-
*
|
|
199
|
-
* be set to zero).
|
|
313
|
+
* Reference for controlling whether tracing is enabled globally. When set to false,
|
|
314
|
+
* spans will not be registered with the tracer and tracing overhead is minimized.
|
|
200
315
|
*
|
|
201
316
|
* @example
|
|
202
317
|
* ```ts
|
|
203
318
|
* import { Effect, References } from "effect"
|
|
204
319
|
*
|
|
205
320
|
* const tracingControl = Effect.gen(function*() {
|
|
206
|
-
* // Check if
|
|
207
|
-
* const current = yield* References.
|
|
321
|
+
* // Check if tracing is enabled (default is true)
|
|
322
|
+
* const current = yield* References.TracerEnabled
|
|
208
323
|
* console.log(current) // true
|
|
209
324
|
*
|
|
210
|
-
* // Disable
|
|
325
|
+
* // Disable tracing globally
|
|
211
326
|
* yield* Effect.provideService(
|
|
212
327
|
* Effect.gen(function*() {
|
|
213
|
-
*
|
|
214
|
-
* const isEnabled = yield* References.TracerTimingEnabled
|
|
328
|
+
* const isEnabled = yield* References.TracerEnabled
|
|
215
329
|
* console.log(isEnabled) // false
|
|
330
|
+
*
|
|
331
|
+
* // Spans will not be traced in this context
|
|
332
|
+
* yield* Effect.log("This will not be traced")
|
|
216
333
|
* }),
|
|
217
|
-
* References.
|
|
334
|
+
* References.TracerEnabled,
|
|
218
335
|
* false
|
|
219
336
|
* )
|
|
220
337
|
*
|
|
221
|
-
* // Re-enable
|
|
338
|
+
* // Re-enable tracing
|
|
222
339
|
* yield* Effect.provideService(
|
|
223
340
|
* Effect.gen(function*() {
|
|
224
|
-
*
|
|
225
|
-
* const isEnabled = yield* References.TracerTimingEnabled
|
|
341
|
+
* const isEnabled = yield* References.TracerEnabled
|
|
226
342
|
* console.log(isEnabled) // true
|
|
343
|
+
*
|
|
344
|
+
* // All subsequent spans will be traced
|
|
345
|
+
* yield* Effect.log("This will be traced")
|
|
227
346
|
* }),
|
|
228
|
-
* References.
|
|
347
|
+
* References.TracerEnabled,
|
|
229
348
|
* true
|
|
230
349
|
* )
|
|
231
350
|
* })
|
|
@@ -234,9 +353,7 @@ export const TracerEnabled = ServiceMap.Reference<boolean>("effect/References/Tr
|
|
|
234
353
|
* @since 4.0.0
|
|
235
354
|
* @category references
|
|
236
355
|
*/
|
|
237
|
-
export const
|
|
238
|
-
defaultValue: constTrue
|
|
239
|
-
})
|
|
356
|
+
export const TracerEnabled: ServiceMap.Reference<boolean> = references.TracerEnabled
|
|
240
357
|
|
|
241
358
|
/**
|
|
242
359
|
* Reference for managing span annotations that are automatically added to all new spans.
|
|
@@ -288,10 +405,8 @@ export const TracerTimingEnabled = ServiceMap.Reference<boolean>("effect/Referen
|
|
|
288
405
|
* @since 4.0.0
|
|
289
406
|
* @category references
|
|
290
407
|
*/
|
|
291
|
-
export const TracerSpanAnnotations
|
|
292
|
-
|
|
293
|
-
{ defaultValue: () => ({}) }
|
|
294
|
-
)
|
|
408
|
+
export const TracerSpanAnnotations: ServiceMap.Reference<ReadonlyRecord<string, unknown>> =
|
|
409
|
+
references.TracerSpanAnnotations
|
|
295
410
|
|
|
296
411
|
/**
|
|
297
412
|
* Reference for managing span links that are automatically added to all new spans.
|
|
@@ -353,57 +468,42 @@ export const TracerSpanAnnotations = ServiceMap.Reference<ReadonlyRecord<string,
|
|
|
353
468
|
* @since 4.0.0
|
|
354
469
|
* @category references
|
|
355
470
|
*/
|
|
356
|
-
export const TracerSpanLinks
|
|
357
|
-
defaultValue: () => []
|
|
358
|
-
})
|
|
471
|
+
export const TracerSpanLinks: ServiceMap.Reference<ReadonlyArray<SpanLink>> = references.TracerSpanLinks
|
|
359
472
|
|
|
360
473
|
/**
|
|
361
|
-
* Reference for
|
|
362
|
-
*
|
|
474
|
+
* Reference for controlling whether trace timing is enabled globally. When set
|
|
475
|
+
* to false, spans will not contain timing information (trace time will always
|
|
476
|
+
* be set to zero).
|
|
363
477
|
*
|
|
364
478
|
* @example
|
|
365
479
|
* ```ts
|
|
366
|
-
* import {
|
|
480
|
+
* import { Effect, References } from "effect"
|
|
367
481
|
*
|
|
368
|
-
* const
|
|
369
|
-
* //
|
|
370
|
-
* const current = yield* References.
|
|
371
|
-
* console.log(current) //
|
|
482
|
+
* const tracingControl = Effect.gen(function*() {
|
|
483
|
+
* // Check if trace timing is enabled (default is true)
|
|
484
|
+
* const current = yield* References.TracerTimingEnabled
|
|
485
|
+
* console.log(current) // true
|
|
372
486
|
*
|
|
373
|
-
* //
|
|
487
|
+
* // Disable trace timing globally
|
|
374
488
|
* yield* Effect.provideService(
|
|
375
489
|
* Effect.gen(function*() {
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
* // All log entries will include these annotations
|
|
380
|
-
* yield* Console.log("Starting operation")
|
|
381
|
-
* yield* Console.info("Processing data")
|
|
490
|
+
* // Spans will not having timing information in this context
|
|
491
|
+
* const isEnabled = yield* References.TracerTimingEnabled
|
|
492
|
+
* console.log(isEnabled) // false
|
|
382
493
|
* }),
|
|
383
|
-
* References.
|
|
384
|
-
*
|
|
385
|
-
* requestId: "req-123",
|
|
386
|
-
* userId: "user-456",
|
|
387
|
-
* version: "1.0.0"
|
|
388
|
-
* }
|
|
494
|
+
* References.TracerTimingEnabled,
|
|
495
|
+
* false
|
|
389
496
|
* )
|
|
390
497
|
*
|
|
391
|
-
* //
|
|
498
|
+
* // Re-enable trace timing
|
|
392
499
|
* yield* Effect.provideService(
|
|
393
500
|
* Effect.gen(function*() {
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
* yield* Console.log("Operation completed with extended context")
|
|
501
|
+
* // Spans will have timing information in this context
|
|
502
|
+
* const isEnabled = yield* References.TracerTimingEnabled
|
|
503
|
+
* console.log(isEnabled) // true
|
|
398
504
|
* }),
|
|
399
|
-
* References.
|
|
400
|
-
*
|
|
401
|
-
* requestId: "req-123",
|
|
402
|
-
* userId: "user-456",
|
|
403
|
-
* version: "1.0.0",
|
|
404
|
-
* operation: "data-sync",
|
|
405
|
-
* timestamp: 1234567890
|
|
406
|
-
* }
|
|
505
|
+
* References.TracerTimingEnabled,
|
|
506
|
+
* true
|
|
407
507
|
* )
|
|
408
508
|
* })
|
|
409
509
|
* ```
|
|
@@ -411,179 +511,70 @@ export const TracerSpanLinks = ServiceMap.Reference<ReadonlyArray<SpanLink>>("ef
|
|
|
411
511
|
* @since 4.0.0
|
|
412
512
|
* @category references
|
|
413
513
|
*/
|
|
414
|
-
export const
|
|
415
|
-
"effect/References/CurrentLogAnnotations",
|
|
416
|
-
{ defaultValue: () => ({}) }
|
|
417
|
-
)
|
|
514
|
+
export const TracerTimingEnabled: ServiceMap.Reference<boolean> = references.TracerTimingEnabled
|
|
418
515
|
|
|
419
516
|
/**
|
|
420
|
-
*
|
|
421
|
-
*
|
|
422
|
-
* @example
|
|
423
|
-
* ```ts
|
|
424
|
-
* import { Console, Effect, References } from "effect"
|
|
425
|
-
*
|
|
426
|
-
* const dynamicLogging = Effect.gen(function*() {
|
|
427
|
-
* // Get current log level (default is "Info")
|
|
428
|
-
* const current = yield* References.CurrentLogLevel
|
|
429
|
-
* console.log(current) // "Info"
|
|
430
|
-
*
|
|
431
|
-
* // Set log level to Debug for detailed logging
|
|
432
|
-
* yield* Effect.provideService(
|
|
433
|
-
* Effect.gen(function*() {
|
|
434
|
-
* const level = yield* References.CurrentLogLevel
|
|
435
|
-
* console.log(level) // "Debug"
|
|
436
|
-
* yield* Console.debug("This debug message will be shown")
|
|
437
|
-
* }),
|
|
438
|
-
* References.CurrentLogLevel,
|
|
439
|
-
* "Debug"
|
|
440
|
-
* )
|
|
441
|
-
*
|
|
442
|
-
* // Change to Error level to reduce noise
|
|
443
|
-
* yield* Effect.provideService(
|
|
444
|
-
* Effect.gen(function*() {
|
|
445
|
-
* const level = yield* References.CurrentLogLevel
|
|
446
|
-
* console.log(level) // "Error"
|
|
447
|
-
* yield* Console.info("This info message will be filtered out")
|
|
448
|
-
* yield* Console.error("This error message will be shown")
|
|
449
|
-
* }),
|
|
450
|
-
* References.CurrentLogLevel,
|
|
451
|
-
* "Error"
|
|
452
|
-
* )
|
|
453
|
-
* })
|
|
454
|
-
* ```
|
|
517
|
+
* The log level for unhandled errors. This reference allows you to set the log
|
|
518
|
+
* level for unhandled errors that occur during Effect execution.
|
|
455
519
|
*
|
|
456
520
|
* @category references
|
|
457
521
|
* @since 4.0.0
|
|
458
522
|
*/
|
|
459
|
-
export const
|
|
460
|
-
"effect/References/CurrentLogLevel",
|
|
461
|
-
{ defaultValue: () => "Info" }
|
|
462
|
-
)
|
|
523
|
+
export const UnhandledLogLevel: ServiceMap.Reference<Severity | undefined> = references.UnhandledLogLevel
|
|
463
524
|
|
|
464
525
|
/**
|
|
465
|
-
* Reference for setting the minimum log level threshold. Log entries below this
|
|
466
|
-
* level will be filtered out completely.
|
|
467
|
-
*
|
|
468
|
-
* @example
|
|
469
|
-
* ```ts
|
|
470
|
-
* import { Console, Effect, References } from "effect"
|
|
471
|
-
*
|
|
472
|
-
* const configureMinimumLogging = Effect.gen(function*() {
|
|
473
|
-
* // Get current minimum level (default is "Info")
|
|
474
|
-
* const current = yield* References.MinimumLogLevel
|
|
475
|
-
* console.log(current) // "Info"
|
|
476
|
-
*
|
|
477
|
-
* // Set minimum level to Warn - Debug and Info will be filtered
|
|
478
|
-
* yield* Effect.provideService(
|
|
479
|
-
* Effect.gen(function*() {
|
|
480
|
-
* const minLevel = yield* References.MinimumLogLevel
|
|
481
|
-
* console.log(minLevel) // "Warn"
|
|
482
|
-
*
|
|
483
|
-
* // These won't be processed at all
|
|
484
|
-
* yield* Console.debug("Debug message") // Filtered out
|
|
485
|
-
* yield* Console.info("Info message") // Filtered out
|
|
486
|
-
*
|
|
487
|
-
* // These will be processed
|
|
488
|
-
* yield* Console.warn("Warning message") // Shown
|
|
489
|
-
* yield* Console.error("Error message") // Shown
|
|
490
|
-
* }),
|
|
491
|
-
* References.MinimumLogLevel,
|
|
492
|
-
* "Warn"
|
|
493
|
-
* )
|
|
494
|
-
*
|
|
495
|
-
* // Reset to default Info level
|
|
496
|
-
* yield* Effect.provideService(
|
|
497
|
-
* Effect.gen(function*() {
|
|
498
|
-
* const minLevel = yield* References.MinimumLogLevel
|
|
499
|
-
* console.log(minLevel) // "Info"
|
|
500
|
-
*
|
|
501
|
-
* // Now info messages will be processed
|
|
502
|
-
* yield* Console.info("Info message") // Shown
|
|
503
|
-
* }),
|
|
504
|
-
* References.MinimumLogLevel,
|
|
505
|
-
* "Info"
|
|
506
|
-
* )
|
|
507
|
-
* })
|
|
508
|
-
* ```
|
|
509
|
-
*
|
|
510
|
-
* @category references
|
|
511
526
|
* @since 4.0.0
|
|
527
|
+
* @category references
|
|
512
528
|
*/
|
|
513
|
-
export
|
|
514
|
-
|
|
515
|
-
|
|
529
|
+
export interface StackFrame {
|
|
530
|
+
readonly name: string
|
|
531
|
+
readonly stack: () => string | undefined
|
|
532
|
+
readonly parent: StackFrame | undefined
|
|
533
|
+
}
|
|
516
534
|
|
|
517
535
|
/**
|
|
518
|
-
* The log level for unhandled errors. This reference allows you to set the log
|
|
519
|
-
* level for unhandled errors that occur during Effect execution.
|
|
520
|
-
*
|
|
521
|
-
* @category references
|
|
522
536
|
* @since 4.0.0
|
|
537
|
+
* @category references
|
|
523
538
|
*/
|
|
524
|
-
export const
|
|
525
|
-
"effect/References/UnhandledLogLevel",
|
|
526
|
-
{ defaultValue: (): Severity | undefined => "Error" }
|
|
527
|
-
)
|
|
539
|
+
export const CurrentLoggers: ServiceMap.Reference<ReadonlySet<Logger<unknown, any>>> = internalEffect.CurrentLoggers
|
|
528
540
|
|
|
529
541
|
/**
|
|
530
|
-
* Reference for managing log spans that track the duration and hierarchy of operations.
|
|
531
|
-
* Each span represents a labeled time period for performance analysis and debugging.
|
|
532
|
-
*
|
|
533
|
-
* @example
|
|
534
|
-
* ```ts
|
|
535
|
-
* import { Console, Effect, References } from "effect"
|
|
536
|
-
*
|
|
537
|
-
* const logSpanExample = Effect.gen(function*() {
|
|
538
|
-
* // Get current spans (empty by default)
|
|
539
|
-
* const current = yield* References.CurrentLogSpans
|
|
540
|
-
* console.log(current.length) // 0
|
|
541
|
-
*
|
|
542
|
-
* // Add a log span manually
|
|
543
|
-
* const startTime = Date.now()
|
|
544
|
-
* yield* Effect.provideService(
|
|
545
|
-
* Effect.gen(function*() {
|
|
546
|
-
* // Simulate some work
|
|
547
|
-
* yield* Effect.sleep("100 millis")
|
|
548
|
-
* yield* Console.log("Database operation in progress")
|
|
549
|
-
*
|
|
550
|
-
* const spans = yield* References.CurrentLogSpans
|
|
551
|
-
* console.log("Active spans:", spans.map(([label]) => label)) // ["database-connection"]
|
|
552
|
-
* }),
|
|
553
|
-
* References.CurrentLogSpans,
|
|
554
|
-
* [["database-connection", startTime]]
|
|
555
|
-
* )
|
|
556
|
-
*
|
|
557
|
-
* // Add another span
|
|
558
|
-
* yield* Effect.provideService(
|
|
559
|
-
* Effect.gen(function*() {
|
|
560
|
-
* const spans = yield* References.CurrentLogSpans
|
|
561
|
-
* console.log("Active spans:", spans.map(([label]) => label)) // ["database-connection", "data-processing"]
|
|
562
|
-
*
|
|
563
|
-
* yield* Console.log("Multiple operations in progress")
|
|
564
|
-
* }),
|
|
565
|
-
* References.CurrentLogSpans,
|
|
566
|
-
* [
|
|
567
|
-
* ["database-connection", startTime],
|
|
568
|
-
* ["data-processing", Date.now()]
|
|
569
|
-
* ]
|
|
570
|
-
* )
|
|
571
|
-
*
|
|
572
|
-
* // Clear spans when operations complete
|
|
573
|
-
* yield* Effect.provideService(
|
|
574
|
-
* Effect.gen(function*() {
|
|
575
|
-
* const spans = yield* References.CurrentLogSpans
|
|
576
|
-
* console.log("Active spans:", spans.length) // 0
|
|
577
|
-
* }),
|
|
578
|
-
* References.CurrentLogSpans,
|
|
579
|
-
* []
|
|
580
|
-
* )
|
|
581
|
-
* })
|
|
582
|
-
* ```
|
|
583
|
-
*
|
|
584
542
|
* @since 4.0.0
|
|
585
543
|
* @category references
|
|
586
544
|
*/
|
|
587
|
-
export const
|
|
588
|
-
|
|
589
|
-
|
|
545
|
+
export const LogToStderr: ServiceMap.Reference<boolean> = internalEffect.LogToStderr
|
|
546
|
+
|
|
547
|
+
export {
|
|
548
|
+
/**
|
|
549
|
+
* Reference for the current scheduler implementation used by the Effect runtime.
|
|
550
|
+
* Controls how Effects are scheduled and executed.
|
|
551
|
+
*
|
|
552
|
+
* @example
|
|
553
|
+
* ```ts
|
|
554
|
+
* import { Effect, References, Scheduler } from "effect"
|
|
555
|
+
*
|
|
556
|
+
* const customScheduling = Effect.gen(function*() {
|
|
557
|
+
* // Get current scheduler (default is MixedScheduler)
|
|
558
|
+
* const current = yield* References.Scheduler
|
|
559
|
+
* console.log(current) // MixedScheduler instance
|
|
560
|
+
*
|
|
561
|
+
* // Use a custom scheduler
|
|
562
|
+
* yield* Effect.provideService(
|
|
563
|
+
* Effect.gen(function*() {
|
|
564
|
+
* const scheduler = yield* References.Scheduler
|
|
565
|
+
* console.log(scheduler) // Custom scheduler instance
|
|
566
|
+
*
|
|
567
|
+
* // Effects will use the custom scheduler in this context
|
|
568
|
+
* yield* Effect.log("Using custom scheduler")
|
|
569
|
+
* }),
|
|
570
|
+
* References.Scheduler,
|
|
571
|
+
* new Scheduler.MixedScheduler()
|
|
572
|
+
* )
|
|
573
|
+
* })
|
|
574
|
+
* ```
|
|
575
|
+
*
|
|
576
|
+
* @category references
|
|
577
|
+
* @since 4.0.0
|
|
578
|
+
*/
|
|
579
|
+
Scheduler
|
|
580
|
+
} from "./Scheduler.ts"
|