@rtorcato/cf-common
Interfaces
PipelineProducer
Defined in: index.ts:8
A typed producer bound to one Pipeline binding.
Type Parameters
T
T extends PipelineRecord
Methods
send()
send(
record):Promise<void>
Defined in: index.ts:10
Send one record. Throws PIPELINE_SEND_FAILED if the binding rejects it.
Parameters
record
T
Returns
Promise<void>
sendBatch()
sendBatch(
records,options?):Promise<void>
Defined in: index.ts:16
Send many records, split into send calls of chunkSize (default 100).
Chunks are sent in order and sending stops at the first failure, so
earlier chunks stay delivered. Throws PIPELINE_SEND_FAILED.
Parameters
records
Iterable<T>
options?
chunkSize?
number
Returns
Promise<void>
Functions
createPipelineProducer()
createPipelineProducer<
T>(pipeline):PipelineProducer<T>
Defined in: index.ts:30
Wrap a Pipeline binding (R2-backed streaming ingestion) so send and
sendBatch take plain, typed records and failures surface as a
CloudflareError. The record type T is asserted by the caller and
not validated at runtime.
Example
const events = createPipelineProducer<{ userId: string; action: string }>(env.EVENTS)
await events.send({ userId: 'u_1', action: 'login' })
await events.sendBatch(rows.map((r) => ({ userId: r.id, action: 'import' })))
Type Parameters
T
T extends PipelineRecord = PipelineRecord
Parameters
pipeline
Pipeline<T>