An open API service indexing awesome lists of open source software.

https://github.com/libyarp/yarp.rb

YARP implementation for Ruby
https://github.com/libyarp/yarp.rb

rpc rpc-library ruby

Last synced: 2 months ago
JSON representation

YARP implementation for Ruby

Awesome Lists containing this project

README

          

# yarp.rb

YARP (Yet Another RPC Protocol) is a simple serialization format and RPC
protocol. YARP is:

- Lighter than JSON
- Lighter than HTTP
- Heavier than Protocol Buffers/gRPC, Cap'n'Proto, and MessagePack

And it does not intend to replace any of the former.
YARP does not use sticky connections, making it load-balancer-friendly, and
provides cleaner autogenerated code.

## Why should I use YARP?

You shouldn't. YARP is a proof of concept and currently considered quite
unstable; This may change over time, as it begins being used on real projects,
but it still does not provide features found in Protobufs/gRPC.
You are, however, welcome to use it as you deem fit. Feel free to open an issue
in case you stumble in an odd behaviour.

## How do I use YARP?

YARP is composed of three distinct parts:

1. Message and Service Definitions
2. Autogenerated code
3. Services implementation

YARP's IDL is quite similar to Protobuf's, making it familiar out-of-box. First,
define messages and services:

```
package io.libyarp;

message RandomBytesRequest {
desired_length int8 = 0; # Fields indexes begin at zero.
}

message RandomBytesResponse {
@repeated data uint8 = 0;
}

service RandomBytesService {
generate_random_bytes(RandomBytesRequest) -> RandomBytesResponse;
}
```

Then, provide the definition to [`yarpc`](https://github.com/libyarp/yarpc):

```
$ yarpc random_bytes_service.yarp --lang ruby --package rbs --out ./rbs
```

Finally, implement the service:

```ruby
class SampleService
include Io::Libyarp::RandomBytesService

def generate_random_bytes(req)
SecureRandom.bytes(req.desired_length)
end
end

Yarp::Server.new.run
```