protobuf 方法org.postgresql.jdbc.PgConnection.createClob()尚未实现。

application
# Disable feature detection by this undocumented parameter. Check the org.hibernate.engine.jdbc.internal.JdbcServiceImpl.configure method for more details.
spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false

# Because detection is disabled you have to set correct dialect by hand.
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQL9Dialect

protobuf counter.proto

counter.proto
// Automatically generated by sol2proto. DO NOT EDIT!
// sources:
//   Counter.abi
syntax = "proto3";

package pb;

import "messages.proto";

service Counter {
  rpc count(CountReq) returns (TransactionResp) {}
}

protobuf messages.proto

messages.proto
// Automatically generated by sol2proto. DO NOT EDIT!
// sources:
//   Counter.abi
syntax = "proto3";

package pb;

import public "github.com/getamis/sol2proto/pb/messages.proto";

message CountReq {
  TransactOpts opts = 1;
}

protobuf GRPC

server.js
import grpc from 'grpc'
import path from 'path'
import fs from 'fs'
import through2 from 'through2'

const apiProto = grpc.load(path.join(__dirname, '/../../myapi.proto'))

const server = new grpc.Server()
server.addService(apiProto.api.Api.service, {
  pow,
  countdown,
  sum,
  uploadFile
})

server.bind('0.0.0.0:5000', grpc.ServerCredentials.createInsecure())
server.start()

console.log('grpc server started')

function pow (call, callback) {
  const { number } = call.request
  callback(null, number * number)
}

function countdown (call) {
  let { number } = call.request
  const timer = setInterval(() => {
    if (--number < 0) {
      call.end()
      clearInterval(timer)
      return
    }
    call.write({ number })
  }, 1000)

  call.on('cancelled', () => clearInterval(timer))
}

function sum (call, callback) {
  let sum = 0
  call.on('data', ({ number }) => { sum += number })
  call.on('end', () => callback(null, { number: sum }))
}

function uploadFile (call, callback) {
  call
    .pipe(through2.obj(({ bytes }, enc, next) => next(null, bytes)))
    .pipe(fs.createWriteStream('pic.jpg'))
    .on('finish', () => callback(null, { content: 'done' }))
}
client.js
import grpc from 'grpc'
import path from 'path'
import fs from 'fs'
import through2 from 'through2'

const apiProto = grpc.load(path.join(__dirname, '/../../myapi.proto'))

const client = new apiProto.api.Api(
  'localhost:5000',
  grpc.credentials.createInsecure()
)

client.pow({ number: 3 }, (err, number) => {
  console.log('pow', err, number)
})

client.countdown({ number: 3 }).on('data', ({ number }) => {
  console.log('countdown', number)
})

const sumCall = client.sum((err, { number }) => {
  console.log('sum', err, number)
})
sumCall.write({ number: 1 })
sumCall.write({ number: 2 })
sumCall.end()

const uploadFileCall = client.uploadFile((err, { content }) => {
  console.log('uploadFile', err, content)
})
fs.createReadStream('pic.jpg')
  .pipe(through2.obj((chunk, enc, next) => next(null, { bytes: chunk })))
  .pipe(uploadFileCall)
api.proto
syntax = "proto3";

package api;

service Api {
  rpc pow (Number) returns (Number) {}

  rpc countdown (Number) returns (stream Number) {}

  rpc sum (stream Number) returns (Number) {}

  rpc uploadFile (stream ByteChunk) returns (Message) {}
}

message Number {
  double number = 1;
}

message Message {
  string content = 1;
}

message ByteChunk {
  bytes bytes = 1;
}

protobuf MongoDbObjectId.proto

MongoDbObjectId.proto
message ObjectId {
  // Unordered map of dynamically typed values.
  map<string, Value> id = 1;
  string _bsontype = 2; // should return "ObjectId"
}

// The JSON representation for `Value` is JSON value.
enum Value {
  VALUE = 1;
}