Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for 0.2.2-RC1 Release #20

Merged
merged 6 commits into from
Jan 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
## Version 0.2.2-RC1
_2018-01-03_
* New: Update to kotlin ```1.3.11```

#### Protoc Plugin
* New: gRPC Coroutines Client & Server Code Generation
* New: Stand alone version of gRPC code gen. ```protoc-gen-grpc-coroutines```

#### Coroutines
* New: Benchmark implementation of gRPC coroutines
* New: Experimental global dispatcher ```Dispatchers.Grpc```
* New: ```SendChannel``` utility api ```CoroutineScope.launchProducerJob```
* Fix: Lowered byte code target for Android compatibility
* Deprecated: ```InboundStreamChannel``` in favor of new stub APIs
* Deprecated: ```ServerBidiCallChannel``` in favor of new stub APIs

#### Proto Builders (DSL)
* Fix: Nested messages are now tagged with ```@DslMarker``` annotation

#### Community Scripts
* New: ```grpc-gateway``` entry point generation script

## Version 0.2.1
_2018-11-02_
* Fix: Address regression in file filter matching
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,20 @@

### Community Contributions are Welcomed

## Quick Start:
## Quick Start: gRPC Coroutines
Run the following command to get started with a preconfigured template project. (_[kotlin-coroutines-gRPC-template](https://github.com/marcoferrer/kotlin-coroutines-gRPC-template)_)
```bash
git clone https://github.com/marcoferrer/kotlin-coroutines-gRPC-template && \
cd kotlin-coroutines-gRPC-template && \
./gradlew run
```

## Version 0.2.1
## Version 0.2.2-RC1
* [CHANGELOG](https://github.com/marcoferrer/kroto-plus/blob/master/CHANGELOG.md)
* Most notable changes
* Update to Kotlin 1.3.0
* Update to Coroutines 1.0.0
* Builder DSL support and safety via Kotlin's ```@DslMarker``` annotation
* Full Client & Server Stub Generation 🎉

## Coming Soon
* Full Client & Server Stub Generation 🎉
* New gradle configuration dsl
* Windows executable

Expand Down Expand Up @@ -86,6 +83,11 @@ The generated extensions allow composition of proto messages in a dsl style. Sup
}
```

### gRPC Coroutines Client & Server
#### [Configuration Options]()
__Docs Coming Soon__


### gRPC Stub Extensions
#### [Configuration Options](https://github.com/marcoferrer/kroto-plus/blob/master/protoc-gen-kroto-plus/src/main/proto/krotoplus/compiler/config.proto#L61)

Expand Down
9 changes: 5 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {
versions = [
"protobuf": '3.6.1',
"grpc": '1.15.1',
"kotlin": '1.3.0',
"kotlin": '1.3.11',
"coroutines": '1.0.0',
"bintray": '1.7.3',
'artifactory':'4.7.1',
Expand All @@ -24,11 +24,12 @@ buildscript {

plugins{
id 'com.google.protobuf' version '0.8.6' apply false
id 'org.jetbrains.kotlin.jvm' version '1.3.0-rc-116' apply false
id 'org.jetbrains.kotlin.jvm' version '1.3.11' apply false
id "com.jfrog.bintray" version "1.8.4" apply false
id "com.jfrog.artifactory" version "4.8.1" apply false
id "org.springframework.boot" version "2.0.3.RELEASE" apply false
id 'com.gradle.plugin-publish' version '0.9.7' apply false
id "com.google.osdetector" version "1.4.0"
}

subprojects{ subproject ->
Expand All @@ -44,7 +45,7 @@ subprojects{ subproject ->
apply plugin: 'kotlin'

group = 'com.github.marcoferrer.krotoplus'
version = '0.2.1'
version = '0.2.2-RC1'

compileKotlin {
kotlinOptions.jvmTarget = "1.8"
Expand All @@ -55,7 +56,7 @@ subprojects{ subproject ->
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
implementation "org.jetbrains.kotlin:kotlin-stdlib"

testImplementation group: 'junit', name: 'junit', version: '[4,)'
testImplementation "org.jetbrains.kotlin:kotlin-test"
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
object Versions {
const val protobuf = "3.6.1"
const val grpc = "1.15.1"
const val kotlin = "1.3.0"
const val coroutines = "1.0.0"
const val kotlin = "1.3.11"
const val coroutines = "1.1.0"
}
2 changes: 1 addition & 1 deletion community-scripts/extendable-messages/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def krotoPlusVersion = '0.2.1'
def krotoPlusVersion = '0.2.2-SNAPSHOT'

plugins {
id "org.jetbrains.kotlin.jvm" version "1.3.0"
Expand Down
49 changes: 49 additions & 0 deletions community-scripts/grpc-gateway-entry-point/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
## Grpc Gateway - Entry Point

Kotlin script for generating an entry point for a [grpc-gateway](https://github.com/grpc-ecosystem/grpc-gateway)

The code generated is based off the example given in the project readme.

```go
package main

import (
"flag"
"net/http"

"github.com/golang/glog"
"golang.org/x/net/context"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"google.golang.org/grpc"

gw "path/to/your_service_package"
)

var (
echoEndpoint = flag.String("echo_endpoint", "localhost:9090", "endpoint of YourService")
)

func run() error {
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
defer cancel()

mux := runtime.NewServeMux()
opts := []grpc.DialOption{grpc.WithInsecure()}
err := gw.RegisterYourServiceHandlerFromEndpoint(ctx, mux, *echoEndpoint, opts)
if err != nil {
return err
}

return http.ListenAndServe(":8080", mux)
}

func main() {
flag.Parse()
defer glog.Flush()

if err := run(); err != nil {
glog.Fatal(err)
}
}
```
16 changes: 16 additions & 0 deletions community-scripts/grpc-gateway-entry-point/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
def krotoPlusVersion = '0.2.2-SNAPSHOT'

plugins {
id "org.jetbrains.kotlin.jvm" version "1.3.0"
}

repositories {
jcenter()
maven { url 'https://oss.jfrog.org/artifactory/oss-snapshot-local' }
}

dependencies{
implementation "com.github.marcoferrer.krotoplus:protoc-gen-kroto-plus:$krotoPlusVersion"
implementation "com.google.protobuf:protobuf-java:3.6.1"
implementation "org.jetbrains.kotlin:kotlin-script-util"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import com.github.marcoferrer.krotoplus.generators.Generator
import com.github.marcoferrer.krotoplus.proto.ProtoService
import com.github.marcoferrer.krotoplus.utils.addFile
import com.google.protobuf.compiler.PluginProtos


object GrpcGatewayEntryPointGenerator : Generator {

private const val httpOptionId = "72295728"

override fun invoke(): PluginProtos.CodeGeneratorResponse {

val services = context.schema.protoServices
.filter { service ->
service.methodDefinitions.any { method ->
httpOptionId in method.descriptorProto.options.toString()
}
}

return PluginProtos.CodeGeneratorResponse.newBuilder()
.addFile {
name = "main.go"
content = buildMain(services)
}
.build()
}

// language=go
private fun buildMain(services: List<ProtoService>) = buildString {
append(
"""
package main

import (
"flag"
"net/http"

"github.com/golang/glog"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"golang.org/x/net/context"
"google.golang.org/grpc"
""".trimIndent()
)

for (service in services) {
val goPackage = service.protoFile.protoPackage.replace(".", "/")

appendln()
append(" ${service.varName} \"../$goPackage\"")
}

appendln()
append(
"""
)

var (
serviceEndpoint = flag.String("service_endpoint", "localhost:8000", "endpoint of YourService")
)

func run() error {
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
defer cancel()

mux := runtime.NewServeMux()
opts := []grpc.DialOption{grpc.WithInsecure()}
var err error
""".trimIndent()
)

for (service in services) {
appendln()
appendln(
"""
err = ${service.varName}.Register${service.name}HandlerFromEndpoint(ctx, mux, *serviceEndpoint, opts)
if err != nil {
return err
}
""".trimIndent()
)
}

append(
"""
return http.ListenAndServe(":8080", mux)
}

func main() {
flag.Parse()
defer glog.Flush()

if err := run(); err != nil {
glog.Fatal(err)
}
}
""".trimIndent()
)
}

val ProtoService.varName: String get() = name.decapitalize() + "Gw"
}

2 changes: 1 addition & 1 deletion community-scripts/var-arg-extensions/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def krotoPlusVersion = '0.2.1'
def krotoPlusVersion = '0.2.2.-SNAPSHOT'

plugins {
id "org.jetbrains.kotlin.jvm" version "1.3.0"
Expand Down
45 changes: 45 additions & 0 deletions docs/html/kroto-plus-config.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ <h2>Table of Contents</h2>
<a href="#krotoplus.compiler.GeneratorScriptsGenOptions"><span class="badge">M</span>GeneratorScriptsGenOptions</a>
</li>

<li>
<a href="#krotoplus.compiler.GrpcCoroutinesGenOptions"><span class="badge">M</span>GrpcCoroutinesGenOptions</a>
</li>

<li>
<a href="#krotoplus.compiler.GrpcStubExtsGenOptions"><span class="badge">M</span>GrpcStubExtsGenOptions</a>
</li>
Expand Down Expand Up @@ -288,6 +292,13 @@ <h3 id="krotoplus.compiler.CompilerConfig">CompilerConfig</h3>
<td><p>Configuration entries for the &#39;Generator Scripts&#39; code generator. </p></td>
</tr>

<tr>
<td>grpc_coroutines</td>
<td><a href="#krotoplus.compiler.GrpcCoroutinesGenOptions">GrpcCoroutinesGenOptions</a></td>
<td>repeated</td>
<td><p>Configuration entries for the &#39;Grpc Coroutines&#39; code generator. </p></td>
</tr>

</tbody>
</table>

Expand Down Expand Up @@ -435,6 +446,30 @@ <h3 id="krotoplus.compiler.GeneratorScriptsGenOptions">GeneratorScriptsGenOption



<h3 id="krotoplus.compiler.GrpcCoroutinesGenOptions">GrpcCoroutinesGenOptions</h3>
<p>Configuration used by the 'gRPC Coroutines' code generator.</p>


<table class="field-table">
<thead>
<tr><td>Field</td><td>Type</td><td>Label</td><td>Description</td></tr>
</thead>
<tbody>

<tr>
<td>filter</td>
<td><a href="#krotoplus.compiler.FileFilter">FileFilter</a></td>
<td></td>
<td><p>Filter used for limiting the input files that are processed by the code generator
The default filter will match true against all input files. </p></td>
</tr>

</tbody>
</table>




<h3 id="krotoplus.compiler.GrpcStubExtsGenOptions">GrpcStubExtsGenOptions</h3>
<p>Configuration used by the 'gRPC Stub Extensions' code generator.</p>

Expand Down Expand Up @@ -634,6 +669,16 @@ <h3 id="krotoplus.compiler.ProtoBuildersGenOptions">ProtoBuildersGenOptions</h3>
the output file. </p></td>
</tr>

<tr>
<td>use_dsl_markers</td>
<td><a href="#bool">bool</a></td>
<td></td>
<td><p>Tag java builder classes with a kotlin interface annotated
with @DslMarker. This requires the kroto-plus output directory to
match the generated java classes directory. Using @DslMarker
provides safer and predictable dsl usage. </p></td>
</tr>

</tbody>
</table>

Expand Down
Loading