forked from scalapb/zio-grpc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'chore/fix-build' into issue-298
- Loading branch information
Showing
137 changed files
with
10,978 additions
and
10,371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Scala Steward: Reformat with scalafmt 3.7.2 | ||
34b9f2c2d303a4c50988182586860b57dca5fa5d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
cd examples | ||
|
||
for d in */ | ||
do | ||
echo "** Running test for examples/$d" | ||
( cd "$d" && sbt scalafmtCheck Test/scalafmtCheck scalafmtSbtCheck test ) | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
*.log | ||
target | ||
.bsp | ||
.sbt | ||
.idea | ||
.metals | ||
.bloop | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,13 @@ | ||
version = "2.7.5" | ||
version = "3.7.2" | ||
rewrite.rules = [SortImports, RedundantBraces] | ||
maxColumn = 120 | ||
align = most | ||
align.preset = most | ||
runner.dialect = scala213source3 | ||
fileOverride { | ||
"glob:**/e2e/target/jvm-3/src_managed/main/**" { | ||
runner.dialect = scala3 | ||
} | ||
"glob:**/code-gen/target/jvm-3/src_managed/main/**" { | ||
runner.dialect = scala3 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Changelog | ||
|
||
## 0.6.1 | ||
* Only buffer stream if queue size is positive (#578, #580) | ||
|
||
## 0.6.0 | ||
|
||
### What changed? | ||
|
||
* Backpressure queue size is controlled by either | ||
`ZIO_GRPC_BACKPRESSURE_QUEUE_SIZE` environment variable or | ||
`zio_grpc.backpressure_queue_size` system property (previously the names | ||
were hyphenated). Change was made for compatibility with ZIO Config. | ||
* GeneratedServices no longer have a `R` type parameter for generated services. This simplifies the previous APIs and encourages the ZIO 2 | ||
style that service dependencies are passed via constructors (see [service pattern](https://zio.dev/reference/service-pattern/)) | ||
* Added `E` type parameter that represents the error type. | ||
* Context is now received as a second parameter for each handler. For | ||
convenience, there is a trait that only takes one parameter (the request | ||
type). | ||
* Introduce Transform for effectful transformations for services that do not have context. | ||
* Introduce GTransform for effectful transformations over both context and error type. | ||
* `ZTransform[ContextIn, ContextOut]` is now a type alias to GTransform that | ||
fixes the error channel to StatusException. | ||
* Classes and methods with suffix ClientWithMetadata have been renamed to ClientWithResponseMetadata. | ||
* Removed the `R` type parameter in most APIs. | ||
* ManagedServer renamed to ScopedServer. | ||
* Clean shutdown when a server is ran through a Scope or ZLayer. | ||
* Added backpressure support [docs](https://scalapb.github.io/zio-grpc/docs/backpressure) | ||
* Added client support for response metadata (#428) | ||
* Signifcant server performance improvement ([2.4x faster handling](https://github.com/scalapb/zio-grpc/pull/457#issuecomment-1350234894)) (#457) | ||
* Server can now send response metadata (#418) | ||
* Clients can now access the response metadata sent by server (#428) | ||
* ServiceList now has a `provideLayer` and `provide` that can be used to | ||
satisfy services dependencies. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
syntax = "proto3"; | ||
|
||
option java_multiple_files = true; | ||
option java_package = "scalapb.zio_grpc.helloworld"; | ||
option java_outer_classname = "HelloWorldProto"; | ||
|
||
package helloworld; | ||
|
||
// The greeting service definition. | ||
service Greeter { | ||
// Sends a greeting | ||
rpc SayHello (HelloRequest) returns (HelloReply) {} | ||
|
||
// Sends a litany of greetings | ||
rpc SayHelloStreaming (HelloRequest) returns (stream HelloReply) {} | ||
} | ||
|
||
// The actual message exchanged by the client and the server. | ||
message Hello { | ||
string name = 1; | ||
double d = 2; | ||
float f = 3; | ||
bool b = 4; | ||
int32 n = 5; | ||
int64 l = 6; | ||
oneof choice { | ||
string c1 = 7; | ||
bool c2 = 8; | ||
} | ||
message Pet { | ||
enum Color { | ||
BLACK = 0; | ||
WHITE = 1; | ||
BLUE = 2; | ||
RED = 3; | ||
YELLOW = 4; | ||
GREEN = 5; | ||
} | ||
string name = 1; | ||
Color color = 2; | ||
} | ||
repeated Pet pets = 9; | ||
} | ||
|
||
// The request message from the client. | ||
message HelloRequest { | ||
Hello request = 1; | ||
} | ||
|
||
// The response message from the server. | ||
message HelloReply { | ||
Hello response = 1; | ||
} |
17 changes: 17 additions & 0 deletions
17
benchmarks/src/main/scala/scalapb/zio_grpc/GreeterImpl.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package scalapb.zio_grpc | ||
|
||
import scalapb.zio_grpc.helloworld.testservice.ZioTestservice.Greeter | ||
import scalapb.zio_grpc.helloworld.testservice.{HelloReply, HelloRequest} | ||
import io.grpc.StatusException | ||
import zio.ZIO | ||
import zio.stream.ZStream | ||
|
||
class GreeterImpl(size: Long) extends Greeter { | ||
|
||
def sayHello(request: HelloRequest): ZIO[Any, StatusException, HelloReply] = | ||
ZIO.succeed(HelloReply(request.request)) | ||
|
||
def sayHelloStreaming(request: HelloRequest): ZStream[Any, StatusException, HelloReply] = | ||
ZStream.repeat(HelloReply(request.request)).take(size) | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
benchmarks/src/main/scala/scalapb/zio_grpc/ServerStreamingBenchmarkApp.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package scalapb.zio_grpc | ||
|
||
import io.grpc.ManagedChannelBuilder | ||
import io.grpc.ServerBuilder | ||
import scalapb.zio_grpc.helloworld.testservice._ | ||
import zio._ | ||
import java.time | ||
|
||
object ServerStreamingBenchmarkApp extends ZIOAppDefault { | ||
|
||
val size = 100000L | ||
|
||
val server = | ||
ServerLayer.fromEnvironment[ZioTestservice.Greeter](ServerBuilder.forPort(50051)) | ||
|
||
val client = | ||
ZLayer.scoped[Server] { | ||
for { | ||
ss <- ZIO.service[Server] | ||
port <- ss.port.orDie | ||
ch = ManagedChannelBuilder.forAddress("localhost", 50051).usePlaintext() | ||
client <- ZioTestservice.GreeterClient.scoped(ZManagedChannel(ch)).orDie | ||
} yield client | ||
} | ||
|
||
val service = | ||
ZLayer.succeed[ZioTestservice.Greeter] { | ||
new GreeterImpl(size) | ||
} | ||
|
||
def run = ZIO | ||
.foreach(Array(8192, 65536)) { queueSize => | ||
val props = java.lang.System.getProperties(); | ||
props.setProperty("zio-grpc.backpressure-queue-size", queueSize.toString()); | ||
|
||
for { | ||
_ <- Console.printLine(s"Starting with queue size $queueSize") | ||
cpt <- Ref.make(0) | ||
start <- Clock.instant.flatMap(Ref.make(_)) | ||
result <- ZioTestservice.GreeterClient | ||
.sayHelloStreaming(HelloRequest(request = Some(Hello(name = "Testing streaming")))) | ||
.tap(_ => cpt.update(_ + 1)) | ||
.tap { _ => | ||
for { | ||
now <- Clock.instant | ||
started <- start.get | ||
_ <- ZIO.when(time.Duration.between(started, now).getSeconds() >= 10)( | ||
start.set(now) *> cpt.get.flatMap(cpt => Console.printLine(s"Received $cpt messages")) | ||
) | ||
} yield () | ||
} | ||
.runDrain | ||
.timed | ||
_ <- Console.printLine(s"queue size: $queueSize (${result._1.toMillis()}ms)") | ||
} yield () | ||
} | ||
.provide(service >+> server >+> client) | ||
|
||
} |
Oops, something went wrong.