backend

package
v0.0.0-...-cff1f21 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2023 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Host      string = "127.0.0.1"
	Port      int    = 3100
	Namespace string = "test"
	Set       string = "store"
	ValueBin  string = "value"
	RefBin    string = "ref"
)
View Source
const (
	Id         string = "_id"
	Value      string = "value"
	Reference  string = "ref"
	Database   string = "peer_service"
	Collection string = "peer"
)

Variables

View Source
var OpenFileLimit = 64

Functions

func NewTable

func NewTable(db database.Database, prefix string) database.Database

NewTable returns a Database object that prefixes all keys with a given string.

func NewTableBatch

func NewTableBatch(db database.Database, prefix string) database.Batch

NewTableBatch returns a Batch object which prefixes all keys with a given string.

Types

type AerospikeDatabase

type AerospikeDatabase struct {
	// contains filtered or unexported fields
}

AerospikeDatabase a MongoDB wrapped object.

func NewAerospikeDatabase

func NewAerospikeDatabase() (*AerospikeDatabase, error)

NewAerospikeDatabase returns a AerospikeDatabase wrapped object.

func (*AerospikeDatabase) Close

func (db *AerospikeDatabase) Close()

func (*AerospikeDatabase) CountReference

func (db *AerospikeDatabase) CountReference(key []byte) (int, error)

func (*AerospikeDatabase) Delete

func (db *AerospikeDatabase) Delete(key []byte) error

Delete deletes the key from the database

func (*AerospikeDatabase) Dereference

func (db *AerospikeDatabase) Dereference(key []byte) error

func (*AerospikeDatabase) Get

func (db *AerospikeDatabase) Get(key []byte) ([]byte, error)

Get returns the given key if it's present.

func (*AerospikeDatabase) Has

func (db *AerospikeDatabase) Has(key []byte) (bool, error)

Has checks if the given key is present in the database

func (*AerospikeDatabase) NewBatch

func (db *AerospikeDatabase) NewBatch() database.Batch

func (*AerospikeDatabase) Put

func (db *AerospikeDatabase) Put(key []byte, value []byte) error

Put puts the given key / value to the database

func (*AerospikeDatabase) Reference

func (db *AerospikeDatabase) Reference(key []byte) error

type BadgerDatabase

type BadgerDatabase struct {
	// contains filtered or unexported fields
}

BadgerDatabase a MongoDB (using badger driver) wrapped object.

func NewBadgerDatabase

func NewBadgerDatabase(dirname string) (*BadgerDatabase, error)

NewBadgerDatabase returns a BadgerDB wrapped object.

func (*BadgerDatabase) Close

func (db *BadgerDatabase) Close()

func (*BadgerDatabase) CountReference

func (db *BadgerDatabase) CountReference(key []byte) (int, error)

func (*BadgerDatabase) Delete

func (db *BadgerDatabase) Delete(key []byte) error

Delete deletes the key from the database

func (*BadgerDatabase) Dereference

func (db *BadgerDatabase) Dereference(key []byte) error

func (*BadgerDatabase) Get

func (db *BadgerDatabase) Get(key []byte) ([]byte, error)

Get returns the given key if it's present.

func (*BadgerDatabase) Has

func (db *BadgerDatabase) Has(key []byte) (bool, error)

Has checks if the given key is present in the database

func (*BadgerDatabase) NewBatch

func (db *BadgerDatabase) NewBatch() database.Batch

func (*BadgerDatabase) Put

func (db *BadgerDatabase) Put(key []byte, value []byte) error

Put puts the given key / value to the database

func (*BadgerDatabase) Reference

func (db *BadgerDatabase) Reference(key []byte) error

type Document

type Document struct {
	Key       []byte `bson:"_id" json:"k,omitempty"`
	Value     []byte `bson:"value" json:"v"`
	Reference int    `bson:"ref" json:"ref,omitempty"`
}

type LDBDatabase

type LDBDatabase struct {
	// contains filtered or unexported fields
}

func NewLDBDatabase

func NewLDBDatabase(file string, reffile string, cache int, handles int) (*LDBDatabase, error)

NewLDBDatabase returns a LevelDB wrapped object.

func (*LDBDatabase) Close

func (db *LDBDatabase) Close()

func (*LDBDatabase) CountReference

func (db *LDBDatabase) CountReference(key []byte) (int, error)

func (*LDBDatabase) Delete

func (db *LDBDatabase) Delete(key []byte) error

Delete deletes the key from the queue and database

func (*LDBDatabase) Dereference

func (db *LDBDatabase) Dereference(key []byte) error

func (*LDBDatabase) Get

func (db *LDBDatabase) Get(key []byte) ([]byte, error)

Get returns the given key if it's present.

func (*LDBDatabase) Has

func (db *LDBDatabase) Has(key []byte) (bool, error)

func (*LDBDatabase) LDB

func (db *LDBDatabase) LDB() *leveldb.DB

