UNPKG

@lightbend/akkaserverless-javascript-sdk

Version:
122 lines (109 loc) 5.41 kB
// GENERATED CODE -- DO NOT EDIT! // Original file comments: // Copyright 2021 Lightbend Inc. // // gRPC interface for the discovery service provided by user functions // 'use strict'; var grpc = require('@grpc/grpc-js'); var akkaserverless_protocol_discovery_pb = require('../../akkaserverless/protocol/discovery_pb.js'); var google_protobuf_descriptor_pb = require('google-protobuf/google/protobuf/descriptor_pb.js'); var google_protobuf_empty_pb = require('google-protobuf/google/protobuf/empty_pb.js'); function serialize_akkaserverless_protocol_ProxyInfo(arg) { if (!(arg instanceof akkaserverless_protocol_discovery_pb.ProxyInfo)) { throw new Error('Expected argument of type akkaserverless.protocol.ProxyInfo'); } return Buffer.from(arg.serializeBinary()); } function deserialize_akkaserverless_protocol_ProxyInfo(buffer_arg) { return akkaserverless_protocol_discovery_pb.ProxyInfo.deserializeBinary(new Uint8Array(buffer_arg)); } function serialize_akkaserverless_protocol_Spec(arg) { if (!(arg instanceof akkaserverless_protocol_discovery_pb.Spec)) { throw new Error('Expected argument of type akkaserverless.protocol.Spec'); } return Buffer.from(arg.serializeBinary()); } function deserialize_akkaserverless_protocol_Spec(buffer_arg) { return akkaserverless_protocol_discovery_pb.Spec.deserializeBinary(new Uint8Array(buffer_arg)); } function serialize_akkaserverless_protocol_UserFunctionError(arg) { if (!(arg instanceof akkaserverless_protocol_discovery_pb.UserFunctionError)) { throw new Error('Expected argument of type akkaserverless.protocol.UserFunctionError'); } return Buffer.from(arg.serializeBinary()); } function deserialize_akkaserverless_protocol_UserFunctionError(buffer_arg) { return akkaserverless_protocol_discovery_pb.UserFunctionError.deserializeBinary(new Uint8Array(buffer_arg)); } function serialize_google_protobuf_Empty(arg) { if (!(arg instanceof google_protobuf_empty_pb.Empty)) { throw new Error('Expected argument of type google.protobuf.Empty'); } return Buffer.from(arg.serializeBinary()); } function deserialize_google_protobuf_Empty(buffer_arg) { return google_protobuf_empty_pb.Empty.deserializeBinary(new Uint8Array(buffer_arg)); } // Service that the SDK (in the user function) implements to allow the proxy to // discover which components are provided by this user function var DiscoveryService = exports.DiscoveryService = { // Discover what components the user function wishes to serve. discover: { path: '/akkaserverless.protocol.Discovery/Discover', requestStream: false, responseStream: false, requestType: akkaserverless_protocol_discovery_pb.ProxyInfo, responseType: akkaserverless_protocol_discovery_pb.Spec, requestSerialize: serialize_akkaserverless_protocol_ProxyInfo, requestDeserialize: deserialize_akkaserverless_protocol_ProxyInfo, responseSerialize: serialize_akkaserverless_protocol_Spec, responseDeserialize: deserialize_akkaserverless_protocol_Spec, }, // Report an error back to the user function. This will only be invoked to // tell the user function that it has done something wrong, eg, violated the // protocol, tried to use a component type that isn't supported, or attempted // to forward to a component that doesn't exist, etc. These messages should be // logged clearly for debugging purposes. reportError: { path: '/akkaserverless.protocol.Discovery/ReportError', requestStream: false, responseStream: false, requestType: akkaserverless_protocol_discovery_pb.UserFunctionError, responseType: google_protobuf_empty_pb.Empty, requestSerialize: serialize_akkaserverless_protocol_UserFunctionError, requestDeserialize: deserialize_akkaserverless_protocol_UserFunctionError, responseSerialize: serialize_google_protobuf_Empty, responseDeserialize: deserialize_google_protobuf_Empty, }, // When the Akka Serverless proxy is shutting down it sends this signal at the end // of the shutdown process. The user function container should preferably delay // its own shutdown until the proxy has terminated to be able to drain requests in // flight from the proxy. proxyTerminated: { path: '/akkaserverless.protocol.Discovery/ProxyTerminated', requestStream: false, responseStream: false, requestType: google_protobuf_empty_pb.Empty, responseType: google_protobuf_empty_pb.Empty, requestSerialize: serialize_google_protobuf_Empty, requestDeserialize: deserialize_google_protobuf_Empty, responseSerialize: serialize_google_protobuf_Empty, responseDeserialize: deserialize_google_protobuf_Empty, }, // Health check for the user function to detect if it stops, crashes or becomes unresponsive // and the proxy needs to restart it. The SDK should respond in a timely fashion if healthy // or fail the request if not. healthCheck: { path: '/akkaserverless.protocol.Discovery/HealthCheck', requestStream: false, responseStream: false, requestType: google_protobuf_empty_pb.Empty, responseType: google_protobuf_empty_pb.Empty, requestSerialize: serialize_google_protobuf_Empty, requestDeserialize: deserialize_google_protobuf_Empty, responseSerialize: serialize_google_protobuf_Empty, responseDeserialize: deserialize_google_protobuf_Empty, }, }; exports.DiscoveryClient = grpc.makeGenericClientConstructor(DiscoveryService);