Giter Club home page Giter Club logo

akka-grpc's Introduction

Akka gRPC

Support for building streaming gRPC servers and clients on top of Akka Streams.

This library is meant to be used as a building block in projects using the Akka toolkit.

The Akka family of projects is managed by teams at Lightbend with help from the community.

Documentation

Project Status

This library is ready to be used in production

The API on both sides (Client and Server) is a simple Akka Streams-based one.

The client side is currently implemented on top of io.grpc:grpc-netty-shaded with an Akka HTTP client backend alternative available.

As for performance, we are currently relying on the JVM TLS implementation, which is sufficient for many use cases, but is planned to be replaced with conscrypt or netty-tcnative.

General overview

gRPC is a schema-first RPC framework, where your protocol is declared in a protobuf definition, and requests and responses will be streamed over an HTTP/2 connection.

Based on a protobuf service definition, akka-grpc can generate:

  • Model classes (using plain protoc for Java or scalapb for Scala)
  • The API (as an interface for Java or a trait for Scala), expressed in Akka Streams Sources
  • On the server side, code to create an Akka HTTP route based on your implementation of the API
  • On the client side, a client for the API.

Project structure

The project is split up in a number of subprojects:

  • codegen: code generation shared among plugins
  • runtime: run-time utilities used by the generated code
  • sbt-plugin: the sbt plugin
  • scalapb-protoc-plugin: the scalapb Scala model code generation packaged as a protoc plugin, to be used from gradle
  • interop-tests

Additionally, 'plugin-tester-java' and 'plugin-tester-scala' contain an example project in Java and Scala respectively, with both sbt and Gradle configurations.

License

Akka gRPC is licensed under the Business Source License 1.1, please see the Akka License FAQ.

Tests and documentation are under a separate license, see the LICENSE file in each documentation and test root directory for details.

akka-grpc's People

Contributors

2m avatar chbatey avatar ctoomey avatar dotbg avatar drmontgomery avatar dwhjames avatar dwijnand avatar ennru avatar eshepelyuk avatar github-brice-jaglin avatar hungaikev avatar ignasi35 avatar johanandren avatar jroper avatar jrudolph avatar jtjeferreira avatar ktoso avatar lomigmegard avatar marcospereira avatar mcanlas avatar mlangc avatar octonato avatar patriknw avatar pvlugter avatar raboof avatar richdougherty avatar scala-steward avatar sebastian-alfers avatar tz70s avatar viktorklang avatar

Stargazers

 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  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  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  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

Watchers

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

akka-grpc's Issues

scripted: akka-grpc server (scala) should pass the status_code_and_message integration test

Variation: akka-grpc server scala with grpc-java client tester

https://travis-ci.org/akka/akka-grpc/jobs/362603376