func (*LDBDatabase) Meter

func (db *LDBDatabase) Meter(prefix string)

Meter configures the database metrics collectors and

func (*LDBDatabase) NewBatch

func (db *LDBDatabase) NewBatch() database.Batch

func (*LDBDatabase) NewIterator

func (db *LDBDatabase) NewIterator() iterator.Iterator

func (*LDBDatabase) NewIteratorWithPrefix

func (db *LDBDatabase) NewIteratorWithPrefix(prefix []byte) iterator.Iterator

NewIteratorWithPrefix returns a iterator to iterate over subset of database content with a particular prefix.

func (*LDBDatabase) Path

func (db *LDBDatabase) Path() string

Path returns the path to the database directory.

func (*LDBDatabase) Put

func (db *LDBDatabase) Put(key []byte, value []byte) error

Put puts the given key / value to the queue

func (*LDBDatabase) Reference

func (db *LDBDatabase) Reference(key []byte) error

type MemDatabase

type MemDatabase struct {
	// contains filtered or unexported fields
}

* This is a test memory database. Do not use for any production it does not get persisted

func NewMemDatabase

func NewMemDatabase() *MemDatabase

func NewMemDatabaseWithCap

func NewMemDatabaseWithCap(size int) *MemDatabase

func (*MemDatabase) Close

func (db *MemDatabase) Close()

func (*MemDatabase) CountReference

func (db *MemDatabase) CountReference(key []byte) (int, error)

func (*MemDatabase) Delete

func (db *MemDatabase) Delete(key []byte) error

func (*MemDatabase) Dereference

func (db *MemDatabase) Dereference(key []byte) error

func (*MemDatabase) Get

func (db *MemDatabase) Get(key []byte) ([]byte, error)

func (*MemDatabase) Has

func (db *MemDatabase) Has(key []byte) (bool, error)

func (*MemDatabase) Keys

func (db *MemDatabase) Keys() [][]byte

func (*MemDatabase) Len

func (db *MemDatabase) Len() int

func (*MemDatabase) NewBatch

func (db *MemDatabase) NewBatch() database.Batch

func (*MemDatabase) Put

func (db *MemDatabase) Put(key []byte, value []byte) error

func (*MemDatabase) Reference

func (db *MemDatabase) Reference(key []byte) error

type MgoDatabase

type MgoDatabase struct {
	// contains filtered or unexported fields
}

MgoDatabase a MongoDB (using mgo driver) wrapped object.

func NewMgoDatabase

func NewMgoDatabase() (*MgoDatabase, error)

NewMgoDatabase returns a MongoDB (using mgo driver) wrapped object.

func (*MgoDatabase) Close

func (db *MgoDatabase) Close()

func (*MgoDatabase) CountReference

func (db *MgoDatabase) CountReference(key []byte) (int, error)

func (*MgoDatabase) Delete

func (db *MgoDatabase) Delete(key []byte) error

Delete deletes the key from the database

func (*MgoDatabase) Dereference

func (db *MgoDatabase) Dereference(key []byte) error

func (*MgoDatabase) Get

func (db *MgoDatabase) Get(key []byte) ([]byte, error)

Get returns the given key if it's present.

func (*MgoDatabase) Has

func (db *MgoDatabase) Has(key []byte) (bool, error)

Has checks if the given key is present in the database

func (*MgoDatabase) NewBatch

func (db *MgoDatabase) NewBatch() database.Batch

func (*MgoDatabase) Put

func (db *MgoDatabase) Put(key []byte, value []byte) error

Put puts the given key / value to the database

func (*MgoDatabase) Reference

func (db *MgoDatabase) Reference(key []byte) error

type MongoDatabase

type MongoDatabase struct {
	// contains filtered or unexported fields
}

MongoDatabase a MongoDB wrapped object.

func NewMongoDatabase

func NewMongoDatabase() (*MongoDatabase, error)

NewMongoDatabase returns a MongoDB wrapped object.

func (*MongoDatabase) Close

func (db *MongoDatabase) Close()

func (*MongoDatabase) CountReference

func (db *MongoDatabase) CountReference(key []byte) (int, error)

func (*MongoDatabase) Delete

func (db *MongoDatabase) Delete(key []byte) error

Delete deletes the key from the database

func (*MongoDatabase) Dereference

func (db *MongoDatabase) Dereference(key []byte) error

func (*MongoDatabase) Get

func (db *MongoDatabase) Get(key []byte) ([]byte, error)

Get returns the given key if it's present.

func (*MongoDatabase) Has

func (db *MongoDatabase) Has(key []byte) (bool, error)

Has checks if the given key is present in the database

func (*MongoDatabase) NewBatch

func (db *MongoDatabase) NewBatch() database.Batch

func (*MongoDatabase) Put

func (db *MongoDatabase) Put(key []byte, value []byte) error

Put puts the given key / value to the database

func (*MongoDatabase) Reference

func (db *MongoDatabase) Reference(key []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL