virusdave / zio-grpc   0.4.3

Apache License 2.0 GitHub

ScalaPB meets ZIO: write purely functional gRPC services and clients using ZIO

Scala versions: 2.13

ZIO gRPC Logo

Snapshot Artifacts

Welcome to ZIO-gRPC

This library enables you to write purely functional gRPC services using ZIO.

Documentation

Highlights

  • Supports all types of RPCs (unary, client streaming, server streaming, bidirectional).
  • Uses ZIO's Stream to let you easily implement streaming requests.
  • Cancellable RPCs: client-side ZIO interruptions are propagated to the server to abort the request and save resources.

Installation

Find the latest snapshot in here.

Add the following to your project/plugins.sbt:

val zioGrpcVersion = "0.4.2"

addSbtPlugin("com.thesamet" % "sbt-protoc" % "1.0.0-RC4")

libraryDependencies += "com.thesamet.scalapb.zio-grpc" %% "zio-grpc-codegen" % zioGrpcVersion

Add the following to your build.sbt:

val grpcVersion = "1.34.0"

PB.targets in Compile := Seq(
    scalapb.gen(grpc = true) -> (sourceManaged in Compile).value,
    scalapb.zio_grpc.ZioCodeGenerator -> (sourceManaged in Compile).value,
)

libraryDependencies ++= Seq(
    "com.thesamet.scalapb" %% "scalapb-runtime-grpc" % scalapb.compiler.Version.scalapbVersion,
    "io.grpc" % "grpc-netty" % grpcVersion
)

Usage

Place your service proto files in src/main/protobuf, and the plugin will generate Scala sources for them. Learn more about how to use ZIO gRPC generated code.

See a full example at the examples directory.