[info] Running test status_code_and_message
[info] [INFO] [04/05/2018 12:45:16.399] [pool-1-thread-1-ScalaTest-running-GrpcInteropSpec] [akka.actor.ActorSystemImpl(default)] Exception thrown, unbinding
[error] org.scalatest.exceptions.TestFailedException
[error] 	at org.scalatest.Assertions.newAssertionFailedException(Assertions.scala:528)
[error] 	at org.scalatest.Assertions.newAssertionFailedException$(Assertions.scala:527)
[error] 	at org.scalatest.WordSpec.newAssertionFailedException(WordSpec.scala:1881)
[error] 	at org.scalatest.Assertions.fail(Assertions.scala:1121)
[error] 	at org.scalatest.Assertions.fail$(Assertions.scala:1117)
[error] 	at org.scalatest.WordSpec.fail(WordSpec.scala:1881)
[error] 	at com.lightbend.grpc.interop.GrpcInteropTests.withGrpcServer(GrpcInteropTests.scala:74)
[error] 	at com.lightbend.grpc.interop.GrpcInteropTests.$anonfun$grpcTests$4(GrpcInteropTests.scala:50)
[error] 	at com.lightbend.grpc.interop.GrpcInteropTests.pendingTestCaseSupport(GrpcInteropTests.scala:86)
[error] 	at com.lightbend.grpc.interop.GrpcInteropTests.$anonfun$grpcTests$3(GrpcInteropTests.scala:49)
[error] 	at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85)
[error] 	at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83)
[error] 0m	at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
[error] 	at org.scalatest.Transformer.apply(Transformer.scala:22)
[error] 	at org.scalatest.Transformer.apply(Transformer.scala:20)
[error] 	at org.scalatest.WordSpecLike$$anon$1.apply(WordSpecLike.scala:1078)
[error] 	at org.scalatest.TestSuite.withFixture(TestSuite.scala:196)
[error] 	at org.scalatest.TestSuite.withFixture$(TestSuite.scala:195)
[error] 	at org.scalatest.WordSpec.withFixture(WordSpec.scala:1881)
[error] 	at org.scalatest.WordSpecLike.invokeWithFixture$1(WordSpecLike.scala:1076)
[error] 	at org.scalatest.WordSpecLike.$anonfun$runTest$1(WordSpecLike.scala:1088)
[error] 	at org.scalatest.SuperEngine.runTestImpl(Engine.scala:289)
[error] 	at org.scalatest.WordSpecLike.runTest(WordSpecLike.scala:1088)
[error] 	at org.scalatest.WordSpecLike.runTest$(WordSpecLike.scala:1070)
[error] 	at org.scalatest.WordSpec.runTest(WordSpec.scala:1881)
[error] 	at org.scalatest.WordSpecLike.$anonfun$runTests$1(WordSpecLike.scala:1147)
[error] 	at org.scalatest.SuperEngine.$anonfun$runTestsInBranch$1(Engine.scala:396)
[error] 	at scala.collection.immutable.List.foreach(List.scala:389)
[error] 	at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:384)
[error] 	at org.scalatest.SuperEngine.runTestsInBranch(Engine.scala:373)
[error] 	at org.scalatest.SuperEngine.$anonfun$runTestsInBranch$1(Engine.scala:410)
[error] 	at scala.collection.immutable.List.foreach(List.scala:389)
[error] 	at org.scalatest.SuperEngine.traverseSubNodes$1(Engine.scala:384)
[error] 	at org.scalatest.SuperEngine.runTestsInBranch(Engine.scala:379)
[error] 	at org.scalatest.SuperEngine.runTestsImpl(Engine.scala:461)
[error] 	at org.scalatest.WordSpecLike.runTests(WordSpecLike.scala:1147)
[error] 	at org.scalatest.WordSpecLike.runTests$(WordSpecLike.scala:1146)
[error] 	at org.scalatest.WordSpec.runTests(WordSpec.scala:1881)
[error] 	at org.scalatest.Suite.run(Suite.scala:1147)
[error] 	at org.scalatest.Suite.run$(Suite.scala:1129)
[error] 	at org.scalatest.WordSpec.org$scalatest$WordSpecLike$$super$run(WordSpec.scala:1881)
[error] 	at org.scalatest.WordSpecLike.$anonfun$run$1(WordSpecLike.scala:1192)
[error] 	at org.scalatest.SuperEngine.runImpl(Engine.scala:521)
[error] 	at org.scalatest.WordSpecLike.run(WordSpecLike.scala:1192)
[error] 	at org.scalatest.WordSpecLike.run$(WordSpecLike.scala:1190)
[error] 	at org.scalatest.WordSpec.run(WordSpec.scala:1881)
[error] 	at org.scalatest.tools.Framework.org$scalatest$tools$Framework$$runSuite(Framework.scala:314)
[error] 	at org.scalatest.tools.Framework$ScalaTestTask.execute(Framework.scala:507)
[error] 	at sbt.ForkMain$Run$2.call(ForkMain.java:300)
[error] 	at sbt.ForkMain$Run$2.call(ForkMain.java:290)
[error] 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] 	at java.lang.Thread.run(Thread.java:748)
[error] Caused by: java.lang.AssertionError: expected:<UNKNOWN> but was:<CANCELLED>
[error] 	at org.junit.Assert.fail(Assert.java:88)
[error] 	at org.junit.Assert.failNotEquals(Assert.java:834)
[error] 	at org.junit.Assert.assertEquals(Assert.java:118)
[error] 	at org.junit.Assert.assertEquals(Assert.java:144)
[error] 	at io.grpc.testing.integration.AbstractInteropTest.statusCodeAndMessage(AbstractInteropTest.java:1507)
[error] 	at io.grpc.testing.integration2.GrpcJavaClientTester.statusCodeAndMessage(GrpcJavaClientTester.java:126)
[error] 	at io.grpc.testing.integration2.TestServiceClient.runTest(TestServiceClient.java:186)
[error] 	at io.grpc.testing.integration2.TestServiceClient.run(TestServiceClient.java:93)
[error] 	at com.lightbend.grpc.interop.IoGrpcClient$.run(IoGrpcClient.scala:20)
[error] 	at com.lightbend.grpc.interop.GrpcInteropTests.runGrpcClient(GrpcInteropTests.scala:80)
[error] 	at com.lightbend.grpc.interop.GrpcInteropTests.$anonfun$grpcTests$5(GrpcInteropTests.scala:50)
[error] 	at com.lightbend.grpc.interop.GrpcInteropTests.withGrpcServer(GrpcInteropTests.scala:62)
[error] 	... 47 more
[info] [info] - should pass the status_code_and_message integration test *** FAILED ***
[info] [info]   org.scalatest.exceptions.TestFailedException was thrown. (GrpcInteropTests.scala:74)

