GithubHelp home page GithubHelp logo

vertx-grpc-java-compiler's Introduction

Build Status

vertx-grpc-java-compiler 1.20.0

This is a drop-in replacement gRPC compiler for java targeting the Vert.x programming model.

Besides the normal generation that the official compiler does it adds 2 extra classes to the generation:

  • an abstract class VertxImplBase
  • a final class VertxStub

These new classes follow the vert.x programming model closer than the generic ones so it will feel more natural to the end user to choose these instead of the official ones. There is no difference between the implementations since the new generated classes only wrap the vert.x types into the gRPC expected types.

Build it

IMPORTANT: Read the additional modification made to the code section (below)

gRPC assumes you already have a couple of dependencies on your system:

  • Docker
  • A working Bash shell
  • maven

Docker will be used to provide a set of cross compilers and the output of the build will end up on this directory.

Maven will then collect the binaries and archive into the local repository.

Build the plugin

sudo ./scripts/build.sh

Note that sudo is used here since in Fedora docker requires it, if you don't need it for your case don't use sudo.

Archive the maven artifacts

mvn install

Update the code

The process is quite manual.

  1. Run a diff between the gRPC tags, replace the versions in the link
  2. If there are changes in the CPP code try to apply the diff/manual merge
  3. Bump the versions on pom.xml and Makefile to match the new one.
  4. Build

When bumping the protobuf dependency the following steps are required:

  1. Download the tar.gz file to the root of the project.
  2. Update travis to cache the new version.
  3. Update the Makefile to use the new version.

IMPORTANT A few changes are applied in the code:

  1. Stub constructors are made public instead of private. It improves Java 9 support where reflective calls should not use setAccessible. Changes are made in java_generator.cpp (such as: https://github.com/vert-x3/vertx-grpc-java-compiler/pull/9/commits/69d8a4fcc2b4d37a265a3f1ae8d4ac203df420dd)

vertx-grpc-java-compiler's People

Contributors

cescoffier avatar liukch avatar pmlopes avatar slinkydeveloper avatar vietj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vertx-grpc-java-compiler's Issues

new version

In order to use next version of GRPC in vertx-grpc (see vert-x3/vertx-grpc#6) we should release corresponding version of vertx-grpc-java-compiler

Execution failed for task :generateProto "extracted-protos" directory does not exist

Using this plugin I'm trying to build the service-definitions.proto from the grpc examples. I have all 3 protobuf definitions in the proto directory, yet service-definitions.proto is causing an error (if I remove it, messages.proto and empty.proto compile successfully). Is this plugin related?

* What went wrong:
Execution failed for task ':generateProto'.
> protoc: stdout: . stderr: /Users/ash/IdeaProjects/kotlin/grpc/build/extracted-protos/main: warning: directory does not exist.
  service-definitions.proto:10:17: "Empty" is not defined.
  service-definitions.proto:10:33: "Empty" is not defined.
  service-definitions.proto:15:17: "SimpleRequest" is not defined.
  service-definitions.proto:15:41: "SimpleResponse" is not defined.
  service-definitions.proto:21:27: "StreamingOutputCallRequest" is not defined.
  service-definitions.proto:21:71: "StreamingOutputCallResponse" is not defined.
  service-definitions.proto:27:33: "StreamingInputCallRequest" is not defined.
  service-definitions.proto:27:69: "StreamingInputCallResponse" is not defined.
  service-definitions.proto:34:29: "StreamingOutputCallRequest" is not defined.
  service-definitions.proto:34:73: "StreamingOutputCallResponse" is not defined.
  service-definitions.proto: warning: Import empty.proto but not used.
  service-definitions.proto: warning: Import messages.proto but not used.

It's looking for extracted definitions in extracted-protos, yet the directory is named extracted-include-protos. Why is it looking here, when the definitions it needs to import are all in the same directory? Why does this error not occur if I'm not importing definitions from one into another?

If it helps, I don't think I'm doing anything crazy with build.gradle:

buildscript {
    ext.kotlin_version = '1.1.3'

    repositories {
        jcenter()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.1"
    }
}

apply plugin: 'kotlin'
apply plugin: "java"
apply plugin: "com.google.protobuf"
apply plugin: "idea"

protobuf {
    //generatedFilesBaseDir = "$projectDir/build/generated/source/proto"
    protoc {
        artifact = "com.google.protobuf:protoc:3.2.0"
    }
    plugins {
        grpc {
            artifact = "io.vertx:protoc-gen-grpc-java:1.3.0"
        }
    }
    generateProtoTasks {
        all().each { task ->
            task.plugins {
                grpc {}
            }
        }
    }
}

clean {
    delete protobuf.generatedFilesBaseDir
}

idea {
    module {
        sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/java")
        sourceDirs += file("${protobuf.generatedFilesBaseDir}/main/grpc")
    }
}

sourceSets {
    main {
        java {
            srcDirs += "${protobuf.generatedFilesBaseDir}/main/java"
            srcDirs += "${protobuf.generatedFilesBaseDir}/main/grpc"
        }
    }
}

repositories {
    jcenter()
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version"
    compile "io.vertx:vertx-core:3.4.2"
    compile "io.vertx:vertx-web:3.4.2"
    compile "io.vertx:vertx-grpc:3.4.2"
}

Return a promise for client stub methods in addition of void

Describe the feature

For our convenience, generate client stub methods with the signature

Future<Reply> rpcName(Request request);

in addition to

void rpcName(Request request, Promise<Reply> handler);

Use cases

Makes using the client far less clunky.

Contribution

I can implement this feature if there's a chance my PR actually gets merged. I've tried PRing various vertx projects and I don't think I've ever gotten a merge once.

"void $lower_method_name$($input_type$ request,\n"

Reopens #20, this is probably what the issue author wanted.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.