| 1 | import type * as Credentials from "@distilled.cloud/aws/Credentials"; |
| 2 | import type * as SigV4 from "@distilled.cloud/aws/SigV4"; |
| 3 | import type * as Effect from "effect/Effect"; |
| 4 | import * as Binding from "../../Binding.ts"; |
| 5 | import type { IngestRequest, PipelineIngestError } from "./BindingHttp.ts"; |
| 6 | import type { Pipeline } from "./Pipeline.ts"; |
| 7 | |
| 8 | export type { IngestRequest } from "./BindingHttp.ts"; |
| 9 | export { PipelineIngestError } from "./BindingHttp.ts"; |
| 10 | |
| 11 | /** |
| 12 | * Runtime binding for the `osis:Ingest` data plane. |
| 13 | * |
| 14 | * Sends events into the bound {@link Pipeline}'s ingest endpoint — the |
| 15 | * pipeline's actual data plane. There is no SDK operation for ingestion; |
| 16 | * each batch is a SigV4-signed HTTP POST (service `"osis"`) to the |
| 17 | * pipeline's ingest endpoint URL, made with the host Function's own |
| 18 | * credentials. The endpoint and pipeline name are injected from the binding; |
| 19 | * pass the source `path` configured on the pipeline's `http` source and the |
| 20 | * batch of events. Provide the implementation with |
| 21 | * `Effect.provide(AWS.OSIS.IngestHttp)`. |
| 22 | * ### Ingesting Data |
| 23 | * **Example:** Send a Batch of Log Events |
| 24 | * ```typescript |
| 25 | * // init — bind the data plane to the pipeline |
| 26 | * const ingest = yield* AWS.OSIS.Ingest(pipeline); |
| 27 | * |
| 28 | * // runtime — path must match the pipeline config's http source path |
| 29 | * yield* ingest({ |
| 30 | * path: "/logs/ingest", |
| 31 | * events: [{ message: "hello", level: "info" }], |
| 32 | * }); |
| 33 | * ``` |
| 34 | * |
| 35 | * @binding |
| 36 | */ |
| 37 | export interface Ingest extends Binding.Service< |
| 38 | Ingest, |
| 39 | "AWS.OSIS.Ingest", |
| 40 | ( |
| 41 | pipeline: Pipeline, |
| 42 | ) => Effect.Effect< |
| 43 | ( |
| 44 | request: IngestRequest, |
| 45 | ) => Effect.Effect< |
| 46 | void, |
| 47 | PipelineIngestError | Credentials.CredentialsError | SigV4.SigningError |
| 48 | > |
| 49 | > |
| 50 | > {} |
| 51 | export const Ingest = Binding.Service<Ingest>("AWS.OSIS.Ingest"); |