https://github.com/merkez/bookshelf
example gRPC service for demonstrating evans @ mrturkmen.com
https://github.com/merkez/bookshelf
demonstration evans grpc grpc-client grpc-service proto
Last synced: 22 days ago
JSON representation
example gRPC service for demonstrating evans @ mrturkmen.com
- Host: GitHub
- URL: https://github.com/merkez/bookshelf
- Owner: merkez
- License: unlicense
- Created: 2020-08-08T09:20:01.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-04-17T00:57:10.000Z (about 5 years ago)
- Last Synced: 2025-03-20T17:23:09.533Z (about 1 year ago)
- Topics: demonstration, evans, grpc, grpc-client, grpc-service, proto
- Language: Go
- Homepage: https://mrturkmen.com/gRPC-calls-with-evans/
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# BookShelf Example gRPC service
[](https://mrturkmen.com/gRPC-calls-with-evans/)
This repo is created for demonstrating basic usage of [__evans__](https://github.com/ktr0731/evans) on the blog post.
Blog Post : https://mrturkmen.com/gRPC-calls-with-evans/
Evans: https://github.com/ktr0731/evans
- [Proto File](#proto-file)
- [Compiling Proto](#compiling-proto)
- [Running Service](#running-service)
- [Demo](#demo)
## Proto File
```proto
// it is important to declare syntax version
syntax = "proto3";
service BookShelf {
rpc AddBook(AddBookRequest) returns (AddBookResponse) {}
rpc ListBook (ListBooksRequest) returns (ListBooksResponse) {}
rpc DelBook (DelBookRequest) returns (DelBookResponse){}
rpc FindBook (FindBookRequest) returns (FindBookResponse){}
}
message AddBookRequest {
string addedBy = 1;
BookInfo book = 2;
message BookInfo {
string isbn =1;
string name =2;
string author=3;
string addedBy=4;
}
}
message AddBookResponse {
string message = 1;
}
message ListBooksRequest {
// no need to have anything
// could be extended to list books based on category ...
}
message ListBooksResponse {
repeated BookInfo books =1;
message BookInfo {
string isbn =1;
string name =2;
string author=3;
string addedBy=4;
}
}
message DelBookRequest {
string isbn =1;
}
message DelBookResponse {
string message =1;
}
message FindBookRequest {
string isbn =1;
}
message FindBookResponse {
Book book = 1;
message Book {
string isbn =1;
string name =2;
string author=3;
string addedBy=4;
}
}
```
## Compiling proto
```bash
$ protoc -I proto/ proto/bs.proto --go_out=plugins=grpc:proto
```
## Running server
```bash
$ go run server/main.go
```
## Demo
[](http://www.youtube.com/watch?v=GnAUkPUXYCs "BookShelf evans demo")