0.0.0-unstable • Published 3 years ago

js-kvproto v0.0.0-unstable

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

kvproto

Compiled TiKV protobuf lib, generated from pingcap/kvproto by protobufjs.

Installation

npm i js-kvproto

Usage

See protobufjs

gRPC

const grpc = require('grpc')
const { pdpb } = require('js-kvproto')

const Client = grpc.makeGenericClientConstructor({})
const client = new Client(
  '127.0.0.1:2379',
  grpc.credentials.createInsecure()
)

const rpcImpl = prefix => (method, requestData, callback) => {
  client.makeUnaryRequest(
    `/${prefix}/${method.name}`,
    arg => arg,
    arg => arg,
    requestData,
    null,
    null,
    callback
  )
}

const pd = pdpb.PD.create(rpcImpl('pdpb.PD'), false, false)

async function main () {
  const members = await pd.getMembers({})

  console.log(members)
}

main().then()