Google GRPC Preliminary interview

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

GRPC is a high-performance, general-purpose, open-source RPC framework developed by Google primarily for mobile applications and based on the HTTP/2 protocol standards, developed based on the Protobuf (protocolbuffers) serialization protocol, and supports many development languages. GRPC provides an easy way to precisely define services and automatically generate a highly reliable client function library for iOS, Android, and background support services. Clients take advantage of advanced streaming and linking capabilities to help conserve bandwidth, reduce the number of TCP links, conserve CPU usage, and battery life.

            1 Installation
           go get Google.golang.org/grpc
  
 2 Create Helloworld.proto
      syntax = "Proto3";
  
      option java_package = "Io.grpc.examples";
  
      package HelloWorld;
  
      //the Greeting service definition.
      service Greeter {
        //sends a Greeting
        rpc SayHello (hellorequest) returns (Helloreply) {}
       }

The request message containing the user ' s name.
Message Hellorequest {
string name = 1;
}

The response message containing the greetings
Message helloreply {
String message = 1;
}
3. Installing PROTOC
Download the Protoc tool:
Https://github.com/google/protobuf, has the source code and compiles well, chooses by oneself
To install the Go plugin:
Go get-a github.com/golang/protobuf/protoc-gen-go
4. Generate the Golang file
Protoc-i././helloworld.proto--go_out=plugins=grpc:helloworld

5. Obtain the Instance code:
$ go get-u github.com/grpc/grpc-common/go/greeter_client
$ go get-u github.com/grpc/grpc-common/go/greeter_server

6. Running
Service side:
$ Greeter_server &
Client:
$ greeter_client

Interested, can discuss together!!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.