Node SDK

Class RStreamsSdk

Legend

  • Namespace
  • Variable
  • Function
  • Function with type parameter
  • Type alias
  • Type alias with type parameter
  • Class
  • Constructor
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Enumeration

The main entry point for the RStreams Node SDK. It exposes commonly used functionality in the SDK. Many of these functions come from StreamUtil which also includes more advanced capabilities.

Hierarchy

  • RStreamsSdk

Index

Constructors

Properties

aws: { cloudformation: CloudFormation; dynamodb: LeoDynamodb; firehose: Firehose; kinesis: Kinesis; s3: S3 }

Type declaration

  • cloudformation: CloudFormation

    A refernce to the AWS CloudFormation library.

  • dynamodb: LeoDynamodb

    Helpful methods for interacting with RStreams' DynamoDB tables.

  • firehose: Firehose

    A refernce to the AWS Firehose library.

  • kinesis: Kinesis

    A refernce to the AWS Kinesis library.

  • s3: S3

    A refernce to the AWS S3 library.

bot: LeoCron

A library allowing one to manually create, update, checkpoint or retrieve information on a bot.

configuration: Configuration

Config used to communicate with AWS resources that comprise the RStreams Bus used by the SDK. It is included here for information purposes and so you can access the AWS resources that the SDK discovered and is using.

see

ConfigProviderChain

streams: typeof StreamUtil
returns

Rstreams Used to get the leo stream to do more advanced processing of the streams.

Methods

checkpoint: (config?: ToCheckpointOptions) => WritableStream<unknown>

Type declaration

    • This is only to be used internally by the SDK. It used to be necessary externally and so remains for backward comaptibiliy.

      Creates a pipeline step that will checkpoint and then pass the events on to the next step in the pipeline.

      internal

      Parameters

      Returns WritableStream<unknown>

      The pipeline step that is ready to be used in a pipeline

createSource: <T, R>(fn: CreateSourceFunction<T, R>, opt?: CreateSourceOptions, state?: R) => ReadableStream<T>

Type declaration

    • A stream generated from a function that returns and array of data of type T

      Allows for custom state to be kept and passed to the function generating new data

      Type parameters

      • T

        The data emitted from the stream

      • R = any

        The current state of the source stream

      Parameters

      Returns ReadableStream<T>

      A Stream of data type T

destroy: (callback: (err: any) => void) => void

Type declaration

    • (callback: (err: any) => void): void
    • deprecated

      This is a legacy feature that is no longer used that remains for backward compatibility.

      Parameters

      • callback: (err: any) => void
          • (err: any): void
          • Parameters

            • err: any

            Returns void

      Returns void

enrich: { <T, U>(opts: EnrichOptions<T, U>, callback: Callback): void; <T, U>(opts: EnrichBatchOptions<T, U>, callback: Callback): void }

Type declaration

    • This is a callback-based version of the RStreamsSdk.enrichEvents function and should no longer be used. Callback-based API flavors will be phased out over time.

      It reads events from one queue and writes them to another queue. Put another way, an enrich operation reads events from a source inQueue and then writes them to a destination outQueue, allowing for side effects or transformation in the process.

      The EnrichOptions.transform function is called when events are retrieved from the source queue so you can transform them and send them to the destination queue by calling the callback in the transform function. The callback here as the second argument of this function is meant to be called when all enriching is done on all events (right before it closes down the stream), allowing you to do clean up like closing a DB connection or something.

      deprecated

      Please use RStreamsSdk.enrichEvents

      Type parameters

      • T

        The type of the data event retrieved from the source queue

      • U

        The type of the data event that is sent to the destination queue

      Parameters

      • opts: EnrichOptions<T, U>

        The details of how to enrich and the function that does the work to enrich, either the batched or not batched version. The batched version will batch up requests to your transform function and pass it an array instead of a single object.

      • callback: Callback

        A function called when all events have been processed

      Returns void

    • Type parameters

      • T

      • U

      Parameters

      Returns void

enrichEvents: <T, U>(opts: EnrichOptions<T, U> | EnrichBatchOptions<T, U>) => Promise<void>

Type declaration

    • This is an async/await friendly version of the RStreamsSdk.enrich function.

      It reads events from one queue and writes them to another queue. Put another way, an enrich operation reads events from a source inQueue and then writes them to a destination outQueue, allowing for side effects or transformation in the process.

      The EnrichOptions.transform function is called when events are retrieved from the source queue so you can transform them and send them to the destination queue by calling the callback in the transform function. The callback here as the second argument of this function is meant to be called when all enriching is done on all events (right before it closes down the stream), allowing you to do clean up like closing a DB connection or something.

      see

      RStreamsSdk.enrich

      Type parameters

      • T

        The type of the event read from the source queue

      • U

        The type of the event that will be written to the destination queue

      Parameters

      • opts: EnrichOptions<T, U> | EnrichBatchOptions<T, U>

        The details of how to enrich and the function that does the work to enrich, either the batched or not batched version. The batched version will batch up requests to your transform function and pass it an array instead of a single object.

      Returns Promise<void>

load: <T>(botId?: string, outQueue?: string, config?: WriteOptions) => WritableStream<BaseEvent<T> | T>

Type declaration

    • This creates a pipeline step that acts as the last step of the pipeline, the sink, writing events sent to the pipeline step to the queue specified.

      Type parameters

      • T

        The type of the data received by the pipeline step

      Parameters

      • Optional botId: string

        For events that don't specify the bot to act as, this default is used. It is the bot to act as when writing, events will be marked as written by this bot. If not provided, each event must include the id of the bot to write the event as.

      • Optional outQueue: string

        For events that don't specify the queue to write to, this default is used. It is the queue into which events will be written. If not provided, each event must include the queue to write the event to.

      • Optional config: WriteOptions

        An object that contains config values that control the flow of events to outQueue

      Returns WritableStream<BaseEvent<T> | T>

