0.8.5 • Published 2 years ago

@nestcloud2/grpc v0.8.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

NestCloud - Grpc

Description

The loadbalance grpc module for nestcloud.

Installation

$ npm install --save @nestcloud2/grpc

Quick Start

Import module

Before import GrpcModule, you need to import LoadbalanceModule first.

import { Module } from '@nestjs/common';
import { LoadbalanceModule } from '@nestcloud2/loadbalance'
import { GrpcModule } from '@nestcloud2/grpc';

@Module({
  imports: [
      LoadbalanceModule.forRoot({...}),
      GrpcModule.forRoot()
  ],
})
export class AppModule {}

Usage

import { Controller, Get } from '@nestjs/common';
import { RpcClient, GrpcClient, IClientConfig, Service } from '@nestcloud2/grpc';
import { HeroService } from './interfaces/hero-service.interface';
import { join } from 'path';

const grpcOptions: IClientConfig = {
    service: 'rpc-server',
    package: 'hero',
    protoPath: join(__dirname, './hero.proto'),
};

@Controller()
export class HeroController {
    @RpcClient(grpcOptions)
    private readonly client: GrpcClient;
    @Service('HeroService', grpcOptions)
    private readonly heroService: HeroService;

    @Get()
    async execute(): Promise<any> {
        return await this.heroService.get({ id: 1 }).toPromise();
    }
}

More please visit the example: https://github.com/nest-cloud/nestcloud-grpc-example

Stay in touch

License

NestCloud is MIT licensed.

0.9.1

2 years ago

0.9.1-rc.0

2 years ago

0.8.5

2 years ago

0.8.4

2 years ago

0.8.3

2 years ago

0.8.0

2 years ago

0.7.21

2 years ago

0.7.20

2 years ago