<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: André Freitas</title>
    <description>The latest articles on DEV Community by André Freitas (@andrefsilveira1).</description>
    <link>https://dev.to/andrefsilveira1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1592870%2Fcc90220f-597e-4183-8d17-ade0532ad4a9.png</url>
      <title>DEV Community: André Freitas</title>
      <link>https://dev.to/andrefsilveira1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/andrefsilveira1"/>
    <language>en</language>
    <item>
      <title>gRPC Quick start - Coding with streams and bidirectional streaming</title>
      <dc:creator>André Freitas</dc:creator>
      <pubDate>Thu, 13 Jun 2024 23:51:43 +0000</pubDate>
      <link>https://dev.to/andrefsilveira1/grpc-quick-start-coding-with-streams-and-bidirectional-streaming-4dkd</link>
      <guid>https://dev.to/andrefsilveira1/grpc-quick-start-coding-with-streams-and-bidirectional-streaming-4dkd</guid>
      <description>&lt;p&gt;Perhaps you've already heard about gRPC. A few years ago, just the mention of "gRPC" gave me goosebumps. I used to think it was the most complex monster created by the world of microservices. But it's not as scary as I once thought (really far from it).&lt;/p&gt;

&lt;p&gt;Let's see a quick start coding guide using Go, Evans, and gRPC&lt;/p&gt;

&lt;p&gt;Attention!&lt;/p&gt;

&lt;p&gt;This guide step isn't for you if:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You do not know Go&lt;/li&gt;
&lt;li&gt;You're a beginner programmer&lt;/li&gt;
&lt;li&gt;You like Star Wars The Last Jedi&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you do not fit into any of the previous cases, keep going&lt;/p&gt;

&lt;h2&gt;
  
  
  What is gRPC?
&lt;/h2&gt;

&lt;p&gt;In a few words, gRPC is a modern framework created by Google (now maintained by Cloud Native Computing) that implements Remote Procedure Call (RPC) that can run in any environment with high performance. It uses protocol buffers (a simplified XML) through HTTP/2. &lt;/p&gt;

&lt;p&gt;Thus, with gRPC we got binary files smaller than JSON, lower network consumption, and faster data transmission between services.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fktl957bhpmkd8mfuuxsl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fktl957bhpmkd8mfuuxsl.png" alt="This is a chart that explain the communication between microservices using gRPC" width="800" height="318"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Notice that the main concept of gRPC is communication between microservices, not between browsers x backend. &lt;/p&gt;

&lt;p&gt;I recommend that you read the official &lt;a href="https://grpc.io/docs/what-is-grpc/"&gt;gRPC website&lt;/a&gt;. There is a lot of good content and documentation, I'll not be wordy cause already exists better references&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's Start
&lt;/h2&gt;

&lt;p&gt;In this article I'll use Go and Docker. So, You'll have to install the gRPC plugins. Follow up on this tutorial: &lt;a href="https://grpc.io/docs/languages/go/quickstart/"&gt;Tutorial&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But... What will we create? &lt;/p&gt;

&lt;p&gt;Let's suppose antennas spread across a land running a service that calculates and returns the distance in kilometers between the antenna and the client. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcctznw3np0ued4jbza32.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcctznw3np0ued4jbza32.gif" alt="gif illustrating a circle connecting to antennas" width="864" height="864"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then, an object, user, person, extraterrestrial, or anything else wanna contact an antenna to track a register from your moving position using latitude and longitude and receive a response from the antenna (remember that this is an example).&lt;/p&gt;

&lt;p&gt;Now that our domain is set up, in our workspace environment, create a folder called "proto". Here we gonna define the contracts of our gRPC service using proto buffer. &lt;/p&gt;

&lt;p&gt;Create a file called "registers.proto" inside the proto folder. First, we gonna define the settings from proto (using proto3) and then, create an object that will represent our Register object.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;syntax = "proto3";
package pb;
option go_package = "internal/pb";