Recover from failed tests

When an interop test fails, all subsequent calls also fail.

Check whether that's something we should fix, or something 'harmless' in the test framework.

Support raw headers for requests

akka-grpc's server implementation will need to support both modeled and raw headers when reading headers from a request. Play has recently changed to use raw headers so support for raw headers is important if we want to embed akka-grpc in Play.

From reading the akka-grpc source I believe that the code that reads the Message-Encoding header may need to be changed to handle raw headers as well as modeled headers. It should be OK to leave any code that emits modeled headers as it currently is.

settings for what to generate

Choice between scala and java exists. I think setting for choosing server/client/both is missing.

That should also influence suggestedDependencies.

materialized values

It's currently _ or Any.

in parameter

The _ in the in: Source[Req, _] makes sense on the client side since it can't be used there (not materialized by user code). On the server side it doesn't make sense to have _, because something is actually materialized there. Better to have NotUsed on both sides (well it's the same trait on both sides so it must be the same on both sides)?

out return value

It seems like the mat val of the in is the Any mat val of the returned Source. That can be useful on the client side but should then be expressed in the types. What does it mean on the server side?

Run scripted tests on jenkins

That currently fails due to the -Dsbt.ivy.home=/localhome/jenkinsakka/.ivy2 option.

The -Dsbt.ivy.home=/localhome/jenkinsakka/.ivy2 is probably there because /home/jenkinsakka is an NFS mount, and we want each node to have its own ivy cache?

Create a new TestServiceClient based on akka-grpc stub

Current TestSerivceClietimplementation is tightly coupled with the grpc-java implementation. We need to refactor it or add a new variant that uses the akka-gprc client stub (see #38).

Ideally, we should be able to swap channels. We will start using a netty channel that will be later replaced by an akka-http channel.

The interop test can then verify a few combinations:

  • grpc-java server with grpc-java client
  • akka-grpc server with grpc-java client
  • akka-grpc server with akka-grpc stub using netty channel
  • akka-grpc server with akka-grpc stub using akka-http channel

generated package names

Something is iffy with how to control the package name of the generated code.

Seems like the file name of the .proto is used. hello-world.proto results in hello-world in the package name, which is obviously not valid, and using the file name is probably not a good idea.

What role does the other options have?

package helloworld; in the .proto doesn't seem to have any effect?

option java_package = "io.grpc.examples"; seems to be some root package, but is that how it's supposed to be used? Shouldn't that be the package?

Would also be good to clarify in examples/doc what the other options are good for, or remove them from example:

option java_multiple_files = true;
option java_outer_classname = "HelloWorldProto";

add real backpressure

We should implement element based backpressure.

Some pointers:

With that in place I assume that we can remove the buffer on the client side. See comment

      // channel calls don't support back-pressure so we need to buffered it
      // and eventually fail the stream

Investigate how to deal with extra clients options

At client side one may need to tweak how the client should work.

The grpc-java implementation has with methods, e.g.: withCompression, withExecutor, withInterceptors, etc. Those methods are added to the stub and returns a new tweaked stub.

We could have something similar or take an approach similar to Lagom's ServiceCall. To be discussed and analysed.

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.