Snowpipe Streaming Node.js SDK v1.8.0
    Preparing search index...

    Class StreamingIngestElasticChannel

    An elastic channel for streaming data into a Snowflake table.

    Unlike a regular channel, an elastic channel has no offset tokens and its lifecycle is tied to the client — there is no close method, and the same instance is returned on repeated calls to client.getElasticChannel(). Appends come in two flavours: fire-and-forget appendRow/appendRows return nothing, while appendRowWithWait/appendRowsWithWait return a promise that resolves when Snowflake acknowledges the rows. Every append must carry an opaque appendToken — required, but nullable — handed back to the handler registered via setErrorHandler when that append fails asynchronously, or to setSuccessHandler when it is acknowledged; pass null to opt that append out of both handlers.

    Create instances using client.getElasticChannel().

    Index

    Properties

    binaryInputFormat: string

    The binary input format. One of: "BASE64", "HEX", "UTF-8".

    channelName: string

    The channel name (always "ELASTIC").

    dbName: string

    The database name.

    isClosed: boolean

    Whether the channel is closed (because the client was closed).

    pipeName: string

    The pipe name.

    schemaName: string

    The schema name.

    Methods

    • Append a single row into the elastic channel without waiting for the acknowledgement (fire-and-forget). The append is still registered for the error handler, so an asynchronous failure is reported through setErrorHandler (keyed by appendToken), just not through a promise. Use appendRowWithWait when you need one to await.

      Parameters

      • row: Record<string, any>

        Row data as column-name to value pairs

      • appendToken: unknown

        Required caller-supplied opaque id for this append, handed to the setErrorHandler handler on asynchronous failure, or to the setSuccessHandler handler on acknowledgement. Not sent to Snowflake; any value (including "") is valid. The argument is mandatory: pass null explicitly to leave the append untracked for both handlers. The token is retained in memory until the append is acknowledged, so a large object raises the memory footprint of in-flight appends — prefer a small value.

      Returns void

      TypeError If row is null or undefined

      StreamingIngestError If the row appending fails synchronously

    • Append multiple rows into the elastic channel without waiting for the acknowledgement (fire-and-forget). The append is still registered for the error handler, so an asynchronous failure is reported through setErrorHandler (keyed by appendToken), just not through a promise. Use appendRowsWithWait when you need one to await.

      Parameters

      • rows: Record<string, any>[]

        Array of row objects (column-name to value pairs)

      • appendToken: unknown

        Required caller-supplied opaque id for this batch, handed to the setErrorHandler handler on asynchronous failure, or to the setSuccessHandler handler on acknowledgement. Not sent to Snowflake; any value (including "") is valid. The argument is mandatory: pass null explicitly to leave the append untracked for both handlers. The token is retained in memory until the append is acknowledged, so a large object raises the memory footprint of in-flight appends — prefer a small value.

      Returns void

      TypeError If rows is not an array

      StreamingIngestError If the rows appending fails synchronously

    • Append multiple rows into the elastic channel. The returned promise resolves when Snowflake acknowledges the batch. If an error handler is registered it also fires on an asynchronous failure — dual delivery.

      Parameters

      • rows: Record<string, any>[]

        Array of row objects (column-name to value pairs)

      • appendToken: unknown

        Required caller-supplied opaque id for this batch, handed to the setErrorHandler handler on asynchronous failure, or to the setSuccessHandler handler on acknowledgement. Not sent to Snowflake; any value (including "") is valid. The argument is mandatory: pass null explicitly to leave the append untracked for both handlers. The token is retained in memory until the append is acknowledged, so a large object raises the memory footprint of in-flight appends — prefer a small value.

      Returns Promise<void>

      TypeError If rows is not an array

      StreamingIngestError If the rows appending fails

    • Append a single row into the elastic channel. The returned promise resolves when Snowflake acknowledges the row. If an error handler is registered it also fires on an asynchronous failure — dual delivery.

      Parameters

      • row: Record<string, any>

        Row data as column-name to value pairs

      • appendToken: unknown

        Required caller-supplied opaque id for this append, handed to the setErrorHandler handler on asynchronous failure, or to the setSuccessHandler handler on acknowledgement. Not sent to Snowflake; any value (including "") is valid. The argument is mandatory: pass null explicitly to leave the append untracked for both handlers. The token is retained in memory until the append is acknowledged, so a large object raises the memory footprint of in-flight appends — prefer a small value.

      Returns Promise<void>

      StreamingIngestError If the row appending fails

    • Get the current status of this channel.

      Returns Promise<ChannelStatus>

      StreamingIngestError If getting the channel status fails

    • Initiate a flush of all buffered data for this channel but do not wait for the flush to complete.

      Returns void

      StreamingIngestError If the flush cannot be initiated

    • Register (or replace) a handler invoked when appends fail asynchronously, i.e. after the append call already returned. Fires once per failure event with a single ErrorDetail bundling the appendTokens that failed together (a server-ack batch, or every in-flight append on invalidation) and their common error, so callers need not await each promise. Both append flavours are covered: it is the only failure signal for the fire-and-forget ones, and an additional one for the WithWait ones, whose promise still rejects. Only appends given an appendToken appear, and tokens are opaque and not deduplicated. Synchronous failures (closed channel, serialization, bad arguments) throw from the append call and never reach the handler. A handler that throws is caught and logged.

      Parameters

      Returns void

      TypeError If handler is not a function, or declares more than one parameter (it is called with a single ErrorDetail)

    • Register (or replace) a handler invoked when appends are acknowledged by Snowflake. Fires once per successful ack batch with a single SuccessDetail bundling the appendTokens acknowledged together, so callers need not await each promise. Both append flavours are covered: it is the only success signal for the fire-and-forget ones, and an additional one for the WithWait ones, whose promise still resolves. Purely opt-in — without a registered handler nothing is collected. Only appends given an appendToken appear, and tokens are opaque and not deduplicated. A handler that throws is caught and logged.

      Like the error handler, this runs on the acknowledgement path, so a slow handler delays subsequent acknowledgements — keep it short.

      Parameters

      Returns void

      TypeError If handler is not a function, or declares more than one parameter (it is called with a single SuccessDetail)

    • Wait for all buffered data in this channel to be flushed to Snowflake.

      Parameters

      • Optionaloptions: { timeoutMs?: number }

        Wait options

        • OptionaltimeoutMs?: number

          Optional timeout in milliseconds.

      Returns Promise<void>

      StreamingIngestError If waiting for the flush fails

      Error If the timeout is reached