grpc-rx

GRPC stub & compiler for RxJava2

Лицензия

Лицензия

Категории

Категории

gRPC Сеть Networking
Группа

Группа

com.github.xiaodongw
Идентификатор

Идентификатор

grpc-rx-stub
Последняя версия

Последняя версия

0.5.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

grpc-rx
GRPC stub & compiler for RxJava2
Ссылка на сайт

Ссылка на сайт

https://github.com/xiaodongw/grpc-rx
Система контроля версий

Система контроля версий

https://github.com/xiaodongw/grpc-rx.git

Скачать grpc-rx-stub

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/com.github.xiaodongw/grpc-rx-stub/ -->
<dependency>
    <groupId>com.github.xiaodongw</groupId>
    <artifactId>grpc-rx-stub</artifactId>
    <version>0.5.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.xiaodongw/grpc-rx-stub/
implementation 'com.github.xiaodongw:grpc-rx-stub:0.5.0'
// https://jarcasting.com/artifacts/com.github.xiaodongw/grpc-rx-stub/
implementation ("com.github.xiaodongw:grpc-rx-stub:0.5.0")
'com.github.xiaodongw:grpc-rx-stub:jar:0.5.0'
<dependency org="com.github.xiaodongw" name="grpc-rx-stub" rev="0.5.0">
  <artifact name="grpc-rx-stub" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.xiaodongw', module='grpc-rx-stub', version='0.5.0')
)
libraryDependencies += "com.github.xiaodongw" % "grpc-rx-stub" % "0.5.0"
[com.github.xiaodongw/grpc-rx-stub "0.5.0"]

Зависимости

compile (5)

Идентификатор библиотеки Тип Версия
io.grpc : grpc-netty jar 1.14.0
io.grpc : grpc-protobuf jar 1.14.0
io.grpc : grpc-stub jar 1.14.0
io.reactivex.rxjava2 : rxjava jar 2.2.0
org.slf4j : slf4j-api jar 1.7.25

test (2)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.12
org.slf4j : slf4j-simple jar 1.7.25

Модули Проекта

Данный проект не имеет модулей.

GRPC-RX

This is a GRPC stub & compiler for RxJava2.

Check GRPC-KT for Kotlin Coroutine binding.

Getting started

  • In your project, configure Gradle to use the grpc-rxjava stub and compiler plugin
dependencies {
  compile "com.github.xiaodongw:grpc-rx-stub:0.5.0"
}
protobuf {
  protoc {
    artifact = "com.google.protobuf:protoc:3.5.1"
  }
  plugins {
    grpc {
      artifact = "com.github.xiaodongw:protoc-gen-grpc-rx:0.5.0"
    }
  }
  generateProtoTasks {
    all()*.plugins {
      grpc {}
    }
  }
}

Now you can fully utilize the elegant API from RxJava2 to handle you requests, for example:

  • Client side

    EchoGrpcRx.EchoStub stub = EchoGrpcRx.newStub(channel);
    
    Flowable<EchoReq> requests = Flowable.range(0, 10)
        .map(i -> EchoService.EchoReq.newBuilder()
            .setValue("hello")
            .build());
    
    Subscriber<EchoResp> responseSubscriber = new AutoTestSubscriber(4);
    
    stub.bidiStreaming(requests)
        .subscribe(responseSubscriber);
  • Server side

    public Flowable<EchoResp> bidiStreaming(Flowable<EchoReq> requests) {
      return requests.map(r -> EchoResp.newBuilder()
          .setValue("world")
          .build());
    }

Flow Control

For messages from GRPC to Flowable/Subscriber (responses at client side, requests at server side), the flow is controlled by Subscriber with Subscription.request(n), this follows the ReactiveStream pattern well.

For messages from Flowable/Publisher to GRPC (requests at client side, responses at server side), the flow is controlled by watermark settings, which means the GRPC subscriber will call Subscription.request(n) to request messages when outstanding message number is less than low watermark. The outstanding message number will never be more than high watermark.

Publish

Publish to Maven Central

  • Publish to Sonatype
gradle clean :grpc-rx-compiler:uploadArchives -PtargetOs=linux -PtargetArch=x86_64
gradle clean :grpc-rx-compiler:uploadArchives -PtargetOs=windows -PtargetArch=x86_64
gradle clean :grpc-rx-compiler:uploadArchives -PtargetOs=osx -PtargetArch=x86_64
gradle :grpc-rx-stub:uploadArchives
  • Promote to Maven Central
    • Go to https://oss.sonatype.org/
    • Close the staging repository if there is no problem.
    • Release the repository if close succeeded.

Версии библиотеки

Версия
0.5.0