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
- Host: GitHub
- URL: https://github.com/libyarp/yarp.rb
- Owner: libyarp
- License: lgpl-3.0
- Created: 2022-05-09T17:45:37.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-16T18:50:44.000Z (almost 4 years ago)
- Last Synced: 2023-08-12T01:54:57.666Z (over 2 years ago)
- Topics: rpc, rpc-library, ruby
- Language: Ruby
- Homepage:
- Size: 69.3 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
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
```