Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simia-tech/boltx
Tools for BoltDB https://github.com/boltdb/bolt
https://github.com/simia-tech/boltx
Last synced: 6 days ago
JSON representation
Tools for BoltDB https://github.com/boltdb/bolt
- Host: GitHub
- URL: https://github.com/simia-tech/boltx
- Owner: simia-tech
- License: mit
- Created: 2016-08-02T14:14:51.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-15T11:21:38.000Z (over 7 years ago)
- Last Synced: 2024-06-20T11:56:08.006Z (5 months ago)
- Language: Go
- Homepage:
- Size: 25.4 KB
- Stars: 1
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# boltx [![Build Status](https://travis-ci.org/simia-tech/boltx.svg?branch=master)](https://travis-ci.org/simia-tech/boltx) [![Coverage Status](https://coveralls.io/repos/github/simia-tech/boltx/badge.svg?branch=master)](https://coveralls.io/github/simia-tech/boltx?branch=master) [![GoDoc](https://godoc.org/github.com/simia-tech/boltx?status.svg)](https://godoc.org/github.com/simia-tech/boltx) [![Go Report Card](https://goreportcard.com/badge/github.com/simia-tech/boltx)](https://goreportcard.com/report/github.com/simia-tech/boltx)
This package contains a collection of tools for [BoltDB](https://github.com/boltdb/bolt). It tries to simplify the
handling of models in a BoltDB bucket without being too opinionated.It's basically assumes that models implement `encoding.BinaryMarshaler` and `encoding.BinaryUnmarshaler` from Go's
standard library.```go
type model struct { ... }func (m *model) MarshalBinary() ([]byte, error) { ... }
func (m *model) UnmarshalBinary([]byte) (error) { ... }
```Those methods should handle the (de)serialization of the model. The interfaces are than used by the functions of
this package to store and load models.```go
model := &model{}boltx.PutModel(bucket, []byte("key"), model)
boltx.GetModel(bucket, []byte("key"), model)
```## Queue
The `Queue` helper implements a queue (single-ended) on a bucket. It's persistent and safe to used with
multiple goroutines.```go
queue := boltx.NewQueue(db, []byte("queue-test"))
queue.EnqueueModel(&model{"item"})model := &model{}
queue.DequeueModel(model)log.Println(model)
```## Deque
The `Deque` helper implements a deque (double-ended queue) on a bucket. It's persistent and safe to use with
multiple goroutines.```go
deque := boltx.NewDeque(db, []byte("deque-test"))go func () {
deque.EnqueueModelBack(&model{"item"})
}()model := &model{}
deque.DequeueModelFront(model)log.Println(model)
```