-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #844 from berkantay/main
Pebble implementation added.
- Loading branch information
Showing
12 changed files
with
1,190 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name-template: "Pebble - v$RESOLVED_VERSION" | ||
tag-template: "pebble/v$RESOLVED_VERSION" | ||
tag-prefix: pebble/v | ||
include-paths: | ||
- pebble | ||
categories: | ||
- title: "🚀 New" | ||
labels: | ||
- "✏️ Feature" | ||
- title: "🧹 Updates" | ||
labels: | ||
- "🧹 Updates" | ||
- "🤖 Dependencies" | ||
- title: "🐛 Fixes" | ||
labels: | ||
- "☢️ Bug" | ||
- title: "📚 Documentation" | ||
labels: | ||
- "📒 Documentation" | ||
change-template: "- $TITLE (#$NUMBER)" | ||
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks. | ||
version-resolver: | ||
major: | ||
labels: | ||
- "major" | ||
minor: | ||
labels: | ||
- "minor" | ||
- "✏️ Feature" | ||
patch: | ||
labels: | ||
- "patch" | ||
- "📒 Documentation" | ||
- "☢️ Bug" | ||
- "🤖 Dependencies" | ||
- "🧹 Updates" | ||
default: patch | ||
template: | | ||
$CHANGES | ||
**Full Changelog**: https://github.com/$OWNER/$REPOSITORY/compare/$PREVIOUS_TAG...pebble/v$RESOLVED_VERSION | ||
Thank you $CONTRIBUTORS for making this update possible. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Release Drafter Pebble | ||
on: | ||
push: | ||
# branches to consider in the event; optional, defaults to all | ||
branches: | ||
- master | ||
- main | ||
paths: | ||
- "pebble/**" | ||
jobs: | ||
draft_release_pebble: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 30 | ||
steps: | ||
- uses: release-drafter/release-drafter@v5 | ||
with: | ||
config-name: release-drafter-pebble.yml | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
on: | ||
push: | ||
branches: | ||
- master | ||
- main | ||
paths: | ||
- "pebble/**" | ||
pull_request: | ||
paths: | ||
- "pebble/**" | ||
name: "Tests pebble" | ||
jobs: | ||
Tests: | ||
strategy: | ||
matrix: | ||
go-version: | ||
- 1.19.x | ||
- 1.20.x | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: "${{ matrix.go-version }}" | ||
- name: Setup Golang caches | ||
uses: actions/cache@v3 | ||
with: | ||
# In order: | ||
# * Module download cache | ||
# * Build cache (Linux) | ||
# * Build cache (Mac) | ||
# * Build cache (Windows) | ||
path: | | ||
~/go/pkg/mod | ||
~/.cache/go-build | ||
~/Library/Caches/go-build | ||
~\AppData\Local\go-build | ||
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }} | ||
restore-keys: | | ||
${{ runner.os }}-go-${{ matrix.go-version }}- | ||
- name: Fetch Repository | ||
uses: actions/checkout@v3 | ||
- name: Test Pebble | ||
run: cd ./pebble && go test ./... -v -race |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# Pebble | ||
|
||
A fast key-value DB using [cockroachdb/pebble](https://github.com/cockroachdb/pebble) | ||
|
||
### Table of Contents | ||
|
||
- [Signatures](#signatures) | ||
- [Installation](#installation) | ||
- [Examples](#examples) | ||
- [Config](#config) | ||
- [Default Config](#default-config) | ||
|
||
### Signatures | ||
|
||
```go | ||
func New(config ...Config) Storage | ||
func (s *Storage) Get(key string) ([]byte, error) | ||
func (s *Storage) Set(key string, val []byte, exp time.Duration) error | ||
func (s *Storage) Delete(key string) error | ||
func (s *Storage) Reset() error | ||
func (s *Storage) Close() error | ||
func (s *Storage) Conn() *badger.DB | ||
``` | ||
|
||
### Installation | ||
|
||
Pebble is tested on the 2 last [Go versions](https://golang.org/dl/) with support for modules. So make sure to initialize one first if you didn't do that yet: | ||
```bash | ||
go mod init github.com/<user>/<repo> | ||
``` | ||
Note: This step is only required if you don't have an existing module. | ||
|
||
And then install the Pebble implementation: | ||
|
||
```bash | ||
go get github.com/gofiber/storage/pebble | ||
``` | ||
|
||
### Examples | ||
|
||
Import the storage package. | ||
|
||
```go | ||
import "github.com/gofiber/storage/pebble" | ||
``` | ||
|
||
You can use the following possibilities to create a storage: | ||
|
||
```go | ||
// Initialize default config | ||
store := pebble.New() | ||
|
||
// Initialize custom config | ||
store := pebble.New(pebble.Config{ | ||
Path: "db", | ||
WriteOptions: &pebble.WriteOptions{}, | ||
}) | ||
``` | ||
|
||
### Config | ||
|
||
```go | ||
type Config struct { | ||
// Database name | ||
// | ||
// Optional. Default is "./db" | ||
Path string | ||
|
||
// Pass write options during write operations | ||
// | ||
// Optional. Default is nil | ||
WriteOptions &pebble.WriteOptions{} | ||
} | ||
``` | ||
|
||
### Default Config | ||
|
||
```go | ||
var ConfigDefault = Config{ | ||
Path: "db", | ||
WriteOptions: &pebble.WriteOptions{}, | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package pebble | ||
|
||
import "github.com/cockroachdb/pebble" | ||
|
||
type Config struct { | ||
Path string | ||
WriteOptions *pebble.WriteOptions | ||
} | ||
|
||
var ConfigDefault = Config{ | ||
Path: "db", | ||
WriteOptions: &pebble.WriteOptions{}, | ||
} | ||
|
||
func configDefault(config ...Config) Config { | ||
if len(config) < 1 { | ||
return configDefault(config...) | ||
} | ||
cfg := config[0] | ||
if cfg.Path == "" { | ||
cfg.Path = ConfigDefault.Path | ||
} | ||
return cfg | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module github.com/gofiber/storage/pebble | ||
|
||
go 1.19 | ||
|
||
require ( | ||
github.com/cockroachdb/pebble v0.0.0-20230529170040-f235f568816e | ||
github.com/gofiber/utils v1.1.0 | ||
) | ||
|
||
require ( | ||
github.com/DataDog/zstd v1.4.5 // indirect | ||
github.com/beorn7/perks v1.0.1 // indirect | ||
github.com/cespare/xxhash/v2 v2.2.0 // indirect | ||
github.com/cockroachdb/errors v1.8.1 // indirect | ||
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f // indirect | ||
github.com/cockroachdb/redact v1.0.8 // indirect | ||
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/protobuf v1.5.2 // indirect | ||
github.com/golang/snappy v0.0.4 // indirect | ||
github.com/klauspost/compress v1.15.15 // indirect | ||
github.com/kr/pretty v0.2.1 // indirect | ||
github.com/kr/text v0.2.0 // indirect | ||
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/prometheus/client_golang v1.12.0 // indirect | ||
github.com/prometheus/client_model v0.2.1-0.20210607210712-147c58e9608a // indirect | ||
github.com/prometheus/common v0.32.1 // indirect | ||
github.com/prometheus/procfs v0.7.3 // indirect | ||
golang.org/x/exp v0.0.0-20200513190911-00229845015e // indirect | ||
golang.org/x/sys v0.3.0 // indirect | ||
google.golang.org/protobuf v1.27.1 // indirect | ||
) |
Oops, something went wrong.