Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

streamdal/node-sdk

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
Jacob Heric
Oct 11, 2023
7d42768 · Oct 11, 2023

History

83 Commits
Oct 11, 2023
Jul 6, 2023
Oct 11, 2023
Oct 11, 2023
Aug 23, 2023
Sep 13, 2023
Jun 27, 2023
Jul 31, 2023
Jun 26, 2023
Oct 11, 2023
Oct 11, 2023
Oct 11, 2023
Oct 11, 2023
Sep 13, 2023
Oct 11, 2023
Oct 11, 2023
Sep 13, 2023
Sep 13, 2023
Sep 13, 2023
Oct 11, 2023

Repository files navigation

Streamdal's Node SDK

Getting started

Optionally copy example.env -> .env and specify any custom env vars.

To use the sdk in your node app:

npm install @streamdal/node-sdk

Then construct an instance of "@streamdal/node-sdk/streamdal.js" and use that to process your data:

const config: StreamdalConfigs = {
  streamdalUrl: "localhost:9091",
  streamdalToken: "1234",
  serviceName: "test-service-name",
  pipelineTimeout: "100",
  stepTimeout: "10",
  dryRun: "false",
};

const audience: Audience = {
  serviceName: "test-service-name",
  componentName: "kafka",
  operationType: OperationType.CONSUMER,
  operationName: "test-kafka-consumer",
};

export const example = async () => {
  const streamdal = new Streamdal(config);
  const result = await streamdal.processPipeline({
    audience,
    data: new TextEncoder().encode(JSON.stringify(exampleData)),
  });

  console.log("streamdal response");
  console.dir(result, {depth: 20});
};

see ./examples for a runnable examples that can be used as a starters

WASM

In order to run pipelines with a minimal amount of overhead, the Streamdal node sdk ships and executes pipeline rules as WASM. If you are using Node version < 20.* you'll need to enable WASM functionality in your node app by supplying the flag, see:

node --experimental-wasi-unstable-preview1 ./build/sandbox/index.js

More info: Node WASM Modules

Development

To do development on the node-sdk, you can run it locally:

npm install npm run sandbox

See ./src/sandbox/index.ts for an entry point for local dev.

Optionally install and run the Streamdal server

Releasing

  1. npm version [<newversion> | major | minor | patch]
  2. git push the generated version tag: git push origin <tag_name>
  3. Generate a release from the tag with user-friendly release notes: https://github.com/streamdal/node-sdk/releases