adonis-grpc-consumer
Version:
Adonis gRPC client provider for easily communicate with gRPC services
29 lines (28 loc) • 895 B
TypeScript
import type * as grpc from '@grpc/grpc-js';
import { GrpcConsumerConfig, GrpcConsumerBaseContract } from '@ioc:Adonis/Addons/GrpcConsumer';
export declare class GrpcConsumer implements GrpcConsumerBaseContract {
private clients;
private config;
constructor(config: GrpcConsumerConfig);
private createGrpcClient;
/**
* Split the package name into an array if it's a nested package.
*/
private getPackageName;
/**
* Returns the services from the given package. Handle nested package
*/
private getServices;
/**
* Creates a gRPC client.
*/
private createClient;
/**
* Returns the gRPC client for the given name with good typings.
*/
getClient<T extends grpc.Client>(name: string): T | undefined;
/**
* Closes all the gRPC clients.
*/
closeAll(): Promise<void>;
}