https://github.com/shiponcs/bookstore-grpc
A gRPC based BookStore server that does some basic operations
https://github.com/shiponcs/bookstore-grpc
grpc grpc-server grpcurl protobuf protobuf3
Last synced: 24 days ago
JSON representation
A gRPC based BookStore server that does some basic operations
- Host: GitHub
- URL: https://github.com/shiponcs/bookstore-grpc
- Owner: shiponcs
- Created: 2023-06-15T06:54:37.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-20T09:26:51.000Z (almost 3 years ago)
- Last Synced: 2025-05-21T17:42:44.015Z (12 months ago)
- Topics: grpc, grpc-server, grpcurl, protobuf, protobuf3
- Language: C++
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# BookStore-gRPC
A BookStore API server in written in gRPC
#### Build using Cmake
After cloning the repo, from root directory of it run:
```bash
$ mkdir -p build
$ cd build
$ cmake ..
$ make
# run
$ ./server
```
#### Use Docker Image
```bash
$ docker pull ghcr.io/shiponcs/bookstore-grpc:1.0
$ docker run -p 50051:50051 ghcr.io/shiponcs/bookstore-grpc:1.0
```
#### Test
We use `grpcurl` to test it.
##### Create(POST) a book
```bash
$ grpcurl -plaintext -d '{"name": "fitzgerald", "author": "gatsby"}' localhost:50051 bookstore.BookStore.PostBook
{
"msg": "Book created with id: 2106477622"
}
$
```
##### Get the list of all books
```bash
$ grpcurl -plaintext localhost:50051 bookstore.BookStore.GetAllBooks
{
"id": 94352545,
"name": "fitzgerald",
"author": "gatsby"
}
{
"id": 1029625494,
"name": "fitzgerald",
"author": "gatsby"
}
{
"id": 1495894131,
"name": "fitzgerald",
"author": "gatsby"
}
$
```
##### Get a book
```bash
$ grpcurl -plaintext -d '{"id": 1029625494}' localhost:50051 bookstore.BookStore.GetABookById
{
"id": 1029625494,
"name": "fitzgerald",
"author": "gatsbees"
}
$
```
##### Delete a book
```bash
$ grpcurl -plaintext -d '{"id": 877404536}' localhost:50051 bookstore.BookStore.DeleteABook
ERROR:
Code: NotFound
Message: No book entry found for this id
user@matin ~/o/g/e/c/BookStore-gRPC (main) [69]>
user@matin ~/o/g/e/c/BookStore-gRPC (main) [69]> grpcurl -plaintext -d '{"id": 94352545}' localhost:50051 bookstore.BookStore.DeleteABook
{
}
$
```
##### Update a Book
```bash
$ grpcurl -plaintext -d '{"id": 877404536, "name": "fitzgerald", "author": "gatsbees"}' localhost:50051 bookstore.BookStore.UpdateABook
ERROR:
Code: NotFound
Message: No book entry found for this id
user@matin ~/o/g/e/c/BookStore-gRPC (main) [69]>
$ grpcurl -plaintext -d '{"id": 1029625494, "name": "fitzgerald", "author": "gatsbees"}' localhost:50051 bookstore.BookStore.UpdateABook
{
"id": 1029625494,
"name": "fitzgerald",
"author": "gatsbees"
}
$
```