@lightbend/akkaserverless-javascript-sdk
Version:
Akka Serverless JavaScript SDK
63 lines (54 loc) • 3.39 kB
JavaScript
// GENERATED CODE -- DO NOT EDIT!
// Original file comments:
// Copyright 2021 Lightbend Inc.
//
// gRPC interface for common messages and services for value-based Entity user functions.
//
;
var grpc = require('@grpc/grpc-js');
var akkaserverless_component_valueentity_value_entity_pb = require('../../../akkaserverless/component/valueentity/value_entity_pb.js');
var akkaserverless_component_component_pb = require('../../../akkaserverless/component/component_pb.js');
var akkaserverless_component_entity_entity_pb = require('../../../akkaserverless/component/entity/entity_pb.js');
var google_protobuf_any_pb = require('google-protobuf/google/protobuf/any_pb.js');
function serialize_akkaserverless_component_valueentity_ValueEntityStreamIn(arg) {
if (!(arg instanceof akkaserverless_component_valueentity_value_entity_pb.ValueEntityStreamIn)) {
throw new Error('Expected argument of type akkaserverless.component.valueentity.ValueEntityStreamIn');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_akkaserverless_component_valueentity_ValueEntityStreamIn(buffer_arg) {
return akkaserverless_component_valueentity_value_entity_pb.ValueEntityStreamIn.deserializeBinary(new Uint8Array(buffer_arg));
}
function serialize_akkaserverless_component_valueentity_ValueEntityStreamOut(arg) {
if (!(arg instanceof akkaserverless_component_valueentity_value_entity_pb.ValueEntityStreamOut)) {
throw new Error('Expected argument of type akkaserverless.component.valueentity.ValueEntityStreamOut');
}
return Buffer.from(arg.serializeBinary());
}
function deserialize_akkaserverless_component_valueentity_ValueEntityStreamOut(buffer_arg) {
return akkaserverless_component_valueentity_value_entity_pb.ValueEntityStreamOut.deserializeBinary(new Uint8Array(buffer_arg));
}
// Service that the SDK (in the user function) implements to make value
// entities available to the proxy
var ValueEntitiesService = exports.ValueEntitiesService = {
// One stream will be established per active entity. Once established, the
// first message sent will be Init, which contains the entity ID, and, a state
// if the entity has previously persisted one. Once the Init message is sent,
// one to many commands are sent to the entity. Each request coming in leads
// to a new command being sent to the entity. The entity is expected to reply
// to each command with exactly one reply message. The entity should process
// commands and reply to commands in the order they came in. When processing a
// command the entity can read and persist (update or delete) the state.
handle: {
path: '/akkaserverless.component.valueentity.ValueEntities/Handle',
requestStream: true,
responseStream: true,
requestType: akkaserverless_component_valueentity_value_entity_pb.ValueEntityStreamIn,
responseType: akkaserverless_component_valueentity_value_entity_pb.ValueEntityStreamOut,
requestSerialize: serialize_akkaserverless_component_valueentity_ValueEntityStreamIn,
requestDeserialize: deserialize_akkaserverless_component_valueentity_ValueEntityStreamIn,
responseSerialize: serialize_akkaserverless_component_valueentity_ValueEntityStreamOut,
responseDeserialize: deserialize_akkaserverless_component_valueentity_ValueEntityStreamOut,
},
};
exports.ValueEntitiesClient = grpc.makeGenericClientConstructor(ValueEntitiesService);