RSocket versus gRPC

We may still wonder why we need a separate framework if there is a well-known framework called gRPC. The gRPC is described as follows:

"A high performance, open source, general-purpose RPC framework (https://github.com/grpc)"

This project was initially developed by Google and aimed to provide asynchronous messaging over HTTP/2. It uses Protocol Buffers (Protobuf) as the Interface Description Language (IDL) and as its underlying message interchange format.

To learn more about Service Definition using IDL and Protobuf, please see the following link:
https://grpc.io/docs/guides/concepts.html#service-definition

In general, gRPC offers an almost identical messaging semantic to a Reactive Streams one and provides the following interface:

interface StreamObserver<V>  {

void onNext(V value);

void onError(Throwable t);

void onCompleted();
}

As we can see, the semantic is 1:1 to Observer from RxJava 1. In turn, the gRPC's API offers the Stream interface, which expands the following methods: 

public interface Stream {

void request(int numMessages);

...

boolean isReady();

...
}

Looking at the preceding code, we may get the feeling that gRPC, along with asynchronous message passing, gives backpressure control support as well. However, that part is a bit tricky. In general, the interaction flow is somewhat similar to what we saw in Diagram 8.13, with the only difference being that it supports the flow control with a higher granularity. Since gRPC is built on top of HTTP/2, the framework employees HTTP/2 flow control as the building block for providing a fine-grained backpressure control. Nevertheless, the flow control still relies on the sliding window size in bytes, so the backpressure control on the logical elements' level granularity is left uncovered.

Another significant difference between gRPC and RSocket is that gRPC is an RPC framework while RSocket is a protocol. gRPC is based on the HTTP/2 protocol and provides code-generation for service stubs and clients. By default, gRPC uses Protobuf for messaging format; however, it may also support other formats such as JSON. At the same time, RSocket gives only a reactive implementation for the server and the client. Also, there is a separate RPC framework called RSocket-RPC, which is built on top of the RSocket protocol and provides all the capabilities of gRPC. RSocket-RPC allows code generation based on Protobuf models in a fashion identical to gRPC. So, any project that uses gRPC can migrate smoothly to RSocket-RPC.

To learn more about RSocket-RPC, please see the following link: https://github.com/netifi/rsocket-rpc.

To learn more about backpressure control support in gRPC, please see the following link: https://github.com/salesforce/reactive-grpc#back-pressure.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.146.221.144