Popularity
0.2
Stable
Activity
3.2
-
0
1
0

Description

A simple gem for nested grpc message encoding and decoding. When you have deeply nested hash to convert to grpc message, it is difficult. So I wrote a tiny library :). Similar to ActiveModelSerializer

Programming language: Ruby
License: MIT License
Tags: Abstraction     Rails     Ruby     Serialization     Ruby On Rails     Grpc    

grpc_serializer alternatives and similar gems

Based on the "Abstraction" category.
Alternatively, view grpc_serializer alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of grpc_serializer or a related project?

Add another 'Abstraction' Gem

README

grpc_serializer

A simple gem for nested grpc message encoding and decoding

Usage

$ gem install grpc_serializer

Sample Proto file (.proto) :

      syntax = "proto3";

       package cpqgrpc.product.v1;

       message Shop {
          string name = 1;   
          repeated string items = 2
       }

       message ProductRequest {
         uint64 id = 2;
         string name = 3;
         repeated string categories = 4;
         Shop shop = 5
       }

Use the generated stub class ProductRequest as follows. Do deep_symbolize_keys before sending as argument

payload:

  {
    id: 1,
    name: "Macbook"
    categories: ["accessories", "electronics"],
    shop: {
      name: "shop 1",
      items: ["item1", "item2"]  
    }
  }
grpc_msg = GrpcSerializer.hash_to_grpc_object(payload, ProductRequest)

To decode to hash on client or server

hash = GrpcSerializer.grpc_object_to_hash(grpc_msg, ProductRequest)