Service Schema
Download the Enhanced Streams proto (available from support).
Full service
protobuf
syntax = "proto3";
package nln.stream.v1;
service StreamService {
rpc Subscribe(SubscribeRequest) returns (stream SubscribeResponse);
rpc ListTopics(ListTopicsRequest) returns (ListTopicsResponse);
}
message SubscribeRequest {
string topic = 1;
OutputFormat format = 2;
}
enum OutputFormat {
PROTO = 0;
JSON = 1;
}
message SubscribeResponse {
string topic = 1;
int64 partition = 2;
int64 offset = 3;
int64 timestamp_ms = 4;
bytes payload = 5;
}
message ListTopicsRequest {}
message ListTopicsResponse {
repeated TopicInfo topics = 1;
}
message TopicInfo {
string name = 1;
string description = 2;
string proto_message_type = 3;
}Generate JavaScript bindings
Dynamic loading avoids a generation step:
bash
npm install @grpc/grpc-js @grpc/proto-loaderjavascript
import grpc from "@grpc/grpc-js"
import protoLoader from "@grpc/proto-loader"
const definition = protoLoader.loadSync("enhanced-streams.proto", {
keepCase: false,
longs: String,
enums: String,
defaults: true,
oneofs: true,
})
const nln = grpc.loadPackageDefinition(definition).nln.stream.v1Format values
PROTO = 0JSON = 1
Start with JSON. Move to protobuf payload decoding only after you receive the matching message schema from cubestech.