message Register {
    string id = 1;
    string latitude = 2;
    string longitude = 3;
    string distance = 4;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Those numbers represent only the order they should be sent. With this message contract, we defined that Register must be created with an id, latitude, longitude, and distance attributes.&lt;/p&gt;

&lt;p&gt;With the proto file defined, run: &lt;code&gt;protoc --go_out=. --go-grpc_out=. proto/register.proto&lt;/code&gt;. This command is used to generate Go source files from a Protocol Buffers Documentation &lt;a href="https://protobuf.dev/reference/go/go-generated/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Great! Now we have our base object. But supposing we are the extraterrestrial contact, what should be inside of our request to the antenna? Well, our latitude and longitude, right? &lt;/p&gt;

&lt;p&gt;Thus:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;message CreateRequest {
    string latitude = 1;
    string longitude = 2;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we defined our request. Quite different from REST.&lt;/p&gt;

&lt;p&gt;Finally, let's define the register service on proto&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;service RegisterService {
    rpc CreateRegister(CreateRequest) returns (Register){}

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we define our service &lt;strong&gt;RegisterService&lt;/strong&gt; with the rpc method &lt;code&gt;CreateRegister&lt;/code&gt; receiving a &lt;code&gt;CreateRequest&lt;/code&gt; and returning &lt;code&gt;Register&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Calm down, don't worry, we're almost there!&lt;/p&gt;

&lt;p&gt;create a folder called &lt;code&gt;service&lt;/code&gt; and inside, create &lt;code&gt;registers.go&lt;/code&gt; file. Here, we have to define the register service&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type RegisterService struct {
    pb.UnimplementedRegisterServiceServer
}

func NewRegisterService() *RegisterService {
    return &amp;amp;RegisterService{}
}

var latitude = -5.8623992555733695
var longitude = -35.19111877919574
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As we don't have a database or anything else, let's create just with &lt;code&gt;pb.UnimplementedRegisterServiceServer&lt;/code&gt;. Notice that I defined global variables from latitude and longitude. It will represent the localization from a specific antenna. You're free to decide your latitude and longitude. I decided to set the coordinates from my favorite restaurant :)&lt;/p&gt;

&lt;p&gt;Finally, let's create our server. I'll create a folder &lt;code&gt;cmd&lt;/code&gt; containing another folder called &lt;code&gt;grpc&lt;/code&gt; that contains the &lt;code&gt;main.go&lt;/code&gt; file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

import (
    "andrefsilveira/grpc-quick-start/internal/pb"
    "andrefsilveira/grpc-quick-start/service"
    "fmt"
    "net"

    "google.golang.org/grpc"
    "google.golang.org/grpc/reflection"
)

func main() {

    registerService := service.NewRegisterService()
    grpcServer := grpc.NewServer()
    pb.RegisterRegisterServiceServer(grpcServer, registerService)
    reflection.Register(grpcServer)

    var port = ":50051"
    listen, err := net.Listen("tcp", port)
    if err != nil {
        panic(err)
    }
    fmt.Printf("Server starting on port %s", port)
    if err := grpcServer.Serve(listen); err != nil {
        panic(err)
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At &lt;code&gt;main.go&lt;/code&gt; we are instantiating the register service and also creating a new grpc server. Again, the details are on the documentation. Remember to import all of the necessary packages.&lt;/p&gt;

&lt;p&gt;But, are we forgetting something?&lt;/p&gt;

&lt;p&gt;Yes, we are. Look, we create the proto file, generate the files from proto buffers, and create the connection and the constructors. But, we have to do something with this request. A few months ago I created a go package that calculates the distance between two coordinates and returns the distance in kilometers. You can read about it &lt;a href="https://github.com/andrefsilveira1/go-haversine"&gt;here&lt;/a&gt;. So, let's use it to calculate our distance from an antenna.&lt;/p&gt;

&lt;p&gt;at &lt;code&gt;service/registers.go&lt;/code&gt;, create:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;func (c *RegisterService) CreateRegister(ctx context.Context, in *pb.CreateRequest) (*pb.Register, error) {
    register := &amp;amp;pb.Register{}

    lat, err := strconv.ParseFloat(in.Latitude, 64)
    if err != nil {
        return nil, err
    }

    lon, err := strconv.ParseFloat(in.Longitude, 64)
    if err != nil {
        return nil, err
    }

    result := haversine.Calculate(latitude, longitude, lat, lon)
    value := strconv.FormatFloat(result, 'f', -1, 64)

    register = &amp;amp;pb.Register{
        Id:        uuid.New().String(),
        Latitude:  register.Latitude,
        Longitude: register.Longitude,
        Distance:  value,
    }

    return register, nil

}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, we are receiving the register from &lt;code&gt;input&lt;/code&gt; and parsing to float to finally use it in the haversine package. Then, a &lt;code&gt;Register&lt;/code&gt; is returned.&lt;/p&gt;

&lt;p&gt;Notice that the method name should match the method name declared in the proto file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;service RegisterService {
    rpc CreateRegister(CreateRequest) returns (Register){}

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So far so good, let's do it!&lt;/p&gt;

&lt;p&gt;run: &lt;code&gt;go run cmd/grpc/main.go&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;You should see the &lt;code&gt;Server starting on port :50051&lt;/code&gt; message. To interact with the gRPC server, we will use Evans, which is an interactive command-line client for gRPC. You can read more about it &lt;a href="https://github.com/ktr0731/evans"&gt;here&lt;/a&gt; and can install using docker &lt;code&gt;docker run --rm --network host -it ghcr.io/ktr0731/evans --host localhost --port 50051 --reflection&lt;/code&gt;. This method is not recommended, but in our case, it will be fine. If everything worked correctly, you must see something like this in your terminal:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiswowqz8jb2ryehctxks.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiswowqz8jb2ryehctxks.png" alt="A print from terminal showing up the Evans start" width="800" height="368"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;first, we have to select the package and the service. Remember that we defined at proto file?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;syntax = "proto3";
package pb;
option go_package = "internal/pb";

[...]

service RegisterService {
    rpc CreateRegister(CreateRequest) returns (Register){}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The package is &lt;code&gt;pb&lt;/code&gt;and the service is &lt;code&gt;RegisterService&lt;/code&gt;. Select them using respectively:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;package pb&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;service RegisterService&lt;/code&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, we can call the create register method. Run &lt;code&gt;call CreateRegister&lt;/code&gt; and type any latitude and longitude. If everything works fine, this should be your output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pb.RegisterService@localhost:50051&amp;gt; call CreateRegister
latitude (TYPE_STRING) =&amp;gt; 150
longitude (TYPE_STRING) =&amp;gt; 600
{
  "distance": "10831.805049673263",
  "id": "5421f456-9b77-495e-b358-1184fcc8dc3b"
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But, let's suppose a scenario that we do not have to receive the response after the request. Take the same example, and let be the "tracking" a non vital information. Thus, we could receive the response only when our connection was closed.&lt;/p&gt;

&lt;p&gt;To do this, we gonna create a &lt;code&gt;stream&lt;/code&gt;. Streams allow the client or the server to send multiple requests over a unique connection. But keep calm it is very simple. &lt;/p&gt;

&lt;p&gt;Create another message called &lt;code&gt;Registers&lt;/code&gt;. Notice that it is the same &lt;code&gt;Register&lt;/code&gt; but with the tag &lt;code&gt;repeated&lt;/code&gt;. This means that we are gonna receive a list of &lt;code&gt;Register&lt;/code&gt; messages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;message Registers {
    repeated Register regiters = 1;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, add the method in &lt;code&gt;RegisterService&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;service RegisterService {
    rpc CreateRegister(CreateRequest) returns (Register){}
    rpc CreateRegisterStream(stream CreateRequest) returns (Registers) {}

}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And finally, create the &lt;code&gt;CreateRegisterStream&lt;/code&gt; method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;func (c *RegisterService) CreateRegisterStream(stream pb.RegisterService_CreateRegisterStreamServer) error {
    registers := &amp;amp;pb.Registers{}

    for {
        register, err := stream.Recv()
        if err == io.EOF {
            return stream.SendAndClose(registers)
        }

        if err != nil {
            return err
        }

        lat, err := strconv.ParseFloat(register.Latitude, 64)
        if err != nil {
            return err
        }

        lon, err := strconv.ParseFloat(register.Longitude, 64)
        if err != nil {
            return err
        }

        result := haversine.Calculate(latitude, longitude, lat, lon)
        value := strconv.FormatFloat(result, 'f', -1, 64)

        registers.Registers = append(registers.Registers, &amp;amp;pb.Register{
            Id:        uuid.New().String(),
            Latitude:  register.Latitude,
            Longitude: register.Longitude,
            Distance:  value,
        })

    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that this method is quite different from the previous one. It's opening a stream with &lt;code&gt;register, err := stream.Recv()&lt;/code&gt; and receiving values inside a for loop. This loop will exit only if an error occurs or it reaches the end of file &lt;code&gt;io.EOF&lt;/code&gt;. Great. Save it and restart Evans and your gRPC server. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;package pb&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;service RegisterService&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;call CreateRegisterStream&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Type some coordinates. When you finish, type: &lt;code&gt;cntrl + d&lt;/code&gt;, and you should receive something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pb.RegisterService@localhost:50051&amp;gt; call CreateRegisterStream
latitude (TYPE_STRING) =&amp;gt; 156
longitude (TYPE_STRING) =&amp;gt; 616
latitude (TYPE_STRING) =&amp;gt; 616
longitude (TYPE_STRING) =&amp;gt; 99
latitude (TYPE_STRING) =&amp;gt; 864
longitude (TYPE_STRING) =&amp;gt; 151
latitude (TYPE_STRING) =&amp;gt; 
{
  "registers": [
    {
      "distance": "12422.520903261275",
      "id": "f083993e-2c73-438e-a906-d1b19b26476f",
      "latitude": "156",
      "longitude": "616"
    },
    {
      "distance": "8286.547137287573",
      "id": "8ca6bc74-af0d-4c38-af54-b1f36bbdecf0",
      "latitude": "616",
      "longitude": "99"
    },
    {
      "distance": "4699.522659470381",
      "id": "af354a5f-91df-4573-b5ad-5fb736187942",
      "latitude": "864",
      "longitude": "151"
    }
  ]
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Nice!&lt;/p&gt;

&lt;p&gt;Moreover, let's suppose another case. Assume that now it is necessary a continuous communication between the user and the antenna. Both must keep in touch with each other, and the information should be transmitted through a binary connection &lt;code&gt;client &amp;lt;-&amp;gt; server&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;In this case, we can use bidirectional streams. This type of communication is related to a two-way conversation where both parties can continuously send and receive messages.&lt;/p&gt;

&lt;p&gt;Similarly to the previous method, let's create the &lt;code&gt;CreateRegisterBidirectional&lt;/code&gt; method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;service RegisterService {
    rpc CreateRegister(CreateRequest) returns (Register){}
    rpc CreateRegisterStream(stream CreateRequest) returns (Registers) {}
    rpc CreateRegisterBidirectional(stream CreateRequest) returns (stream Register) {}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that we now put the &lt;code&gt;stream&lt;/code&gt; tag in the return statement too. When it has a &lt;code&gt;stream&lt;/code&gt; at input and output, it defines a bidirectional method. &lt;/p&gt;

&lt;p&gt;Thus, let's create the method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;func (c *RegisterService) CreateRegisterBidirectional(stream pb.RegisterService_CreateRegisterBidirectionalServer) error {
    for {
        register, err := stream.Recv()
        if err == io.EOF {
            return nil
        }
        if err != nil {
            return err
        }

        lat, err := strconv.ParseFloat(register.Latitude, 64)
        if err != nil {
            return err
        }

        lon, err := strconv.ParseFloat(register.Longitude, 64)
        if err != nil {
            return err
        }

        result := haversine.Calculate(latitude, longitude, lat, lon)
        value := strconv.FormatFloat(result, 'f', -1, 64)

        err = stream.Send(&amp;amp;pb.Register{
            Id:        uuid.New().String(),
            Latitude:  register.Latitude,
            Longitude: register.Longitude,
            Distance:  value,
        })

        if err != nil {
            return err
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that looks like with the previous method. But instead send and closing only when the connection close, now we gonna receive and send simultaneously. Restart Evans and the gRPC server again.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;package pb&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;service RegisterService&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;call CreateRegisterBidirectional&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Type how many coordinates you want. The output should look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pb.RegisterService@localhost:50051&amp;gt; call CreateRegisterBidirectional
latitude (TYPE_STRING) =&amp;gt; 161
longitude (TYPE_STRING) =&amp;gt; 66
latitude (TYPE_STRING) =&amp;gt; {
  "distance": "9052.814145827013",
  "id": "197ed428-3a18-4548-888a-9d2ca4930995",
  "latitude": "161",
  "longitude": "66"
}
latitude (TYPE_STRING) =&amp;gt; 6489
longitude (TYPE_STRING) =&amp;gt; 116
latitude (TYPE_STRING) =&amp;gt; {
  "distance": "16820.47617639521",
  "id": "d356e97f-2a1d-491a-b2ef-37e88bfafb59",
  "latitude": "6489",
  "longitude": "116"
}
latitude (TYPE_STRING) =&amp;gt; 616
longitude (TYPE_STRING) =&amp;gt; 888
latitude (TYPE_STRING) =&amp;gt; {
  "distance": "7930.192513515994",
  "id": "ba561afe-3a92-4f19-8a14-9b6c7ae3de26",
  "latitude": "616",
  "longitude": "888"
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice that now we are sending and receiving information at the same time. To stop it, type &lt;code&gt;cntrl + d&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Uff, so this is it. If you have any doubts or recommendations do not hesitate to reach out at: &lt;a href="mailto:freitasandre38@gmail.com"&gt;freitasandre38@gmail.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Also, you can find the source code &lt;a href="https://github.com/andrefsilveira1/grpc-quick-start"&gt;here&lt;/a&gt;&lt;/p&gt;

</description>
      <category>microservices</category>
      <category>grpc</category>
      <category>go</category>
      <category>development</category>
    </item>
  </channel>
</rss>
