@protobuf-ts/grpc-backend
Version:
gRPC backend for servers generated by the protoc plugin "protobuf-ts"
22 lines (21 loc) • 1.34 kB
TypeScript
import { MethodInfo, ServerCallContext, ServiceInfo } from "@protobuf-ts/runtime-rpc";
import * as grpc from "@grpc/grpc-js";
declare type ContextFactory = (serviceInfo: ServiceInfo, methodInfo: MethodInfo, call: grpc.ServerUnaryCall<any, any> | grpc.ServerReadableStream<any, any> | grpc.ServerWritableStream<any, any>) => ServerCallContext;
export interface AdaptServiceOptions {
contextFactory?: ContextFactory;
}
/**
* Create a grpc service definition and an implementation for @grpc/grpc-js.
*/
export declare function adaptService(serviceInfo: ServiceInfo, serviceImplementation: any, options?: AdaptServiceOptions): [grpc.ServiceDefinition, grpc.UntypedServiceImplementation];
/**
* Create a service definition for @grpc/grpc-js from service info.
*/
export declare function createDefinition(serviceInfo: ServiceInfo): grpc.ServiceDefinition;
/**
* Create a grpc service implementation that delegates to the given
* protobuf-ts service implementation.
*/
export declare function mapService(si: ServiceInfo, service: any, options: AdaptServiceOptions): grpc.UntypedServiceImplementation;
export declare function createContext(serviceInfo: ServiceInfo, methodInfo: MethodInfo, call: grpc.ServerUnaryCall<any, any> | grpc.ServerReadableStream<any, any> | grpc.ServerWritableStream<any, any>): ServerCallContext;
export {};