Add Effect v4 support, Fast Refresh tooling, and revamped docs #56
@@ -1,4 +1,4 @@
|
|||||||
import { type Cause, Context, DateTime, type Duration, Effect, Equal, Exit, HashMap, Layer, Option, Scope, Semaphore, Stream, SubscriptionRef } from "effect"
|
import { type Cause, Context, DateTime, type Duration, Effect, Equal, Exit, HashMap, Layer, Option, Order, Scope, Semaphore, Stream, SubscriptionRef } from "effect"
|
||||||
|
|
||||||
|
|
||||||
export interface ScopeRegistryService {
|
export interface ScopeRegistryService {
|
||||||
@@ -159,18 +159,20 @@ export class ScopeRegistryServiceImpl implements ScopeRegistryService {
|
|||||||
getNextExpiration(
|
getNextExpiration(
|
||||||
entries: HashMap.HashMap<ScopeRegistryService.Key, ScopeRegistryService.Entry>,
|
entries: HashMap.HashMap<ScopeRegistryService.Key, ScopeRegistryService.Entry>,
|
||||||
): Option.Option<DateTime.Utc> {
|
): Option.Option<DateTime.Utc> {
|
||||||
let earliest: DateTime.Utc | undefined
|
return HashMap.reduce(
|
||||||
|
entries,
|
||||||
for (const entry of HashMap.values(entries)) {
|
Option.none<DateTime.Utc>(),
|
||||||
if (
|
(earliest, entry) => Option.match(
|
||||||
entry.leases === 0 &&
|
Option.filter(entry.expiresAt, () => entry.leases === 0),
|
||||||
entry.expiresAt._tag === "Some" &&
|
{
|
||||||
(!earliest || DateTime.isLessThan(entry.expiresAt.value, earliest))
|
onNone: () => earliest,
|
||||||
)
|
onSome: expiresAt => Option.some(Option.match(earliest, {
|
||||||
earliest = entry.expiresAt.value
|
onNone: () => expiresAt,
|
||||||
}
|
onSome: Order.min<DateTime.Utc>(DateTime.Order)(expiresAt),
|
||||||
|
})),
|
||||||
return Option.fromNullishOr(earliest)
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user