offload: { <T>(config: OffloadOptions<T>, callback: Callback): void; <T>(config: OffloadBatchOptions<T>, callback: Callback): void }

Type declaration

    • This is a callback-based version of the RStreamsSdk.offloadEvents function and should no longer be used. Callback-based API flavors will be phased out over time.

      It reads events from a queue to do general processing (such as write to an external DB). It's called offload because it is commonly used to process events and offload them to external resources such as ElasticSearch or other databases that are off of the RStreams Bus.

      It reads from the queue specified in opts and then calls the opts.transform function passing in the events retrieved so they may be processed.

      deprecated

      Please use RStreamsSdk.offloadEvents

      Type parameters

      • T

        The type of the data read from the RStreams bus queue

      Parameters

      Returns void

    • Type parameters

      • T

      Parameters

      Returns void

offloadEvents: <T>(config: OffloadOptions<T> | OffloadBatchOptions<T>) => Promise<void>

Type declaration

    • This is an async/await friendly version of RStreamsSdk.offload.

      It reads events from a queue to do general processing (such as write to an external DB). It's called offload because it is commonly used to process events and offload them to external resources such as ElasticSearch or other databases that are off of the RStreams Bus.

      see

      RStreamsSdk.offload

      Type parameters

      • T

      Parameters

      Returns Promise<void>

put: <T>(bot_id: string, outQueue: string, payload: T | Event<T>, callback: Callback) => void

Type declaration

    • <T>(bot_id: string, outQueue: string, payload: T | Event<T>, callback: Callback): void
    • This is a callback-based version of the RStreamsSdk.putEvent function and should no longer be used. Callback-based API flavors will be phased out over time.

      A callback-based function to write a single event to an RStreams queue. There are occasions where this is useful, perhaps inside a pipeline step.

      deprecated

      Please use RStreamsSdk.putEvent

      Type parameters

      • T

        The data to write as the payload of the event

      Parameters

      • bot_id: string

        The name of the bot to write the event as

      • outQueue: string

        The name of the queue to write to

      • payload: T | Event<T>

        The data to write to the queue

      • callback: Callback

        The function to call when done

      Returns void

putEvent: <T>(bot_id: string, outQueue: string, payload: T | Event<T>) => Promise<void>

Type declaration

    • <T>(bot_id: string, outQueue: string, payload: T | Event<T>): Promise<void>
    • An async/await friendly function to write a single event to a queue. There are occasions where this is useful, perhaps inside a pipeline step.

      Type parameters

      • T

        The data to write as the payload of the event

      Parameters

      • bot_id: string

        The name of the bot to write the event as

      • outQueue: string

        The name of the queue to write to

      • payload: T | Event<T>

        The payload of the event to write

      Returns Promise<void>

read: <T>(botId: string, inQueue: string, config?: ReadOptions) => ReadableQueueStream<T>

Type declaration

    • Create a pipeline step that reads from the RStreams bus instance queue inQueue doing so as bot botId.

      Type parameters

      • T

        The type of data that will be read from the queue.

      Parameters

      • botId: string

        The bot to read as

      • inQueue: string

        The queue to read from

      • Optional config: ReadOptions

        The options on how to read from this queue

      Returns ReadableQueueStream<T>

      The pipeline step that is ready to be used in a pipeline

throughAsync: <T, U>(transform?: (this: TransformStream<T, U>, obj: T) => U | Promise<U>, flush?: (this: TransformStream<T, U>) => U | Promise<U>) => TransformStream<T, U>

Type declaration

    • This creates an async/await-friendly pipeline step that will take data in, possibly transform the data or do computation, and then sends the result on to the next step in the pipeline.

      see

      through

      Type parameters

      • T

        The type of the data sent in to be passed through this step.

      • U

        The type of data to be sent on to the next step in the pipeline.

      Parameters

      • Optional transform: (this: TransformStream<T, U>, obj: T) => U | Promise<U>

        A function that does the work of taking the data in, doing something with it and then rejecting or resolving the promise with the result object type U. If you resolve with no result data, the event is skipped and not sent to the next pipeline step. The first arg is stripped off by Javascript since it recognizes that the this arg is just to set the this context so that the this keyword will work inside the function and itself be the instance of the transform stream which can be useful. For example, say you want to push to an event in here to a queue. You could do that by calling this.push to push the event to a queue while still sending the queue on the next step in the pipeline afterwards.

        So, the first real argument your function will receive is obj which is the data event being sent in to be processed/transformed and sent on to the next pipeline step.

      • Optional flush: (this: TransformStream<T, U>) => U | Promise<U>

        A function to be called when the entire pipeline has been flushed to allow for cleanup, perhaps closing a DB connection.

      Returns TransformStream<T, U>

      The pipeline step that is ready to be used in a pipeline

write: <T>(botId: string, config?: BaseWriteOptions) => TransformStream<Event<T>, unknown>

Type declaration

    • Create a pipeline step that takes the events from the previous pipeline step and then writes them to an RStreams bus queue.

      Type parameters

      • T

      Parameters

      • botId: string

        The bot to act as when writing.

      • Optional config: BaseWriteOptions

        Options for writing

      Returns TransformStream<Event<T>, unknown>

      The pipeline step that is ready to be used in a pipeline

Generated using TypeDoc