https://github.com/wlawt/tulip
Creating and making API calls with gRPC and protobuffers.
https://github.com/wlawt/tulip
Last synced: 4 months ago
JSON representation
Creating and making API calls with gRPC and protobuffers.
- Host: GitHub
- URL: https://github.com/wlawt/tulip
- Owner: wlawt
- Created: 2021-04-11T20:54:01.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-04-16T14:46:32.000Z (about 4 years ago)
- Last Synced: 2025-01-08T08:18:16.463Z (5 months ago)
- Language: Go
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Tulip - Golang with gRPC
Creating and making API calls with gRPC and protobuffers.
This project is basically implementing a CRUD API with MongoDB
and Docker.## Requirements
- go 1.14
- protobuf (https://github.com/golang/protobuf)
- gRPC (https://github.com/grpc/grpc-go)
- MongoDB 4.4
- Docker## Running
```go
// Client
go run blog_client/client.go// Server
go run blog_client/server.go
```## Project Structure
```
root/
blog_client/ # All things related to client
blog_server/ # All things related to server
blogpb/ # Protobuf configs
```## What is gRPC
Remote procedure calls (gRPC) uses HTTP2 to make API requests
compared to making RESTful API calls that relies on HTTP1.gRPC also uses protobuffers, which means that data transferred
is done using bytes over HTTP2. Compared to RESTful, which sends
things as JSON, this offers some form of speed advantage for
demanding services.gRPC also creates all the boiler templates needed for the API,
which standardizes a lot of the process, whereas in RESTful, you'd
have to implement the different CRUD functions. gRPC also supports
multiple langauges. My gRPC service in Java can communicate with
my other gRPC service written in Golang, etc.One of the biggest advantages of using protobuffers and gRPC is the
support for streaming. You can have unary, server/client streaming,
and bi-directional streaming. Unary is the simple request and
response call, identical to RESTful calls. Server streaming
establishes requires the client to send one request to the
server and the server can send as _many_ times back to client.
Client streaming utilizes similar logic, except vise versa.
And, bi-directional streaming combines both client and server
streaming.In my opinion, this addresses lots of scalability and network
problems when dealing with millions of requests per second.
For data intensive applications, programs can establish a persistant
connection with the client/server, which will save ultimately
save computation and energy resources.## Improvements
- Add test cases
- Integrate CI testing
- Modularize CRUD functions in [`server.go`](https://github.com/wlawt/go-grpc/blob/master/blog_server/server.go)