effect 4.0.0-beta.41 → 4.0.0-beta.42
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/Effect.d.ts +19 -63
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +24 -65
- package/dist/Effect.js.map +1 -1
- package/dist/MutableList.d.ts.map +1 -1
- package/dist/MutableList.js +3 -0
- package/dist/MutableList.js.map +1 -1
- package/dist/Number.d.ts.map +1 -1
- package/dist/Number.js +12 -3
- package/dist/Number.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +16 -14
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/TxChunk.d.ts +39 -39
- package/dist/TxChunk.d.ts.map +1 -1
- package/dist/TxChunk.js +3 -3
- package/dist/TxChunk.js.map +1 -1
- package/dist/TxDeferred.d.ts +9 -9
- package/dist/TxDeferred.d.ts.map +1 -1
- package/dist/TxDeferred.js +2 -2
- package/dist/TxDeferred.js.map +1 -1
- package/dist/TxHashMap.d.ts +59 -59
- package/dist/TxHashMap.d.ts.map +1 -1
- package/dist/TxHashMap.js +8 -8
- package/dist/TxHashMap.js.map +1 -1
- package/dist/TxHashSet.d.ts +35 -35
- package/dist/TxHashSet.d.ts.map +1 -1
- package/dist/TxHashSet.js +7 -7
- package/dist/TxHashSet.js.map +1 -1
- package/dist/TxPriorityQueue.d.ts +23 -23
- package/dist/TxPriorityQueue.d.ts.map +1 -1
- package/dist/TxPriorityQueue.js +4 -4
- package/dist/TxPriorityQueue.js.map +1 -1
- package/dist/TxPubSub.d.ts +14 -14
- package/dist/TxPubSub.d.ts.map +1 -1
- package/dist/TxPubSub.js +12 -12
- package/dist/TxPubSub.js.map +1 -1
- package/dist/TxQueue.d.ts +33 -33
- package/dist/TxQueue.d.ts.map +1 -1
- package/dist/TxQueue.js +29 -44
- package/dist/TxQueue.js.map +1 -1
- package/dist/TxReentrantLock.d.ts +10 -33
- package/dist/TxReentrantLock.d.ts.map +1 -1
- package/dist/TxReentrantLock.js +14 -37
- package/dist/TxReentrantLock.js.map +1 -1
- package/dist/TxRef.d.ts +36 -42
- package/dist/TxRef.d.ts.map +1 -1
- package/dist/TxRef.js +16 -25
- package/dist/TxRef.js.map +1 -1
- package/dist/TxSemaphore.d.ts +8 -8
- package/dist/TxSemaphore.d.ts.map +1 -1
- package/dist/TxSemaphore.js +10 -10
- package/dist/TxSemaphore.js.map +1 -1
- package/dist/TxSubscriptionRef.d.ts +14 -14
- package/dist/TxSubscriptionRef.d.ts.map +1 -1
- package/dist/TxSubscriptionRef.js +5 -5
- package/dist/TxSubscriptionRef.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/unstable/ai/OpenAiStructuredOutput.js +3 -0
- package/dist/unstable/ai/OpenAiStructuredOutput.js.map +1 -1
- package/dist/unstable/cli/internal/command.d.ts.map +1 -1
- package/dist/unstable/cli/internal/command.js +12 -1
- package/dist/unstable/cli/internal/command.js.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.d.ts.map +1 -1
- package/dist/unstable/cluster/SqlMessageStorage.js +1 -4
- package/dist/unstable/cluster/SqlMessageStorage.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +1 -1
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +1 -1
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/package.json +1 -1
- package/src/Effect.ts +24 -75
- package/src/MutableList.ts +3 -0
- package/src/Number.ts +13 -3
- package/src/SchemaRepresentation.ts +8 -6
- package/src/TxChunk.ts +53 -62
- package/src/TxDeferred.ts +14 -17
- package/src/TxHashMap.ts +91 -101
- package/src/TxHashSet.ts +68 -70
- package/src/TxPriorityQueue.ts +34 -38
- package/src/TxPubSub.ts +30 -32
- package/src/TxQueue.ts +70 -84
- package/src/TxReentrantLock.ts +30 -54
- package/src/TxRef.ts +53 -65
- package/src/TxSemaphore.ts +23 -24
- package/src/TxSubscriptionRef.ts +25 -27
- package/src/index.ts +3 -3
- package/src/unstable/ai/OpenAiStructuredOutput.ts +3 -0
- package/src/unstable/cli/internal/command.ts +16 -1
- package/src/unstable/cluster/SqlMessageStorage.ts +0 -4
- package/src/unstable/socket/Socket.ts +1 -1
package/src/TxPriorityQueue.ts
CHANGED
|
@@ -109,7 +109,7 @@ const insertSorted = <A>(chunk: Chunk<A>, value: A, ord: Order<A>): Chunk<A> =>
|
|
|
109
109
|
* @since 4.0.0
|
|
110
110
|
* @category constructors
|
|
111
111
|
*/
|
|
112
|
-
export const empty = <A>(order: Order<A>): Effect.Effect<TxPriorityQueue<A
|
|
112
|
+
export const empty = <A>(order: Order<A>): Effect.Effect<TxPriorityQueue<A>> =>
|
|
113
113
|
Effect.map(TxRef.make<Chunk<A>>(C.empty()), (ref) => makeTxPriorityQueue(ref, order))
|
|
114
114
|
|
|
115
115
|
/**
|
|
@@ -147,7 +147,7 @@ export const fromIterable: {
|
|
|
147
147
|
* @since 4.0.0
|
|
148
148
|
* @category constructors
|
|
149
149
|
*/
|
|
150
|
-
<A>(order: Order<A>): (iterable: Iterable<A>) => Effect.Effect<TxPriorityQueue<A
|
|
150
|
+
<A>(order: Order<A>): (iterable: Iterable<A>) => Effect.Effect<TxPriorityQueue<A>>
|
|
151
151
|
/**
|
|
152
152
|
* Creates a `TxPriorityQueue` from an iterable of elements.
|
|
153
153
|
*
|
|
@@ -165,10 +165,10 @@ export const fromIterable: {
|
|
|
165
165
|
* @since 4.0.0
|
|
166
166
|
* @category constructors
|
|
167
167
|
*/
|
|
168
|
-
<A>(order: Order<A>, iterable: Iterable<A>): Effect.Effect<TxPriorityQueue<A
|
|
168
|
+
<A>(order: Order<A>, iterable: Iterable<A>): Effect.Effect<TxPriorityQueue<A>>
|
|
169
169
|
} = dual(
|
|
170
170
|
2,
|
|
171
|
-
<A>(order: Order<A>, iterable: Iterable<A>): Effect.Effect<TxPriorityQueue<A
|
|
171
|
+
<A>(order: Order<A>, iterable: Iterable<A>): Effect.Effect<TxPriorityQueue<A>> => {
|
|
172
172
|
const arr = Array.from(iterable).sort((a, b) => order(a, b))
|
|
173
173
|
return Effect.map(
|
|
174
174
|
TxRef.make</**
|
|
@@ -211,9 +211,8 @@ export const fromIterable: {
|
|
|
211
211
|
* @since 4.0.0
|
|
212
212
|
* @category constructors
|
|
213
213
|
*/
|
|
214
|
-
export const make =
|
|
215
|
-
|
|
216
|
-
fromIterable(order, elements)
|
|
214
|
+
export const make = <A>(order: Order<A>) => (...elements: Array<A>): Effect.Effect<TxPriorityQueue<A>> =>
|
|
215
|
+
fromIterable(order, elements)
|
|
217
216
|
|
|
218
217
|
/**
|
|
219
218
|
* Returns the number of elements in the queue.
|
|
@@ -232,8 +231,7 @@ export const make =
|
|
|
232
231
|
* @since 4.0.0
|
|
233
232
|
* @category getters
|
|
234
233
|
*/
|
|
235
|
-
export const size = <A>(self: TxPriorityQueue<A>): Effect.Effect<number
|
|
236
|
-
Effect.map(TxRef.get(self.ref), C.size)
|
|
234
|
+
export const size = <A>(self: TxPriorityQueue<A>): Effect.Effect<number> => Effect.map(TxRef.get(self.ref), C.size)
|
|
237
235
|
|
|
238
236
|
/**
|
|
239
237
|
* Returns `true` if the queue is empty.
|
|
@@ -252,8 +250,7 @@ export const size = <A>(self: TxPriorityQueue<A>): Effect.Effect<number, never,
|
|
|
252
250
|
* @since 4.0.0
|
|
253
251
|
* @category getters
|
|
254
252
|
*/
|
|
255
|
-
export const isEmpty = <A>(self: TxPriorityQueue<A>): Effect.Effect<boolean
|
|
256
|
-
Effect.map(size(self), (n) => n === 0)
|
|
253
|
+
export const isEmpty = <A>(self: TxPriorityQueue<A>): Effect.Effect<boolean> => Effect.map(size(self), (n) => n === 0)
|
|
257
254
|
|
|
258
255
|
/**
|
|
259
256
|
* Returns `true` if the queue has at least one element.
|
|
@@ -272,8 +269,7 @@ export const isEmpty = <A>(self: TxPriorityQueue<A>): Effect.Effect<boolean, nev
|
|
|
272
269
|
* @since 4.0.0
|
|
273
270
|
* @category getters
|
|
274
271
|
*/
|
|
275
|
-
export const isNonEmpty = <A>(self: TxPriorityQueue<A>): Effect.Effect<boolean
|
|
276
|
-
Effect.map(size(self), (n) => n > 0)
|
|
272
|
+
export const isNonEmpty = <A>(self: TxPriorityQueue<A>): Effect.Effect<boolean> => Effect.map(size(self), (n) => n > 0)
|
|
277
273
|
|
|
278
274
|
/**
|
|
279
275
|
* Observes the smallest element without removing it. Retries if the queue is
|
|
@@ -293,15 +289,15 @@ export const isNonEmpty = <A>(self: TxPriorityQueue<A>): Effect.Effect<boolean,
|
|
|
293
289
|
* @since 4.0.0
|
|
294
290
|
* @category getters
|
|
295
291
|
*/
|
|
296
|
-
export const peek = <A>(self: TxPriorityQueue<A>): Effect.Effect<A
|
|
292
|
+
export const peek = <A>(self: TxPriorityQueue<A>): Effect.Effect<A> =>
|
|
297
293
|
Effect.gen(function*() {
|
|
298
294
|
const chunk = yield* TxRef.get(self.ref)
|
|
299
295
|
const head = C.head(chunk)
|
|
300
296
|
if (O.isNone(head)) {
|
|
301
|
-
return yield* Effect.
|
|
297
|
+
return yield* Effect.txRetry
|
|
302
298
|
}
|
|
303
299
|
return head.value
|
|
304
|
-
})
|
|
300
|
+
}).pipe(Effect.tx)
|
|
305
301
|
|
|
306
302
|
/**
|
|
307
303
|
* Observes the smallest element without removing it. Returns `None` if the
|
|
@@ -321,7 +317,7 @@ export const peek = <A>(self: TxPriorityQueue<A>): Effect.Effect<A, never, Effec
|
|
|
321
317
|
* @since 4.0.0
|
|
322
318
|
* @category getters
|
|
323
319
|
*/
|
|
324
|
-
export const peekOption = <A>(self: TxPriorityQueue<A>): Effect.Effect<Option<A
|
|
320
|
+
export const peekOption = <A>(self: TxPriorityQueue<A>): Effect.Effect<Option<A>> =>
|
|
325
321
|
Effect.map(TxRef.get(self.ref), C.head)
|
|
326
322
|
|
|
327
323
|
/**
|
|
@@ -363,7 +359,7 @@ export const offer: {
|
|
|
363
359
|
* @since 4.0.0
|
|
364
360
|
* @category mutations
|
|
365
361
|
*/
|
|
366
|
-
<A>(value: A): (self: TxPriorityQueue<A>) => Effect.Effect<void
|
|
362
|
+
<A>(value: A): (self: TxPriorityQueue<A>) => Effect.Effect<void>
|
|
367
363
|
/**
|
|
368
364
|
* Inserts an element into the queue in sorted position.
|
|
369
365
|
*
|
|
@@ -383,10 +379,10 @@ export const offer: {
|
|
|
383
379
|
* @since 4.0.0
|
|
384
380
|
* @category mutations
|
|
385
381
|
*/
|
|
386
|
-
<A>(self: TxPriorityQueue<A>, value: A): Effect.Effect<void
|
|
382
|
+
<A>(self: TxPriorityQueue<A>, value: A): Effect.Effect<void>
|
|
387
383
|
} = dual(
|
|
388
384
|
2,
|
|
389
|
-
<A>(self: TxPriorityQueue<A>, value: A): Effect.Effect<void
|
|
385
|
+
<A>(self: TxPriorityQueue<A>, value: A): Effect.Effect<void> =>
|
|
390
386
|
TxRef.update(self.ref, (chunk) => insertSorted(chunk, value, self.ord))
|
|
391
387
|
)
|
|
392
388
|
|
|
@@ -427,7 +423,7 @@ export const offerAll: {
|
|
|
427
423
|
* @since 4.0.0
|
|
428
424
|
* @category mutations
|
|
429
425
|
*/
|
|
430
|
-
<A>(values: Iterable<A>): (self: TxPriorityQueue<A>) => Effect.Effect<void
|
|
426
|
+
<A>(values: Iterable<A>): (self: TxPriorityQueue<A>) => Effect.Effect<void>
|
|
431
427
|
/**
|
|
432
428
|
* Inserts all elements from an iterable into the queue.
|
|
433
429
|
*
|
|
@@ -446,10 +442,10 @@ export const offerAll: {
|
|
|
446
442
|
* @since 4.0.0
|
|
447
443
|
* @category mutations
|
|
448
444
|
*/
|
|
449
|
-
<A>(self: TxPriorityQueue<A>, values: Iterable<A>): Effect.Effect<void
|
|
445
|
+
<A>(self: TxPriorityQueue<A>, values: Iterable<A>): Effect.Effect<void>
|
|
450
446
|
} = dual(
|
|
451
447
|
2,
|
|
452
|
-
<A>(self: TxPriorityQueue<A>, values: Iterable<A>): Effect.Effect<void
|
|
448
|
+
<A>(self: TxPriorityQueue<A>, values: Iterable<A>): Effect.Effect<void> =>
|
|
453
449
|
TxRef.update(self.ref, (chunk) => {
|
|
454
450
|
const arr = [...C.toArray(chunk), ...values].sort((a, b) => self.ord(a, b))
|
|
455
451
|
return C.fromIterable(arr)
|
|
@@ -473,16 +469,16 @@ export const offerAll: {
|
|
|
473
469
|
* @since 4.0.0
|
|
474
470
|
* @category mutations
|
|
475
471
|
*/
|
|
476
|
-
export const take = <A>(self: TxPriorityQueue<A>): Effect.Effect<A
|
|
472
|
+
export const take = <A>(self: TxPriorityQueue<A>): Effect.Effect<A> =>
|
|
477
473
|
Effect.gen(function*() {
|
|
478
474
|
const chunk = yield* TxRef.get(self.ref)
|
|
479
475
|
const head = C.head(chunk)
|
|
480
476
|
if (O.isNone(head)) {
|
|
481
|
-
return yield* Effect.
|
|
477
|
+
return yield* Effect.txRetry
|
|
482
478
|
}
|
|
483
479
|
yield* TxRef.set(self.ref, C.drop(chunk, 1))
|
|
484
480
|
return head.value
|
|
485
|
-
})
|
|
481
|
+
}).pipe(Effect.tx)
|
|
486
482
|
|
|
487
483
|
/**
|
|
488
484
|
* Takes all elements from the queue, returning them in priority order.
|
|
@@ -501,7 +497,7 @@ export const take = <A>(self: TxPriorityQueue<A>): Effect.Effect<A, never, Effec
|
|
|
501
497
|
* @since 4.0.0
|
|
502
498
|
* @category mutations
|
|
503
499
|
*/
|
|
504
|
-
export const takeAll = <A>(self: TxPriorityQueue<A>): Effect.Effect<Array<A
|
|
500
|
+
export const takeAll = <A>(self: TxPriorityQueue<A>): Effect.Effect<Array<A>> =>
|
|
505
501
|
Effect.map(
|
|
506
502
|
TxRef.modify(self.ref, (chunk) => [chunk, C.empty()]),
|
|
507
503
|
C.toArray
|
|
@@ -524,7 +520,7 @@ export const takeAll = <A>(self: TxPriorityQueue<A>): Effect.Effect<Array<A>, ne
|
|
|
524
520
|
* @since 4.0.0
|
|
525
521
|
* @category mutations
|
|
526
522
|
*/
|
|
527
|
-
export const takeOption = <A>(self: TxPriorityQueue<A>): Effect.Effect<Option<A
|
|
523
|
+
export const takeOption = <A>(self: TxPriorityQueue<A>): Effect.Effect<Option<A>> =>
|
|
528
524
|
TxRef.modify(self.ref, (chunk) => {
|
|
529
525
|
const head = C.head(chunk)
|
|
530
526
|
if (O.isNone(head)) {
|
|
@@ -568,7 +564,7 @@ export const takeUpTo: {
|
|
|
568
564
|
* @since 4.0.0
|
|
569
565
|
* @category mutations
|
|
570
566
|
*/
|
|
571
|
-
(n: number): <A>(self: TxPriorityQueue<A>) => Effect.Effect<Array<A
|
|
567
|
+
(n: number): <A>(self: TxPriorityQueue<A>) => Effect.Effect<Array<A>>
|
|
572
568
|
/**
|
|
573
569
|
* Takes up to `n` elements from the queue in priority order.
|
|
574
570
|
*
|
|
@@ -586,10 +582,10 @@ export const takeUpTo: {
|
|
|
586
582
|
* @since 4.0.0
|
|
587
583
|
* @category mutations
|
|
588
584
|
*/
|
|
589
|
-
<A>(self: TxPriorityQueue<A>, n: number): Effect.Effect<Array<A
|
|
585
|
+
<A>(self: TxPriorityQueue<A>, n: number): Effect.Effect<Array<A>>
|
|
590
586
|
} = dual(
|
|
591
587
|
2,
|
|
592
|
-
<A>(self: TxPriorityQueue<A>, n: number): Effect.Effect<Array<A
|
|
588
|
+
<A>(self: TxPriorityQueue<A>, n: number): Effect.Effect<Array<A>> =>
|
|
593
589
|
Effect.map(
|
|
594
590
|
TxRef.modify(self.ref, (chunk) => {
|
|
595
591
|
const taken = C.take(chunk, n)
|
|
@@ -637,7 +633,7 @@ export const removeIf: {
|
|
|
637
633
|
* @since 4.0.0
|
|
638
634
|
* @category filtering
|
|
639
635
|
*/
|
|
640
|
-
<A>(predicate: Predicate<A>): (self: TxPriorityQueue<A>) => Effect.Effect<void
|
|
636
|
+
<A>(predicate: Predicate<A>): (self: TxPriorityQueue<A>) => Effect.Effect<void>
|
|
641
637
|
/**
|
|
642
638
|
* Removes elements matching the predicate.
|
|
643
639
|
*
|
|
@@ -656,10 +652,10 @@ export const removeIf: {
|
|
|
656
652
|
* @since 4.0.0
|
|
657
653
|
* @category filtering
|
|
658
654
|
*/
|
|
659
|
-
<A>(self: TxPriorityQueue<A>, predicate: Predicate<A>): Effect.Effect<void
|
|
655
|
+
<A>(self: TxPriorityQueue<A>, predicate: Predicate<A>): Effect.Effect<void>
|
|
660
656
|
} = dual(
|
|
661
657
|
2,
|
|
662
|
-
<A>(self: TxPriorityQueue<A>, predicate: Predicate<A>): Effect.Effect<void
|
|
658
|
+
<A>(self: TxPriorityQueue<A>, predicate: Predicate<A>): Effect.Effect<void> =>
|
|
663
659
|
TxRef.update(self.ref, (chunk) => C.filter(chunk, (a) => !predicate(a)))
|
|
664
660
|
)
|
|
665
661
|
|
|
@@ -700,7 +696,7 @@ export const retainIf: {
|
|
|
700
696
|
* @since 4.0.0
|
|
701
697
|
* @category filtering
|
|
702
698
|
*/
|
|
703
|
-
<A>(predicate: Predicate<A>): (self: TxPriorityQueue<A>) => Effect.Effect<void
|
|
699
|
+
<A>(predicate: Predicate<A>): (self: TxPriorityQueue<A>) => Effect.Effect<void>
|
|
704
700
|
/**
|
|
705
701
|
* Retains only elements matching the predicate.
|
|
706
702
|
*
|
|
@@ -719,10 +715,10 @@ export const retainIf: {
|
|
|
719
715
|
* @since 4.0.0
|
|
720
716
|
* @category filtering
|
|
721
717
|
*/
|
|
722
|
-
<A>(self: TxPriorityQueue<A>, predicate: Predicate<A>): Effect.Effect<void
|
|
718
|
+
<A>(self: TxPriorityQueue<A>, predicate: Predicate<A>): Effect.Effect<void>
|
|
723
719
|
} = dual(
|
|
724
720
|
2,
|
|
725
|
-
<A>(self: TxPriorityQueue<A>, predicate: Predicate<A>): Effect.Effect<void
|
|
721
|
+
<A>(self: TxPriorityQueue<A>, predicate: Predicate<A>): Effect.Effect<void> =>
|
|
726
722
|
TxRef.update(self.ref, (chunk) => C.filter(chunk, predicate))
|
|
727
723
|
)
|
|
728
724
|
|
|
@@ -743,7 +739,7 @@ export const retainIf: {
|
|
|
743
739
|
* @since 4.0.0
|
|
744
740
|
* @category conversions
|
|
745
741
|
*/
|
|
746
|
-
export const toArray = <A>(self: TxPriorityQueue<A>): Effect.Effect<Array<A
|
|
742
|
+
export const toArray = <A>(self: TxPriorityQueue<A>): Effect.Effect<Array<A>> =>
|
|
747
743
|
Effect.map(TxRef.get(self.ref), C.toArray)
|
|
748
744
|
|
|
749
745
|
/**
|
package/src/TxPubSub.ts
CHANGED
|
@@ -118,12 +118,12 @@ const makeTxPubSub = <A>(
|
|
|
118
118
|
* @since 4.0.0
|
|
119
119
|
* @category constructors
|
|
120
120
|
*/
|
|
121
|
-
export const bounded = <A = never>(capacity: number): Effect.Effect<TxPubSub<A
|
|
121
|
+
export const bounded = <A = never>(capacity: number): Effect.Effect<TxPubSub<A>> =>
|
|
122
122
|
Effect.gen(function*() {
|
|
123
123
|
const subscribersRef = yield* TxRef.make<Array<TxQueue.TxQueue<A>>>([])
|
|
124
124
|
const shutdownRef = yield* TxRef.make(false)
|
|
125
125
|
return makeTxPubSub(subscribersRef, shutdownRef, "bounded", capacity)
|
|
126
|
-
})
|
|
126
|
+
}).pipe(Effect.tx)
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
129
|
* Creates a dropping TxPubSub with the specified capacity. When a subscriber's
|
|
@@ -153,12 +153,12 @@ export const bounded = <A = never>(capacity: number): Effect.Effect<TxPubSub<A>,
|
|
|
153
153
|
* @since 4.0.0
|
|
154
154
|
* @category constructors
|
|
155
155
|
*/
|
|
156
|
-
export const dropping = <A = never>(capacity: number): Effect.Effect<TxPubSub<A
|
|
156
|
+
export const dropping = <A = never>(capacity: number): Effect.Effect<TxPubSub<A>> =>
|
|
157
157
|
Effect.gen(function*() {
|
|
158
158
|
const subscribersRef = yield* TxRef.make<Array<TxQueue.TxQueue<A>>>([])
|
|
159
159
|
const shutdownRef = yield* TxRef.make(false)
|
|
160
160
|
return makeTxPubSub(subscribersRef, shutdownRef, "dropping", capacity)
|
|
161
|
-
})
|
|
161
|
+
}).pipe(Effect.tx)
|
|
162
162
|
|
|
163
163
|
/**
|
|
164
164
|
* Creates a sliding TxPubSub with the specified capacity. When a subscriber's
|
|
@@ -187,12 +187,12 @@ export const dropping = <A = never>(capacity: number): Effect.Effect<TxPubSub<A>
|
|
|
187
187
|
* @since 4.0.0
|
|
188
188
|
* @category constructors
|
|
189
189
|
*/
|
|
190
|
-
export const sliding = <A = never>(capacity: number): Effect.Effect<TxPubSub<A
|
|
190
|
+
export const sliding = <A = never>(capacity: number): Effect.Effect<TxPubSub<A>> =>
|
|
191
191
|
Effect.gen(function*() {
|
|
192
192
|
const subscribersRef = yield* TxRef.make<Array<TxQueue.TxQueue<A>>>([])
|
|
193
193
|
const shutdownRef = yield* TxRef.make(false)
|
|
194
194
|
return makeTxPubSub(subscribersRef, shutdownRef, "sliding", capacity)
|
|
195
|
-
})
|
|
195
|
+
}).pipe(Effect.tx)
|
|
196
196
|
|
|
197
197
|
/**
|
|
198
198
|
* Creates an unbounded TxPubSub with unlimited capacity. Messages are always accepted.
|
|
@@ -218,12 +218,12 @@ export const sliding = <A = never>(capacity: number): Effect.Effect<TxPubSub<A>,
|
|
|
218
218
|
* @since 4.0.0
|
|
219
219
|
* @category constructors
|
|
220
220
|
*/
|
|
221
|
-
export const unbounded = <A = never>(): Effect.Effect<TxPubSub<A
|
|
221
|
+
export const unbounded = <A = never>(): Effect.Effect<TxPubSub<A>> =>
|
|
222
222
|
Effect.gen(function*() {
|
|
223
223
|
const subscribersRef = yield* TxRef.make<Array<TxQueue.TxQueue<A>>>([])
|
|
224
224
|
const shutdownRef = yield* TxRef.make(false)
|
|
225
225
|
return makeTxPubSub(subscribersRef, shutdownRef, "unbounded", Number.POSITIVE_INFINITY)
|
|
226
|
-
})
|
|
226
|
+
}).pipe(Effect.tx)
|
|
227
227
|
|
|
228
228
|
// =============================================================================
|
|
229
229
|
// Getters
|
|
@@ -272,7 +272,7 @@ export const capacity = <A>(self: TxPubSub<A>): number => self.capacity
|
|
|
272
272
|
* @since 4.0.0
|
|
273
273
|
* @category getters
|
|
274
274
|
*/
|
|
275
|
-
export const size = <A>(self: TxPubSub<A>): Effect.Effect<number
|
|
275
|
+
export const size = <A>(self: TxPubSub<A>): Effect.Effect<number> =>
|
|
276
276
|
Effect.gen(function*() {
|
|
277
277
|
const subscribers = yield* TxRef.get(self.subscribersRef)
|
|
278
278
|
let maxSize = 0
|
|
@@ -281,7 +281,7 @@ export const size = <A>(self: TxPubSub<A>): Effect.Effect<number, never, Effect.
|
|
|
281
281
|
if (s > maxSize) maxSize = s
|
|
282
282
|
}
|
|
283
283
|
return maxSize
|
|
284
|
-
})
|
|
284
|
+
}).pipe(Effect.tx)
|
|
285
285
|
|
|
286
286
|
/**
|
|
287
287
|
* Checks if the TxPubSub has no pending messages (all subscriber queues are empty).
|
|
@@ -300,8 +300,7 @@ export const size = <A>(self: TxPubSub<A>): Effect.Effect<number, never, Effect.
|
|
|
300
300
|
* @since 4.0.0
|
|
301
301
|
* @category getters
|
|
302
302
|
*/
|
|
303
|
-
export const isEmpty = <A>(self: TxPubSub<A>): Effect.Effect<boolean
|
|
304
|
-
Effect.map(size(self), (s) => s === 0)
|
|
303
|
+
export const isEmpty = <A>(self: TxPubSub<A>): Effect.Effect<boolean> => Effect.map(size(self), (s) => s === 0)
|
|
305
304
|
|
|
306
305
|
/**
|
|
307
306
|
* Checks if any subscriber queue is at capacity.
|
|
@@ -320,7 +319,7 @@ export const isEmpty = <A>(self: TxPubSub<A>): Effect.Effect<boolean, never, Eff
|
|
|
320
319
|
* @since 4.0.0
|
|
321
320
|
* @category getters
|
|
322
321
|
*/
|
|
323
|
-
export const isFull = <A>(self: TxPubSub<A>): Effect.Effect<boolean
|
|
322
|
+
export const isFull = <A>(self: TxPubSub<A>): Effect.Effect<boolean> =>
|
|
324
323
|
Effect.gen(function*() {
|
|
325
324
|
if (self.capacity === Number.POSITIVE_INFINITY) return false
|
|
326
325
|
const subscribers = yield* TxRef.get(self.subscribersRef)
|
|
@@ -328,7 +327,7 @@ export const isFull = <A>(self: TxPubSub<A>): Effect.Effect<boolean, never, Effe
|
|
|
328
327
|
if (yield* TxQueue.isFull(queue)) return true
|
|
329
328
|
}
|
|
330
329
|
return false
|
|
331
|
-
})
|
|
330
|
+
}).pipe(Effect.tx)
|
|
332
331
|
|
|
333
332
|
/**
|
|
334
333
|
* Checks if the TxPubSub has been shut down.
|
|
@@ -348,8 +347,7 @@ export const isFull = <A>(self: TxPubSub<A>): Effect.Effect<boolean, never, Effe
|
|
|
348
347
|
* @since 4.0.0
|
|
349
348
|
* @category getters
|
|
350
349
|
*/
|
|
351
|
-
export const isShutdown = <A>(self: TxPubSub<A>): Effect.Effect<boolean
|
|
352
|
-
TxRef.get(self.shutdownRef)
|
|
350
|
+
export const isShutdown = <A>(self: TxPubSub<A>): Effect.Effect<boolean> => TxRef.get(self.shutdownRef)
|
|
353
351
|
|
|
354
352
|
// =============================================================================
|
|
355
353
|
// Mutations
|
|
@@ -430,7 +428,7 @@ export const publish: {
|
|
|
430
428
|
* @since 4.0.0
|
|
431
429
|
* @category mutations
|
|
432
430
|
*/
|
|
433
|
-
<A>(value: A): (self: TxPubSub<A>) => Effect.Effect<boolean
|
|
431
|
+
<A>(value: A): (self: TxPubSub<A>) => Effect.Effect<boolean>
|
|
434
432
|
// =============================================================================
|
|
435
433
|
// Mutations
|
|
436
434
|
// =============================================================================
|
|
@@ -470,10 +468,10 @@ export const publish: {
|
|
|
470
468
|
* @since 4.0.0
|
|
471
469
|
* @category mutations
|
|
472
470
|
*/
|
|
473
|
-
<A>(self: TxPubSub<A>, value: A): Effect.Effect<boolean
|
|
471
|
+
<A>(self: TxPubSub<A>, value: A): Effect.Effect<boolean>
|
|
474
472
|
} = dual(
|
|
475
473
|
2,
|
|
476
|
-
<A>(self: TxPubSub<A>, value: A): Effect.Effect<boolean
|
|
474
|
+
<A>(self: TxPubSub<A>, value: A): Effect.Effect<boolean> =>
|
|
477
475
|
Effect.gen(function*() {
|
|
478
476
|
if (yield* TxRef.get(self.shutdownRef)) return false
|
|
479
477
|
|
|
@@ -486,7 +484,7 @@ export const publish: {
|
|
|
486
484
|
}
|
|
487
485
|
|
|
488
486
|
return allAccepted
|
|
489
|
-
})
|
|
487
|
+
}).pipe(Effect.tx)
|
|
490
488
|
)
|
|
491
489
|
|
|
492
490
|
/**
|
|
@@ -546,7 +544,7 @@ export const publishAll: {
|
|
|
546
544
|
* @since 4.0.0
|
|
547
545
|
* @category mutations
|
|
548
546
|
*/
|
|
549
|
-
<A>(values: Iterable<A>): (self: TxPubSub<A>) => Effect.Effect<boolean
|
|
547
|
+
<A>(values: Iterable<A>): (self: TxPubSub<A>) => Effect.Effect<boolean>
|
|
550
548
|
/**
|
|
551
549
|
* Publishes all messages from an iterable to all current subscribers.
|
|
552
550
|
*
|
|
@@ -575,10 +573,10 @@ export const publishAll: {
|
|
|
575
573
|
* @since 4.0.0
|
|
576
574
|
* @category mutations
|
|
577
575
|
*/
|
|
578
|
-
<A>(self: TxPubSub<A>, values: Iterable<A>): Effect.Effect<boolean
|
|
576
|
+
<A>(self: TxPubSub<A>, values: Iterable<A>): Effect.Effect<boolean>
|
|
579
577
|
} = dual(
|
|
580
578
|
2,
|
|
581
|
-
<A>(self: TxPubSub<A>, values: Iterable<A>): Effect.Effect<boolean
|
|
579
|
+
<A>(self: TxPubSub<A>, values: Iterable<A>): Effect.Effect<boolean> =>
|
|
582
580
|
Effect.gen(function*() {
|
|
583
581
|
if (yield* TxRef.get(self.shutdownRef)) return false
|
|
584
582
|
|
|
@@ -588,7 +586,7 @@ export const publishAll: {
|
|
|
588
586
|
if (!accepted) allAccepted = false
|
|
589
587
|
}
|
|
590
588
|
return allAccepted
|
|
591
|
-
})
|
|
589
|
+
}).pipe(Effect.tx)
|
|
592
590
|
)
|
|
593
591
|
|
|
594
592
|
/**
|
|
@@ -623,8 +621,8 @@ export const publishAll: {
|
|
|
623
621
|
*/
|
|
624
622
|
export const subscribe = <A>(self: TxPubSub<A>): Effect.Effect<TxQueue.TxQueue<A>, never, Scope.Scope> =>
|
|
625
623
|
Effect.acquireRelease(
|
|
626
|
-
Effect.
|
|
627
|
-
(queue) => Effect.
|
|
624
|
+
Effect.tx(acquireSubscriber(self)),
|
|
625
|
+
(queue) => Effect.tx(releaseSubscriber(self, queue))
|
|
628
626
|
)
|
|
629
627
|
|
|
630
628
|
/**
|
|
@@ -691,7 +689,7 @@ export const releaseSubscriber: {
|
|
|
691
689
|
const makeSubscriberQueue = <A>(
|
|
692
690
|
strategy: "bounded" | "unbounded" | "dropping" | "sliding",
|
|
693
691
|
cap: number
|
|
694
|
-
): Effect.Effect<TxQueue.TxQueue<A
|
|
692
|
+
): Effect.Effect<TxQueue.TxQueue<A>> => {
|
|
695
693
|
switch (strategy) {
|
|
696
694
|
case "bounded":
|
|
697
695
|
return TxQueue.bounded<A>(cap)
|
|
@@ -727,7 +725,7 @@ const makeSubscriberQueue = <A>(
|
|
|
727
725
|
* @since 4.0.0
|
|
728
726
|
* @category mutations
|
|
729
727
|
*/
|
|
730
|
-
export const shutdown = <A>(self: TxPubSub<A>): Effect.Effect<void
|
|
728
|
+
export const shutdown = <A>(self: TxPubSub<A>): Effect.Effect<void> =>
|
|
731
729
|
Effect.gen(function*() {
|
|
732
730
|
const alreadyShutdown = yield* TxRef.get(self.shutdownRef)
|
|
733
731
|
if (alreadyShutdown) return
|
|
@@ -737,7 +735,7 @@ export const shutdown = <A>(self: TxPubSub<A>): Effect.Effect<void, never, Effec
|
|
|
737
735
|
for (const queue of subscribers) {
|
|
738
736
|
yield* TxQueue.shutdown(queue)
|
|
739
737
|
}
|
|
740
|
-
})
|
|
738
|
+
}).pipe(Effect.tx)
|
|
741
739
|
|
|
742
740
|
/**
|
|
743
741
|
* Waits for the TxPubSub to be shut down.
|
|
@@ -758,12 +756,12 @@ export const shutdown = <A>(self: TxPubSub<A>): Effect.Effect<void, never, Effec
|
|
|
758
756
|
* @since 4.0.0
|
|
759
757
|
* @category mutations
|
|
760
758
|
*/
|
|
761
|
-
export const awaitShutdown = <A>(self: TxPubSub<A>): Effect.Effect<void
|
|
759
|
+
export const awaitShutdown = <A>(self: TxPubSub<A>): Effect.Effect<void> =>
|
|
762
760
|
Effect.gen(function*() {
|
|
763
761
|
const shut = yield* TxRef.get(self.shutdownRef)
|
|
764
762
|
if (shut) return
|
|
765
|
-
return yield* Effect.
|
|
766
|
-
})
|
|
763
|
+
return yield* Effect.txRetry
|
|
764
|
+
}).pipe(Effect.tx)
|
|
767
765
|
|
|
768
766
|
// =============================================================================
|
|
769
767
|
// Guards
|