Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rulanugrh/saturnus

Templates and Examples implementation about HTTP Transcoding to GRPC Golang with MongoDB
https://github.com/rulanugrh/saturnus

grpc grpc-go http-server http-transcoding mongodb-go todolist

Last synced: 3 days ago
JSON representation

Templates and Examples implementation about HTTP Transcoding to GRPC Golang with MongoDB

Awesome Lists containing this project

README

        

SATURNUS


## Description
Example and Template about Transcoding HTTP to GRPC with Golang and Mongodb. Fyi, GRPC is modern open source high performance Remote Procedure (RPC) framework that can run in any environtment. It can efficiently connect services in and across data centers with pluggable support for load balancing, tracing, health checking and authentication. It is also applicable in last mile of distributed computing to connect devices, mobile applications and browsers to backend services. gRPC is based from protocol buffer which is an input schema that will be carried out by the client or user.

In this project, I provide examples or templates about http to gRPC transcoding. Actually, gRPC itself is based on HTTP v2 but is not published. So, Google Cloud Endpoint itself supports transcoding http to grpc, more or less the schema is like this.



## Endpoint
- GRPC


Endpoint
Description
Method


TodoService/CreateProduct
To create todo
POST


TodoService/FindById
To get todo by id
GET


TodoService/Update
To update todo by id
PUT


TodoService/Delete
To delete todo by id
DELETE


TodoService/FindAll
To sell all todo
GET

- REST


Endpoint
Description
Method


/v1/todo
To create todo
POST


/v1/todo/{id}
To get todo by id
GET


/v1/todo/{id}
To update todo by id
PUT


/v1/todo/{id}
To delete todo by id
DELETE


/v1/todo
To sell all todo
GET

## Usage
### 1.1 Usage with Golang
Run this command to running download all module
```go
go mod tidy
```
then running file `server.go` to run the server
```go
go run server.go
```
and the output will be like this
```
2023/08/08 14:26:20 GRPC Server running on localhost:40000
2023/08/08 14:26:20 HTTP Server running on localhost:8080
```

### 1.2 Usage with Docker
Run this command to download docker-compose (this command for linux)
```bash
sudo apt install docker-compose -y
```
then running this command
```
docker-compose up -d
```
and service will be running on port `40000 to GRPC` and `8080 to REST`

> For example schema to input in GRPC you can see in [`example`](https://github.com/rulanugrh/saturnus/tree/master/example) folder