Skip to content

Commit

Permalink
⬆️ dependencies use @grpc/grpc-js & @grpc/proto-loader replace grpc
Browse files Browse the repository at this point in the history
  • Loading branch information
classLfz committed Aug 21, 2023
1 parent 7857d1c commit 518886d
Show file tree
Hide file tree
Showing 3 changed files with 883 additions and 1,917 deletions.
11 changes: 5 additions & 6 deletions lib/Service.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const path = require('path')
const grpc = require('grpc')
const grpc = require('@grpc/grpc-js')
const loader = require('@grpc/proto-loader')
const protobuf = require('protobufjs')
const { buildRequestMessage } = require('./helper')

Expand Down Expand Up @@ -38,11 +39,9 @@ class Service {
channelCredentials = grpc.credentials.createSsl()
}
this._iProto = protobuf.Root.fromJSON(require(path.join(__dirname, `../jsons/${serviceName}_service_pb.json`)))
let IService = grpc.loadObject(this._iProto)
servicePath.forEach(point => {
IService = IService[point]
})
this._client = new IService(
const def = loader.loadSync(path.join(__dirname, `../jsons/${serviceName}_service_pb.json`))
const GrpcObj = grpc.loadPackageDefinition(def).ai.metathings.service[serviceName][serviceName.charAt(0).toUpperCase() + serviceName.slice(1) + 'Service']
this._client = new GrpcObj(
host,
channelCredentials || grpc.credentials.createInsecure(),
{
Expand Down
Loading

0 comments on commit 518886d

Please sign in to comment.