Giter VIP home page Giter VIP logo

add-sub-api's Introduction

环境安装

开局第一步,先解决环境问题,本人之前也通过一些标准的文档来安装,但是总会出现消小小的问题

标准安装

  • 1 安装protoc
https://github.com/protocolbuffers/protobuf/releases/tag/v3.14.0
  • 2 安装protoc-gen-go
go get -u github.com/golang/protobuf/protoc-gen-go
  • 3 安装grpc
go get google.golang.org/grpc

通过 go-zero 提供的goctl一键安装

https://go-zero.dev/cn/docs/prepare/protoc-install

参考项目

编码实现

本项目设计的三个项目地址,将这三个项目放到同一层级目录就行,grpc-go-addgrpc-go-sub是server,add-sub-api是client

编写 proto 文件

  • client端的 proto 文件应该直接使用服务方的 proto 文件add.protosub.proto

生成pb文件

protoc --go_out=plugins=grpc:. add.proto
protoc --go_out=plugins=grpc:. sub.proto

编写 grpc service 服务

  • 实现具体的逻辑

编写 grpc client 调用 grpc server

  • 连接 grpc server xx端口

  • 实例化 grpc service client

  • 准备 rpc Request 参数

  • 调用 grpc service 的具体 方法

  • 接收 rpc Response

调用

使用 PostMan 调用

GET http://127.0.0.1:8080/createGrpcAddClient

GET http://127.0.0.1:8080/createGrpcSubClient

TODO

  • 后面有时间的话,计划录一节视频来讲解一下自己的理解
  • 支持 http访问
  • 支持 swagger 文档

add-sub-api's People

Contributors

mohuani avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.