Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elan8/propanedb
A document database for Protocol Buffer messages with GRPC interface
https://github.com/elan8/propanedb
database grpc protobuf protocol-buffers
Last synced: 3 months ago
JSON representation
A document database for Protocol Buffer messages with GRPC interface
- Host: GitHub
- URL: https://github.com/elan8/propanedb
- Owner: elan8
- Created: 2021-06-17T17:58:32.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-02-06T16:56:39.000Z (almost 3 years ago)
- Last Synced: 2024-04-18T16:58:01.171Z (7 months ago)
- Topics: database, grpc, protobuf, protocol-buffers
- Language: C++
- Homepage: https://www.propanedb.com
- Size: 429 KB
- Stars: 11
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-grpc - PropaneDB - A Protocol Buffers database with gRPC API and Golang driver. (Tools / Other)
README
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/f8495be580014d2d873e820ed36835e0)](https://www.codacy.com/gh/elan8/propanedb/dashboard?utm_source=github.com&utm_medium=referral&utm_content=elan8/propanedb&utm_campaign=Badge_Grade)
# PropaneDB
A document database for Protocol Buffer messages with GRPC interfaceIdeal for GRPC microservices:
- Use the messages defined in the proto file both for communication and storage: single source of truth
- Can be used with any programming language that is supported by GRPCFeatures:
- Store Protobuf objects in serialized form (google.protobuf.Any) in a database
- Retrieve those objects using their UUID
- Delete objects based on their UUID
- Search function based on the fields of the Protobuf objects
- Support multiple databases per instance
- Backup and restore functionality## Getting started
In order to use PropaneDB with your application, you can use the Golang driver.
1. First define your messages and RPC's in a .proto file and generate GRPC code and a Descriptor file:
```
protoc --go_out=:. --go-grpc_out=:. --descriptor_set_out=./propane/test.bin -I. ./api/test.proto
```
2. Open a terminal and use the following command to start an instance of PropaneDB
```
docker run -p=50051:50051 ghcr.io/elan8/propanedb:latest
```
3. First import the driver in your Go app and other dependencies (assuming you are using Go modules)
```
import (
"context"
"log"
"io/ioutil""github.com/elan8/propanedb-go-driver/propane"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/descriptorpb"
)
```
4. Connect to PropaneDB and create a database
```
databaseName := "test"
ctx := context.Background()
port := "50051"b, err := ioutil.ReadFile("../propane/test.bin")
if err != nil {
log.Fatalf("Error: %s", err)
}fds := &descriptorpb.FileDescriptorSet{}
proto.Unmarshal(b, fds)client, err := propane.Connect(ctx, "localhost:"+port)
if err != nil {
log.Fatalf("Error: %s", err)
}
err = client.CreateDatabase(ctx, databaseName, fds)
if err != nil {
log.Printf("Error: %s", err)
}
```
5. Instantiate a Protobuf message (=struct in Go) that you previously defined in your .proto file and store it in the database:
```
item1 := &propane.TestEntity{}
item1.Description = "Test 1"
id1, err := client.Put(ctx, item1)
if err != nil {
log.Fatalf("Error: %s", err)
}
log.Print("Id1=" + id1)
```## Related projects
- [Golang driver](https://github.com/elan8/propanedb-go-driver)
- [Demo](https://github.com/elan8/propanedb-demo)## Implementation
- Storage engine is RocksDB.
- Interface is based on GRPC
- Deployment using Docker containers