Limiter + usage nest on an HttpApiClient handle.
export interface HttpApiClientMetrics {
readonly HttpApiClientMetrics.remaining: Hyperlink.Subscribable<number>(property) HttpApiClientMetrics.remaining: {
get: Effect.Effect<A>;
changes: Stream.Stream<A>;
}
remaining: import HyperlinkHyperlink.interface Subscribable<A>A read-only reactive value: its current value (
Subscribable.get
, an Effect) plus a stream
of every change (
Subscribable.changes
). This is what a
ref
field surfaces — uniform local
and remote — and it's exactly the read side of a SubscriptionRef (Effect ships no Subscribable type in
this beta, so we name it here).
Subscribable<number>;
readonly HttpApiClientMetrics.resetAfter: Hyperlink.Subscribable<number>(property) HttpApiClientMetrics.resetAfter: {
get: Effect.Effect<A>;
changes: Stream.Stream<A>;
}
resetAfter: import HyperlinkHyperlink.interface Subscribable<A>A read-only reactive value: its current value (
Subscribable.get
, an Effect) plus a stream
of every change (
Subscribable.changes
). This is what a
ref
field surfaces — uniform local
and remote — and it's exactly the read side of a SubscriptionRef (Effect ships no Subscribable type in
this beta, so we name it here).
Subscribable<number>;
readonly HttpApiClientMetrics.exceeded: Hyperlink.Subscribable<number>(property) HttpApiClientMetrics.exceeded: {
get: Effect.Effect<A>;
changes: Stream.Stream<A>;
}
exceeded: import HyperlinkHyperlink.interface Subscribable<A>A read-only reactive value: its current value (
Subscribable.get
, an Effect) plus a stream
of every change (
Subscribable.changes
). This is what a
ref
field surfaces — uniform local
and remote — and it's exactly the read side of a SubscriptionRef (Effect ships no Subscribable type in
this beta, so we name it here).
Subscribable<number>;
readonly HttpApiClientMetrics.usage: Hyperlink.Subscribable<ApiUsageSnapshot>(property) HttpApiClientMetrics.usage: {
get: Effect.Effect<A>;
changes: Stream.Stream<A>;
}
usage: import HyperlinkHyperlink.interface Subscribable<A>A read-only reactive value: its current value (
Subscribable.get
, an Effect) plus a stream
of every change (
Subscribable.changes
). This is what a
ref
field surfaces — uniform local
and remote — and it's exactly the read side of a SubscriptionRef (Effect ships no Subscribable type in
this beta, so we name it here).
Subscribable<type ApiUsageSnapshot = {
readonly clientId: string;
readonly inFlight: number;
readonly requestsTotal: number;
readonly errorsTotal: number;
readonly topEndpoints: readonly Struct.ReadonlySide<{
readonly group: String;
readonly endpoint: String;
readonly requests: Number;
readonly errors: Number;
}, "Type">[];
}
ApiUsageSnapshot>;
readonly HttpApiClientMetrics.windows: Stream.Stream<ApiUsageMetrics>(property) HttpApiClientMetrics.windows: {
channel: Channel.Channel<Arr.NonEmptyReadonlyArray<A>, E, void, unknown, unknown, unknown, R>;
pipe: { <A>(this: A): A; <A, B = never>(this: A, ab: (_: A) => B): B; <A, B = never, C = never>(this: A, ab: (_: A) => B, bc: (_: B) => C): C; <A, B = never, C = never, D = never>(this: A, ab: (_: A) => B, bc: (_: B) => C, cd: (_: C) => D): D; <…;
}
windows: import("effect").import StreamStream.interface Stream<out A, out E = never, out R = never>A Stream<A, E, R> describes a program that can emit many A values, fail
with E, and require R.
Details
Streams are pull-based with backpressure and emit chunks to amortize effect
evaluation. They support monadic composition and error handling similar to
Effect, adapted for multiple values.
Example (Creating and consuming streams)
import { Console, Effect, Stream } from "effect"
const program = Effect.gen(function*() {
yield* Stream.make(1, 2, 3).pipe(
Stream.map((n) => n * 2),
Stream.runForEach((n) => Console.log(n))
)
})
Effect.runPromise(program)
// Output:
// 2
// 4
// 6
Stream<type ApiUsageMetrics = {
readonly windowStart: Utc;
readonly windowEnd: Utc;
readonly windowMillis: number;
readonly requests: number;
readonly errors: number;
readonly inFlight: number;
readonly throughputPerSec: number;
readonly byEndpoint: readonly {
readonly group: string;
readonly endpoint: string;
readonly requests: number;
readonly errors: number;
readonly avgDurationMs?: number | undefined;
}[];
}
ApiUsageMetrics>;
}