Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,31 @@ jobs:
with:
go-version: '1.23'

- name: Install RocksDB dependencies
run: sudo apt-get update && sudo apt-get install -y libsnappy-dev

- name: Cache RocksDB
id: cache-rocksdb
uses: actions/cache@v3
with:
path: /tmp/rocksdb
key: rocksdb-portable-10.5.1

- name: Build RocksDB
if: steps.cache-rocksdb.outputs.cache-hit != 'true'
run: |
cd /tmp
git clone --depth 1 --branch v10.5.1 https://github.com/facebook/rocksdb.git
cd rocksdb
PORTABLE=1 make static_lib -j$(nproc)

- name: Install RocksDB
run: |
cd /tmp/rocksdb
sudo make install-static

- name: Build
run: go build -v ./...
run: CGO_ENABLED=1 go build -v ./...

- name: Test
run: go test -v ./...
run: CGO_ENABLED=1 go test -v ./...
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,42 @@ Package config provides an easy way to create and manage configurations for aerg

## db

Package db is an wrapper of database implementations. Currently, this supports [badgerdb](https://github.com/dgraph-io/badger).
More implementations (e.g. leveldb) will be updated in the future
Package db is a wrapper of database implementations. Currently, this supports:
- [BadgerDB](https://github.com/dgraph-io/badger)
- [LevelDB](https://github.com/syndtr/goleveldb)
- [RocksDB](https://rocksdb.org/)

### RocksDB Requirements

RocksDB requires CGO and the RocksDB C++ library to be installed on your system.

**Ubuntu/Debian:**
```bash
sudo apt-get update
sudo apt-get install -y librocksdb-dev
```

**Alpine Linux:**
```bash
apk add --no-cache rocksdb-dev build-base
```

**RedHat/CentOS/Fedora:**
```bash
sudo yum install -y rocksdb-devel
# or on newer versions
sudo dnf install -y rocksdb-devel
```

**macOS:**
```bash
brew install rocksdb
```

**Building with RocksDB:**
```bash
CGO_ENABLED=1 go build ./...
```

## log

Expand Down
9 changes: 9 additions & 0 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ func registerDBConstructor(dbimpl ImplType, constructor dbConstructor) {
dbImpls[dbimpl] = constructor
}

// GetRegisteredImpls returns the list of registered database implementations
func GetRegisteredImpls() []ImplType {
var impls []ImplType
for impl := range dbImpls {
impls = append(impls, impl)
}
return impls
}

// NewDB creates new database or load existing database in the directory
func NewDB(dbimpltype ImplType, dir string, options ...Option) DB {
// The default wrapper need 3 frames and badger wrapper need 1 frame to show actual stack trace.
Expand Down
Loading