0.1.0 • Published 3 years ago

@radicalbit/helicon-node-sdk2 v0.1.0

Weekly downloads
-
License
MIT
Repository
bitbucket
Last release
3 years ago

Helicon node sdk

This module contains the NodeJs sdk for Helicon publish and subscribe operations.

Helicon is a simple, scalable, robust, code-free and generic platform to enable and productise the next generation of "online modified", real-time event stream ML/AI models.

Publish

publish operations can be performed by using the HeliconWriteClient class exported by the library.

To initialize a new HeliconWriteClient istance, the user is tasked to fill all the required parameters of the constructor such as:

  • The authorization server URL
  • The address where the GRPC Host is located
  • The port to which the GRPC Host is binded
  • The rest of the authentication parameters such as Client Secret, clientId and Tenant

Each of these parameters can be found (pre-filled) in the "Setup" section of a newly created stream.

After a HeliconWriteClient has been initialized, the user can send data to the stream thanks to the write(streamName, payload) method; An usage example is shown below:

const { HeliconWriteClient } = require("@radicalbit/helicon-node-sdk");

const authorizationServer = "<authorization-server-url>";
const grpcHost = "<grpc-host>";
const grpcPort = 0;
const clientId = "<client-id>";
const clientSecret = "<client-secret>";
const tenant = "<tenant-name>";

const payload = {
	"name": "record",
	"temperature": "29"
};

const heliconWriteClient = new HeliconWriteClient(authorizationServerUrl, grpcHost, grpcPort, clientId, clientSecret, tenant);

heliconWriteClient.write("<streamName>", payload).then(
	() => console.log("payload published!"),
	(errorMessage) => console.error(errorMessage)
);

Subscribe

subscribe operations can be performed by using the HeliconSubscribeClient class exported by the library.

To initialize a new HeliconSubscribeClient istance, the user is tasked to fill all the required parameters of the constructor such as:

  • The authorization server URL
  • The address where the GRPC Host is located
  • The port to which the GRPC Host is binded
  • The rest of the authentication parameters such as Client Secret, clientId and Tenant

Each of these parameters can be found (pre-filled) in the "Setup" section of a newly created stream.

After a HeliconSubscribeClient has been initialized, the user can receive the events from the stream thanks to the subscribe(streamDisplaName) method; An usage example is shown below:

const { HeliconSubscribeClient } = require("helicon-node-api");

const authorizationServer = "<authorization-server-url>";
const grpcHost = "<grpc-host>";
const grpcPort = 0;
const clientId = "<client-id>";
const clientSecret = "<client-secret>";
const tenant = "<tenant-name>";

const heliconSubscribeClient = new HeliconSubscribeClient(authorizationServerUrl, grpcHost, grpcPort, clientId, clientSecret, tenant);

heliconSubscribeClient.subscribe("<streamName>").onData(
  (data => console.log(data))
);

Support

We're always happy to help with any other questions you might have! Send us an email.