0.0
No release in over 3 years
A simple gem for nested grpc message encoding and decoding
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.17
~> 1.17.1
~> 10.0
~> 3.0

Runtime

~> 1.18.0
 Project Readme

grpc_serializer

A simple Ruby 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)