Skip to main content

Quick Start

Overview

This paper will describe how to quickly develop a rpc server

Sample

Preparation

We do the following execution to generate a proto file and pb file.

# Create demo service directory
$ mkdir demo && cd demo
# go mod initializing
$ go mod init demo
# Generate greet. roto file
$ goctl rpc -o greet.proto
# pun pb.go file
$ protoc greet.proto --go_out=. --go-grpc_out=.
# Create client directory
$ mkdir client && cd client
# Add profile
$ mkdir etc && cd etc
$ touch gret-client. aml
# Add client.go file
$ touch server.go

yaml configuration content and server.go code below

Name: greet.rpc
ListenOn: 127.0.0.1:8080
small trick

If you also find it troublesome to write the code, please try goctl scroll code generated, refer to goctl rpc

More gRPC usage (service register, service discovery, intermediate use etc.) can be consulted rpc service registration

References