Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jonathanmdr/grpc
Example of gRPC with Go
https://github.com/jonathanmdr/grpc
go golang grpc grpc-go grpc-server protobuf3 protobuffer protocol-buffers rpc rpc-framework rpc-server
Last synced: about 2 months ago
JSON representation
Example of gRPC with Go
- Host: GitHub
- URL: https://github.com/jonathanmdr/grpc
- Owner: jonathanmdr
- Created: 2022-11-07T19:43:31.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2022-11-08T19:16:08.000Z (about 2 years ago)
- Last Synced: 2024-10-31T23:25:06.452Z (3 months ago)
- Topics: go, golang, grpc, grpc-go, grpc-server, protobuf3, protobuffer, protocol-buffers, rpc, rpc-framework, rpc-server
- Language: Go
- Homepage:
- Size: 37.1 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# gRPC
Example of gRPC with Go## Compiling `.proto` files:
---
> `--go_out` specifies out directory for generation all entities "_messages of `.proto` file_"
>
> `--go-grpc_out` specifies out directory for generation all gRPC code "_services of `.proto` file_"
>
> `latest param` specifies directory for get `.proto` file
```sh
protoc --go_out=. --go-grpc_out=. proto/course_category.proto
```## Installing client gRPC:
---
> The client used for tests is named [evans](https://github.com/ktr0731/evans)
```sh
# MacOS installation using brew
brew tap ktr0731/evans
brew install evans
```## Creating SQLite database:
---
```sh
# For connect on database
sqlite3 db.sqlite
```
```sql
-- For create table categories
create table categories(
id string primary key,
name string,
description string
);-- For create table courses
create table courses(
id string primary key,
name string,
description string,
category_id string,
foreign key (category_id) references categories(id)
);
```## Running server:
---
```sh
go run cmd/grpcServer/main.go
```## Running client:
---
> By default the evans client listens on TCP port 50051, you don't need to specify if you are using this port
```sh
evans -r repl
```## Select gRPC service on client:
---
> Needs to start client before selecting gRPC service
>
> `first param` is the gRPC service name
```sh
# If your function uses stream mode, for stop this use 'Ctrl + D'
service CategoryService
```## Calling gRPC service function on client:
---
> Needs to start client before selecting gRPC service
>
> `first param` is the function name
```sh
call CreateCategory
```