0.0.9 • Published 4 years ago

@tick-core/grpc-server v0.0.9

Weekly downloads
1
License
ISC
Repository
-
Last release
4 years ago

tick-core-grpc-server: grpc server

下载

npm install @tick-core/grpc-server

controller

import {
  Controller,
  Router,
} from '@tick-core/grpc-server'

@Controller('testOne') // proto 的 package
export default class {
  @Router()   // or @Router('sayHello') proto service 中的 rpc method
  sayHello (data: any) {
    console.log(data)
    return {
      id: 13,
      name: '张思',
      age: 14
    }
  }
}

使用方式1【本地proto】

import {
  createGrpcServer,
} from '@tick-core/grpc-server'
import path from 'path'

createGrpcServer({
  ports: [8899, 8888],  // 多个端口会启用多个子进程,充分利用cpu资源
  controllerPath: path.join(__dirname, './controller'),
  protoPath:  path.join(__dirname, './protos'),
  logPath: '/xxx/xxx/xxx',
  backPath: '/xxx/xxx/xxx',
})

使用方式2【zookeeper proto】

import {
  createGrpcServer,
} from '@tick-core/grpc-server'
import path from 'path'
import {
  Zconf,
} from '@tick-core/zconf'

createGrpcServer({
  ports: [8899, 8888],
  controllerPath: path.join(__dirname, './controller'),
  protoPath: new Zconf({
    zookeeperConfs: [{
      host: '127.0.0.1',
      port: 2181,
    }],
    conf: {
      proto1: '/app/proto1',
      proto: '/app/proto'
    },
    retries: 3,
    cache: false,
  }),
  logPath: '/xxx/xxx/xxx',
  backPath: '/xxx/xxxxx',
})
0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.3

4 years ago

0.0.4

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago