<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shiladitya Mandal on Medium]]></title>
        <description><![CDATA[Stories by Shiladitya Mandal on Medium]]></description>
        <link>https://medium.com/@shiladitya16?source=rss-a0eb22adf4cd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*kcS3_kZ11p6tGswWKnuAFw.jpeg</url>
            <title>Stories by Shiladitya Mandal on Medium</title>
            <link>https://medium.com/@shiladitya16?source=rss-a0eb22adf4cd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 19:26:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shiladitya16/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Circuit breaker and monitoring of a gRPC service in Ruby (Part 1)]]></title>
            <link>https://medium.com/@shiladitya16/circuit-breaker-and-monitoring-of-a-grpc-service-in-ruby-part-1-7509c7e1356a?source=rss-a0eb22adf4cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/7509c7e1356a</guid>
            <category><![CDATA[grpc]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Shiladitya Mandal]]></dc:creator>
            <pubDate>Mon, 01 May 2017 00:30:41 GMT</pubDate>
            <atom:updated>2017-05-01T00:42:32.409Z</atom:updated>
            <content:encoded><![CDATA[<p>gRPC is a well suited framework for a micro-services architecture, where there are small independent components talking to each other over the network. When I started building multiple components communicating with each other over gRPC, I started realizing there were needs for certain basic tools around a gRPC call (both server side and client side), which were not available out of the box. For example, things like instrumentation of gRPC calls, or a simple health API. I realized I was having to write these components every time I built a new service. This brought me to the idea of building a <a href="https://github.com/shiladitya-bits/grpc-commons">grpc-commons</a>, which will be a set of basic tools required in a micro-services architecture. In this post, I will be focusing on a couple of things — circuit breaker &amp; monitoring.</p><h3>Circuit Breaker</h3><p>A common requirement in an architecture, where independent modules are separate services over the network. Difference between a normal method call and a RPC call over the network is that a RPC call can fail, or become unresponsive. From <a href="https://martinfowler.com/bliki/CircuitBreaker.html">Martin Fowler’s post</a>,</p><p>“<em>The basic idea behind the circuit breaker is very simple. You wrap a protected function call in a circuit breaker object, which monitors for failures. Once the failures reach a certain threshold, the circuit breaker trips, and all further calls to the circuit breaker return with an error, without the protected call being made at all. Usually you’ll also want some kind of monitor alert if the circuit breaker trips.</em>”</p><p>This is how a circuit breaker state diagram usually looks:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/0*Ab2sJI6WadgEnqVV.png" /></figure><h3>Monitoring</h3><p>Monitoring is crucial to any software system. I will not be talking about general monitoring systems in this post. I will discuss points of monitoring in a gRPC call that could be setup without much developer effort.</p><p>In Part 1, I will try to explain the concept of having a grpc-commons and the implementation. Will focus on monitoring in Part 2.</p><h3>grpc-commons: Under the hood</h3><p>I have mostly been writing gRPC services in Ruby recently. grpc-commons is currently, a set of tools which does the above (and more in future) which would be helpful for a gRPC server / client written in Ruby. I have not packaged them separately (tooling for client &amp; server), but will explain them separately here.</p><p><strong>If you look at the generated ruby file for a gRPC service:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sCRmlTHShkCULGzM.png" /></figure><p>All the GRPC related methods are inherited from GRPC::GenericService.</p><p>And this is how we call a service defined like above:</p><pre>stub = Snip::UrlSnipService::Stub.new(&#39;0.0.0.0:50052&#39;, :this_channel_is_insecure)<br>     req = Snip::SnipRequest.new(url: &#39;http://shiladitya-bits.github.io&#39;)<br>     resp_obj = stub.snip_it(req)</pre><p>To know more about implementation details of a basic gRPC client-server call in Ruby, head over to my post (here)[<a href="https://shiladitya-bits.github.io/Building-Microservices-from-scratch-using-gRPC-on-Ruby/">https://shiladitya-bits.github.io/Building-Microservices-from-scratch-using-gRPC-on-Ruby/</a>].</p><p>I wanted the easiest way to plug in my tools on the client side. the Snip::UrlSnipService::Stub class is what gets called when you make the RPC call. So, I went ahead and overrode a new module GrpcCommons::GenericService from GRPC::GenericService</p><pre>module GrpcCommons<br>  module GenericService<br><br>    def self.included klass<br><br>      klass.class_eval do<br>        include GRPC::GenericService<br><br>        # This is an override for the same method in GRPC::GenericService<br>        def self.rpc_stub_class<br>          stub_claz = super<br>          instance_meths = stub_claz.instance_methods(false)<br>          alt_stub_claz = Class.new(stub_claz) do<br>            instance_meths.each do |meth|<br>              define_method(meth) do |*args|<br>                tracker_name = &quot;#{self.class.name[0..self.class.name.rindex(&quot;::&quot;)]}:#{meth}&quot;<br><br>                stoplight_lambda = Stoplight(tracker_name) {<br>                  super(*args)<br>                }.with_cool_off_time(ENV[&#39;GRPC_COMMONS_COOLOFF_INTERVAL&#39;].to_i)<br><br>                response = StatsD.measure(tracker_name) do<br>                  stoplight_lambda.run<br>                end<br>                response<br><br>              end<br>            end<br>          end<br>          alt_stub_claz<br>        end<br>      end<br>    end<br>  end<br>end</pre><p><a href="https://github.com/shiladitya-bits/grpc-commons/blob/master/lib/grpc-commons/generic_service.rb">Link to this file on Github</a></p><p>If you see, I am wrapping each RPC method defined in the Service class (whenever any Service class includes GrpcCommons::GenericService module instead of GRPC::GenericService, the Stub class gets overriden by the above implementation). Each RPC call will go through a circuit breaker check (using Stoplight gem for this). And the actual run method goes through a StatsD call for instrumentation. If you are not aware of StatsD and how it helps in monitoring your apps, <a href="https://www.datadoghq.com/blog/statsd/">read this blog by Datadog</a>. I will try to connect the dots in a future post about how I have been doing my monitoring in the 2nd part.</p><p>Now, let’s use this tool given in our gRPC client. This is how a modified service definition file will look like after replacing the GenericService module:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*miBRWgwQjURiJ8gi.png" /></figure><p>Make sure the grpc-commons gem is included in your Gemfile. Full code is available in a sample grpc app (<a href="https://github.com/shiladitya-bits/snip-service">snip</a>), which I have been discussing in <a href="https://shiladitya-bits.github.io/Building-Microservices-from-scratch-using-gRPC-on-Ruby/">previous posts</a> as well.</p><p>Now, you are set to use the new wrapper (with Stoplight and StatsD tracking). There is nothing you need to change in the way the gRPC call is made. Just changing your service definition to use the new module does all the work under the hood!</p><pre>stub = Snip::UrlSnipService::Stub.new(&#39;0.0.0.0:50052&#39;, :this_channel_is_insecure)<br>     req = Snip::SnipRequest.new(url: &#39;http://shiladitya-bits.github.io&#39;)<br>     resp_obj = stub.snip_it(req)</pre><p>We are done with a basic setup of using these common tools for circuit breaking and monitoring. Will continue implementation details on each in Part 2.</p><p><em>Originally published at </em><a href="https://shiladitya-bits.github.io/Circuit-breaker-and-monitoring-of-a-gRPC-service-part-1/"><em>shiladitya-bits.github.io</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7509c7e1356a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dockerization of gRPC service in Ruby]]></title>
            <link>https://medium.com/@shiladitya16/dockerization-of-grpc-service-in-ruby-abbb991185f3?source=rss-a0eb22adf4cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/abbb991185f3</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[grpc]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Shiladitya Mandal]]></dc:creator>
            <pubDate>Sun, 30 Apr 2017 08:06:35 GMT</pubDate>
            <atom:updated>2017-04-30T08:08:24.598Z</atom:updated>
            <content:encoded><![CDATA[<p>In a previous post, I had talked about <a href="https://medium.com/@shiladitya16/building-micro-services-using-grpc-on-ruby-41acb755ee06">Building Microservices using gRPC on Ruby</a>. Today, let’s talk about how to deploy the same application we built using Docker.</p><p>If you are new to the concept of <em>Docker</em> and <em>containers</em>,</p><p><em>Docker automates the repetitive tasks of setting up and configuring development environments so that developers can focus on what matters: building great software.</em></p><p>Learn more about them on the <a href="https://www.docker.com/what-container">official site</a>.</p><p>First, make sure your local environment has Docker engine setup. There are plenty of resources on the official website to download and get your local Docker engine running.</p><h3>Setting up the Dockerfile</h3><p>Create a new file in your project root directory: <strong>Dockerfile</strong></p><pre>FROM ruby:2.3.1</pre><pre>RUN mkdir /snip<br>WORKDIR /snip<br>COPY Gemfile /snip<br>COPY Gemfile.lock /snip</pre><pre>RUN bundle config --global frozen 1</pre><pre>RUN bundle install --without development test<br>COPY lib /snip/lib</pre><pre>EXPOSE 50052<br>ENTRYPOINT [ &quot;bundle&quot;, &quot;exec&quot;]<br>CMD [&quot;lib/start_server.rb&quot;]</pre><h3>Details behind the scenes</h3><p>Let’s try to understand what we wrote here. It is pretty simple:</p><ol><li>FROM ruby:2.3.1 - just extending our docker image from a ruby image so we don&#39;t have to install ruby ourselves here.</li><li>snip directory - This is the directory where our application will be installed</li><li>bundle config --global frozen 1 - to make sure Gemfile and Gemfile.lock agree with each other</li><li>Note, we could also have done bundle install --deployment directly, in which case bundle config --global frozen 1 is enabled by default.</li><li>COPY lib /snip/lib - copying our application directory.</li><li>EXPOSE 50052 - exposing the application server port on the container.</li><li>ENTRYPOINT and CMD - tells what command to execute when container is deployed.</li></ol><h3>Building a Docker image</h3><p>To build docker image, simply run :</p><pre>docker build -t snip .</pre><p>This will build your image with latest tag. To build an image with a custom tag,</p><pre>docker build -t snip:v1 .</pre><h3>Why copy Gemfile and application code separately?</h3><p>If you notice carefully, we are executing COPY on Gemfile, and application directory /lib separately before and after bundle install. We could also have copied all of the content at once and run bundle install at the end.</p><p>The reason is we would lose out on caching the bundler build!</p><p>When we run docker build, Docker creates a layer for each command executed. When you execute it a second time it will reuse the cache from previous execution if it did not change.</p><p>If you copy the application directory before bundle install, there is a high probability that COPY command will not get a cache hit because your application code would keep changing. This will stop using cache, and execute all future commands, including bundle install.</p><p>With our current Dockerfile, it will only run bundle install in the next build if you have changes in your Gemfile or Gemfile.lock.</p><h3>Running the docker image on local</h3><p>Simple command to run your new image (interactive run -i, closing this process will kill container as well):</p><pre>docker run -i -t snip:latest</pre><p><strong><em>Points to note:</em></strong></p><ol><li>-i is to run in interactive mode. Ctrl+C will kill your container as well.</li><li>-t snip:latest runs the snip image with latest tag. Check docker images output for all images.</li><li>Check docker ps out for all running containers.</li></ol><h3>Issue with git based gens with SSH authentication</h3><p>Many of you who are trying out Docker in your organizations which have private repositories, you might face an issue during Docker build like this:</p><p>Let’s say your Gemfile had this line which uses SSH authentication for your git based snip gem:</p><pre>gem &#39;snip&#39;,:git =&gt; &quot;git@github.com:shiladitya-bits/snip.git&quot;,:branch =&gt; &#39;master&#39;</pre><p>docker build gives the following error:</p><pre>Fetching git@github.com:shiladitya-bits/snip.git<br>Host key verification failed.<br>fatal: Could not read from remote repository.</pre><pre>Please make sure you have the correct access rights<br>and the repository exists.</pre><p>The above fails because git@github.com:shiladitya-bits/snip.git requires SSH based authentication, and there are no SSH credentials inside the docker machine. Hence, bundle install which runs successfully on your host machine(where SSH credentials are present in ~/.ssh directory), the same command fails to run inside your docker machine.</p><p>There are 2 solutions to this problem:</p><h4>HTTPS Based authentication</h4><p>Change it to:</p><pre>gem &#39;snip&#39;,:git =&gt; &quot;https://github.com/shiladitya-bits/snip&quot;,:branch =&gt; &#39;master&#39;</pre><p>This will work as it is for public repositories. For <strong>private</strong> repositories, you will have to setup an <a href="https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/">OAuth key</a> for access to your repository, and prepend it to your URL:</p><pre>gem &#39;snip&#39;,:git =&gt; &quot;https://&lt;YOUR_OAUTH_KEY&gt;&gt;:x-oauth-basic@github.com/shiladitya-bits/snip&quot;,:branch =&gt; &#39;master&#39;</pre><h4>Solution for SSH based authentication</h4><p>We need to modify our Dockerfile slightly to copy our ssh keys onto the docker machine as well. Here is a modified version:</p><pre>FROM ruby:2.3.1</pre><pre>RUN mkdir /snip<br>WORKDIR /snip<br>COPY Gemfile /snip<br>COPY Gemfile.lock /snip</pre><pre># Create .ssh directory and copying our ssh key from host machine to docker machine<br>RUN mkdir /root/.ssh</pre><pre># NOTE: Make sure your local ~/.ssh/id_rsa* is first copied to your local project working directory<br>COPY id_rsa* /root/.ssh/</pre><pre>RUN bundle config --global frozen 1</pre><pre>RUN eval &quot;$(ssh-agent -s)&quot;<br>RUN ssh-keyscan -H github.com &gt;&gt; ~/.ssh/known_hosts</pre><pre># restricting permission to ssh keys<br>RUN chmod 0600 ~/.ssh/id_rsa<br>RUN chmod 0600 ~/.ssh/id_rsa.pub</pre><pre>RUN bundle install --without development test<br>COPY lib /snip/lib</pre><pre># Removing our copied ssh keys<br>RUN rm ~/.ssh/id_rsa*</pre><pre>EXPOSE 50052<br>ENTRYPOINT [ &quot;bundle&quot;, &quot;exec&quot;]<br>CMD [&quot;lib/start_server.rb&quot;]</pre><p><em>Small note</em>: You need to copy your local ~/.ssh/id_rsa* to your project working directory. This is due to the restriction of COPY command not being able to copy files outside of a build context.</p><p>The above modifications are all aimed at a simple goal — making a valid ssh key available to the docker machine during bundler build. There are other ways of achieving the same, one of them being <a href="http://www.habitus.io/">Habitus</a> — a build tool for Docker which helps you host some data on a local server which is available to the docker machine. Habitus works well, but I think it is overengineering to achieve what we want to do in this particular case. The above solution might look like a hack, but it is a one time thing which doesn’t hurt much later!</p><p>End of this post! As before, you can find the working code for <a href="https://github.com/shiladitya-bits/snip-service">snip-service</a> on Github.</p><p>Find the <a href="https://shiladitya-bits.github.io/Dockerization-of-gRPC-service-in-Ruby/">original post</a> on my <a href="https://shiladitya-bits.github.io/">blog</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abbb991185f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Micro-services using gRPC on Ruby]]></title>
            <link>https://medium.com/@shiladitya16/building-micro-services-using-grpc-on-ruby-41acb755ee06?source=rss-a0eb22adf4cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/41acb755ee06</guid>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[grpc]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Shiladitya Mandal]]></dc:creator>
            <pubDate>Sun, 30 Apr 2017 08:02:28 GMT</pubDate>
            <atom:updated>2017-04-30T08:07:40.732Z</atom:updated>
            <content:encoded><![CDATA[<p>Today, REST with JSON is the most popular framework amongst web developers for network communication. But, it is not very suitable for a micro-services architecture mainly because of latency added by JSON data transmission / serializing / deserializing.</p><p>My quest for finding an optimal network communication framework for micro-services brought me to gRPC. <br>“<em>gRPC is a modern, open source remote procedure call (RPC) framework that can run anywhere. It enables client and server applications to communicate transparently, and makes it easier to build connected systems.</em>”</p><p>To read more about benefits of gRPC, visit the official site <a href="http://www.grpc.io/faq/">here</a>.</p><p>Serialization in gRPC is based on <a href="https://developers.google.com/protocol-buffers/docs/overview">Protocol Buffers</a>, a language and platform independent serialization mechanism for structured data. <br>“<em>Protocol buffers are a flexible, efficient, automated mechanism for serializing structured data — think XML, but smaller, faster, and simpler.</em>”</p><p>In the remaining part of this post, I will be walking you through setting up a simple gRPC server from scratch on Ruby. Let’s build <em>Snip — </em>a dummy URL shortener!</p><p>We will divide our code structure into 3 separate repositories:</p><ol><li><strong>snip</strong> : contains the proto definitions and converted ruby files for client communication. Basically, this is like an interface between client and server, specifying the RPC methods, and the request and response formats.</li><li><strong>snip-service</strong> : Service implementation for the RPC methods (This is where the gRPC server sits).</li><li><strong>X-app</strong> : This is any application who wishes to call snip-service for shortening URLs.</li></ol><p>snip will be packaged as a gem, and included in both snip-service and X-app.</p><h3>Step 0: Install dependencies</h3><p>Make sure you have ruby and bundler setup working. Then, install the required gems for grpc:</p><pre>gem install grpc<br>gem install grpc-tools</pre><h3>PART A: snip gem</h3><h4>Step 1: Setup snip gem</h4><p>snip is supposed to be a ruby gem, so you could use the bundler scaffold for creating it.</p><pre>bundle gem snip</pre><p>Add this to snip.gemspec file:</p><pre>spec.add_dependency &quot;grpc&quot;</pre><h4>Step 2: Define proto files</h4><p>Let’s create a new file proto/snip.proto</p><pre>syntax = &quot;proto3&quot;;<br>package snip;</pre><pre>service UrlSnipService {<br>    rpc snip_it(SnipRequest) returns (SnipResponse) {}<br>}</pre><pre>message SnipRequest {<br>    string url = 1;<br>}</pre><pre>message SnipResponse {<br>    string url = 1;<br>}</pre><h4>Step 3: Generate ruby bindings for the proto definition</h4><p>Next, we are going to convert the defined proto files to ruby bindings, which are ultimately going to be used by both the client and the server.</p><pre>grpc_tools_ruby_protoc -Iproto --ruby_out=lib --grpc_out=lib proto/snip.proto</pre><p>My <strong>snip</strong> directory <em>tree</em> after this command:</p><pre>├── Gemfile<br>├── Gemfile.lock<br>├── LICENSE<br>├── README.md<br>├── lib<br>│   ├── proto<br>│   │   ├── snip_pb.rb<br>│   │   └── snip_services_pb.rb<br>│   └── snip<br>│       └── version.rb<br>├── proto<br>│   └── snip.proto<br>└── snip.gemspec</pre><p>Note that snip_pb.rb and snip-services_pb.rb are the important files which are required for client-server communication. This is how they should look:</p><p><strong>snip_pb.rb</strong></p><pre># Generated by the protocol buffer compiler.  DO NOT EDIT!<br># source: snip.proto</pre><pre>require &#39;google/protobuf&#39;</pre><pre>Google::Protobuf::DescriptorPool.generated_pool.build do<br>  add_message &quot;snip.SnipRequest&quot; do<br>    optional :url, :string, 1<br>  end<br>  add_message &quot;snip.SnipResponse&quot; do<br>    optional :url, :string, 1<br>  end<br>end</pre><pre>module Snip<br>  SnipRequest = Google::Protobuf::DescriptorPool.generated_pool.lookup(&quot;snip.SnipRequest&quot;).msgclass<br>  SnipResponse = Google::Protobuf::DescriptorPool.generated_pool.lookup(&quot;snip.SnipResponse&quot;).msgclass<br>end</pre><p><strong>snip_services_pb.rb</strong></p><pre># Generated by the protocol buffer compiler.  DO NOT EDIT!<br># Source: snip.proto for package &#39;snip&#39;</pre><pre>require &#39;grpc&#39;<br>require &#39;snip_pb&#39;</pre><pre>module Snip<br>  module UrlSnipService<br>    class Service</pre><pre>      include GRPC::GenericService</pre><pre>      self.marshal_class_method = :encode<br>      self.unmarshal_class_method = :decode<br>      self.service_name = &#39;snip.UrlSnipService&#39;</pre><pre>      rpc :snip_it, SnipRequest, SnipResponse<br>    end</pre><pre>    Stub = Service.rpc_stub_class<br>  end<br>end</pre><p>Voila! You are done with your snip gem. We will move onto the service implementation next.</p><h3>PART B: snip-service &amp; gRPC server</h3><h4>Step 1: Setup</h4><p>Add the following to your Gemfile in snip-service</p><pre>gem &#39;snip&#39;,:git =&gt; &quot;https://github.com/shiladitya-bits/snip&quot;,:branch =&gt; &#39;master&#39;<br>gem &#39;grpc&#39;, &#39;~&gt; 1.0&#39;</pre><p>Replace snip gem path with wherever you have setup the gem to be in.</p><h4>Step 2: Service implementation</h4><p><strong>lib/services/snip_service.rb</strong></p><pre>require &#39;grpc&#39;<br>require &#39;snip_services_pb&#39;</pre><pre>class SnipService &lt; Snip::UrlSnipService::Service</pre><pre>  def snip_it(snip_req, _unused_call)<br>    puts &quot;Received URL snip request for #{snip_req.url}&quot;<br>    Snip::SnipResponse.new(url: snip_req.url)<br>  end<br>end</pre><p>snip_it is the RPC method we defined in our proto. Let us look at the 2 parameters here:</p><ul><li><strong>snip_req</strong> - the request proto object sent by client in the format as defined in proto Snip::SnipRequest</li><li><strong>_unused_call</strong> - this contains other metadata sent by client. We will talk about how to send metadata in another post later.</li></ul><p>You need to return an object of Snip::SnipResponse from this method as your response. For keeping the implementation simple, we are sending back the same URL as sent by the client.</p><h4>Step 3: Setup your gRPC server</h4><p>Now that your service implementation is ready, let us setup the gRPC server that will be serving calls to your service.</p><p><strong>lib/start_server.rb</strong></p><pre>#!/usr/bin/env ruby<br>require &#39;rubygems&#39;<br>require &#39;snip_services_pb&#39;<br>require_relative &#39;services/snip_service&#39;<br>class SnipServer</pre><pre>  class &lt;&lt; self<br>    def start<br>      start_grpc_server<br>    end</pre><pre>    private<br>    def start_grpc_server<br>      @server = GRPC::RpcServer.new<br>      @server.add_http2_port(&quot;0.0.0.0:50052&quot;, :this_port_is_insecure)<br>      @server.handle(SnipService)<br>      @server.run_till_terminated<br>    end<br>  end<br>end</pre><pre>SnipServer.start</pre><p>A very simple ruby class which starts the server on port 50052 on running this:</p><pre>bundle exec lib/start_server.rb</pre><p>You might need to do a chmod +x lib/start_server.rb for giving executable permissions.</p><h3>PART C: X-app client</h3><h4>Step 1: Setup</h4><p>Same as the snip-service Gemfile, you need to include snip gem in your client as well.</p><pre>gem &#39;snip&#39;,:git =&gt; &quot;https://github.com/shiladitya-bits/snip&quot;,:branch =&gt; &#39;master&#39;<br> gem &#39;grpc&#39;, &#39;~&gt; 1.0&#39;</pre><h4>Step 2: Last step: RPC call!</h4><p>Just a final piece of code which helps you test out your gRPC server:</p><p><strong>test/test_snip_service</strong></p><pre>#!/usr/bin/env ruby<br>require &#39;grpc&#39;<br>require &#39;snip_services_pb&#39;</pre><pre>def test_single_call<br>  stub = Snip::UrlSnipService::Stub.new(&#39;0.0.0.0:50052&#39;, :this_channel_is_insecure)<br>  req = Snip::SnipRequest.new(url: &#39;http://shiladitya-bits.github.io&#39;)<br>  resp_obj = stub.snip_it(req)<br>  puts &quot;Snipped URL: #{resp_obj.url}&quot;<br>end</pre><pre>test_single_call</pre><p>There you go! Your first working gRPC communication is complete!</p><p>The <a href="https://github.com/shiladitya-bits/snip">snip</a> and <a href="https://github.com/shiladitya-bits/snip-service">snip-service</a> repositories are available on Github. You can find a sample client call inside snip-service itself in test/test_snip_service.</p><p>This is the end of this post. Check out my latest post on <a href="https://medium.com/@shiladitya16/dockerization-of-grpc-service-in-ruby-abbb991185f3">Dockerizing your gRPC service</a></p><p>Find the <a href="https://shiladitya-bits.github.io/Building-Microservices-from-scratch-using-gRPC-on-Ruby/">original post</a> on my <a href="https://shiladitya-bits.github.io/">blog</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41acb755ee06" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RTO Hypothecation Removal Process (Bangalore)]]></title>
            <link>https://medium.com/@shiladitya16/rto-hypothecation-removal-process-bangalore-64da869e520d?source=rss-a0eb22adf4cd------2</link>
            <guid isPermaLink="false">https://medium.com/p/64da869e520d</guid>
            <category><![CDATA[tor]]></category>
            <category><![CDATA[auto-loans]]></category>
            <category><![CDATA[bangalore]]></category>
            <dc:creator><![CDATA[Shiladitya Mandal]]></dc:creator>
            <pubDate>Sat, 02 Jul 2016 07:06:42 GMT</pubDate>
            <atom:updated>2016-07-02T07:06:42.684Z</atom:updated>
            <content:encoded><![CDATA[<p>I recently completed my hypothecation removal process. It is fairly simple if you know what to do. I am going to share a step by step guide for you to follow. For me it was Koramangala RTO, Bangalore, but I believe it should be similar for other places as well.</p><h3>Prerequisites</h3><p>To start off, first you need to make sure you have the <strong>NOC</strong> and <strong>2 copies of Form 35</strong> which you can easily request from your the who issued your loan. If your current NOC has expired (usually valid for 90 days), you can ask your bank for a new one without any charges. There should be a placeholder on the Form 35 for your <strong>signature</strong> and <strong>date</strong>. Fill them up.</p><p>Things to get <strong>photocopied</strong> :</p><ol><li>Insurance</li><li>Pollution certificate</li></ol><p>Buy the following <strong>stationery</strong> :</p><ol><li><strong>Paper file</strong> with a thread to pin all your documents in one place</li><li>A plastic cover to keep your RC card (yes you will have to submit your original RC card).</li><li>Postal cover with Rs.20 stamp — write down your <strong>address</strong>(where you want it delivered), <strong>phone number</strong>, and <strong>Vehicle number </strong>on it</li></ol><p>Now, you are good to go the RTO.</p><h3>At the RTO</h3><p>(If you are at the Koramangala RTO, go straight to Room 11 in 2nd floor. Elsewhere, just ask someone where the RC hypothecation removal happens. Avoid all agents, they will just charge you extra for nothing)</p><p><strong><em>Step 1: Cash counter</em></strong></p><p>Go to the cash counter and pay the fees for RC hypothecation removal (Rs. 100/-) — you will get <strong>2 receipts</strong></p><p><strong><em>Step 2: Officer 1</em></strong></p><p>Ask the cash counter who to go to next. You are to submit all the below documents in a the paper file bound with the thread:</p><ol><li>Cash receipts</li><li>Plastic cover with RC card</li><li>Postal cover with address, phone and vehicle number</li><li>NOC + Form 35</li><li>Insurance + Pollution certificate xerox</li></ol><p>This guy will verify your documents, and sign/stamp your application.</p><p><strong><em>Step 3: Officer 2</em></strong></p><p>There will be another officer beside the first one, who will cross check your application and finally give you a small receipt. This receipt is important as you do not have your original RC card now. The new one will reach in few weeks to the address you mentioned on the postal cover.</p><p>That’s it! Your are done! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64da869e520d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>