/** * @since 1.0.0 */ import type { Pipeable } from "@effect/data/Pipeable" import type * as Effect from "@effect/io/Effect" import type * as Fiber from "@effect/io/Fiber" import * as internal from "@effect/io/internal/metric/polling" import type * as Metric from "@effect/io/Metric" import type * as Schedule from "@effect/io/Schedule" import type * as Scope from "@effect/io/Scope" /** * @since 1.0.0 * @category symbols */ export const PollingMetricTypeId: unique symbol = internal.PollingMetricTypeId /** * @since 1.0.0 * @category symbols */ export type PollingMetricTypeId = typeof PollingMetricTypeId /** * A `PollingMetric` is a combination of a metric and an effect that polls for * updates to the metric. * * @since 1.0.0 * @category models */ export interface PollingMetric extends Pipeable { readonly [PollingMetricTypeId]: PollingMetricTypeId /** * The metric that this `PollingMetric` polls to update. */ readonly metric: Metric.Metric /** * An effect that polls a value that may be fed to the metric. */ readonly poll: Effect.Effect } /** * Constructs a new polling metric from a metric and poll effect. * * @since 1.0.0 * @category constructors */ export const make: ( metric: Metric.Metric, poll: Effect.Effect ) => PollingMetric = internal.make /** * Collects all of the polling metrics into a single polling metric, which * polls for, updates, and produces the outputs of all individual metrics. * * @since 1.0.0 * @category constructors */ export const collectAll: ( iterable: Iterable> ) => PollingMetric, Array, R, E, Array> = internal.collectAll /** * Returns an effect that will launch the polling metric in a background * fiber, using the specified schedule. * * @since 1.0.0 * @category utils */ export const launch: { ( schedule: Schedule.Schedule ): ( self: PollingMetric ) => Effect.Effect> ( self: PollingMetric, schedule: Schedule.Schedule ): Effect.Effect> } = internal.launch /** * An effect that polls a value that may be fed to the metric. * * @since 1.0.0 * @category utils */ export const poll: (self: PollingMetric) => Effect.Effect = internal.poll /** * An effect that polls for a value and uses the value to update the metric. * * @since 1.0.0 * @category utils */ export const pollAndUpdate: ( self: PollingMetric ) => Effect.Effect = internal.pollAndUpdate /** * Returns a new polling metric whose poll function will be retried with the * specified retry policy. * * @since 1.0.0 * @category constructors */ export const retry: { ( policy: Schedule.Schedule ): (self: PollingMetric) => PollingMetric ( self: PollingMetric, policy: Schedule.Schedule ): PollingMetric } = internal.retry /** * Zips this polling metric with the specified polling metric. * * @since 1.0.0 * @category utils */ export const zip: { ( that: PollingMetric ): ( self: PollingMetric ) => PollingMetric ( self: PollingMetric, that: PollingMetric ): PollingMetric } = internal.zip