Documentation ¶
Index ¶
- func EncodeWriteTask(task *WriteTask) []byte
- func NewDBDeque(db Database, readFront bool) *dbDeque
- type Batch
- type Database
- type DatabaseBatcher
- type DatabaseDeleter
- type DatabaseDispatcher
- type DatabaseGetter
- type DatabaseGroup
- type DatabasePatch
- func (p *DatabasePatch) Apply() error
- func (p *DatabasePatch) BranchId() string
- func (p *DatabasePatch) Delete(key []byte) error
- func (p *DatabasePatch) DeleteBatch(b iservices.IDatabaseBatch)
- func (p *DatabasePatch) Get(key []byte) ([]byte, error)
- func (p *DatabasePatch) Has(key []byte) (bool, error)
- func (p *DatabasePatch) Iterate(start, limit []byte, reverse bool, callback func(key, value []byte) bool)
- func (p *DatabasePatch) NewBatch() iservices.IDatabaseBatch
- func (p *DatabasePatch) NewPatch(branchId ...string) iservices.IDatabasePatch
- func (p *DatabasePatch) Put(key []byte, value []byte) error
- func (p *DatabasePatch) ServiceId() uint32
- type DatabasePutter
- type DatabaseScanner
- type DatabaseService
- func (s *DatabaseService) BeginTransaction()
- func (s *DatabaseService) BeginTransactionWithTag(tag string)
- func (s *DatabaseService) BranchId() string
- func (s *DatabaseService) Close()
- func (s *DatabaseService) Delete(key []byte) error
- func (s *DatabaseService) DeleteAll() error
- func (s *DatabaseService) DeleteBatch(b iservices.IDatabaseBatch)
- func (s *DatabaseService) EnableReversion(b bool) error
- func (s *DatabaseService) EndTransaction(commit bool) error
- func (s *DatabaseService) Get(key []byte) ([]byte, error)
- func (s *DatabaseService) GetRevision() uint64
- func (s *DatabaseService) GetRevisionAndBase() (current uint64, base uint64)
- func (s *DatabaseService) GetRevisionTag(r uint64) string
- func (s *DatabaseService) GetTagRevision(tag string) (uint64, error)
- func (s *DatabaseService) Has(key []byte) (bool, error)
- func (s *DatabaseService) HashOfTopTransaction() uint32
- func (s *DatabaseService) Iterate(start, limit []byte, reverse bool, callback func(key, value []byte) bool)
- func (s *DatabaseService) Lock()
- func (s *DatabaseService) NewBatch() iservices.IDatabaseBatch
- func (s *DatabaseService) NewPatch(branchId ...string) iservices.IDatabasePatch
- func (s *DatabaseService) Put(key []byte, value []byte) error
- func (s *DatabaseService) RLock()
- func (s *DatabaseService) RUnlock()
- func (s *DatabaseService) RebaseToRevision(r uint64) error
- func (s *DatabaseService) RebaseToTag(tag string) error
- func (s *DatabaseService) ReversionEnabled() bool
- func (s *DatabaseService) RevertToRevision(r uint64) error
- func (s *DatabaseService) RevertToTag(tag string) error
- func (s *DatabaseService) RollbackTag(tag string) error
- func (s *DatabaseService) ServiceId() uint32
- func (s *DatabaseService) Squash(tag string) error
- func (s *DatabaseService) Start(node *node.Node) error
- func (s *DatabaseService) Stop() error
- func (s *DatabaseService) TagRevision(r uint64, tag string) error
- func (s *DatabaseService) TransactionHeight() uint
- func (s *DatabaseService) Unlock()
- type DatabaseWriter
- type GuardedDatabaseService
- type KeyHashDispatcher
- type LevelDatabase
- func (db *LevelDatabase) Close()
- func (db *LevelDatabase) Delete(key []byte) error
- func (db *LevelDatabase) DeleteBatch(b Batch)
- func (db *LevelDatabase) FileName() string
- func (db *LevelDatabase) Get(key []byte) ([]byte, error)
- func (db *LevelDatabase) Has(key []byte) (bool, error)
- func (db *LevelDatabase) Iterate(start, limit []byte, reverse bool, callback func(key, value []byte) bool)
- func (db *LevelDatabase) NewBatch() Batch
- func (db *LevelDatabase) Put(key []byte, value []byte) error
- type LevelDatabaseBatch
- type LevelWriteAheadLog
- func (wal *LevelWriteAheadLog) Close()
- func (wal *LevelWriteAheadLog) DeleteTask(taskId uint64) error
- func (wal *LevelWriteAheadLog) DeleteTasks(taskIds []uint64) error
- func (wal *LevelWriteAheadLog) GetTask(taskId uint64) (*WriteTask, error)
- func (wal *LevelWriteAheadLog) GetTasks() ([]*WriteTask, error)
- func (wal *LevelWriteAheadLog) NewTaskID() uint64
- func (wal *LevelWriteAheadLog) PutTask(task *WriteTask) error
- func (wal *LevelWriteAheadLog) PutTasks(tasks []*WriteTask) error
- type RedblackDatabase
- func (db *RedblackDatabase) Close()
- func (db *RedblackDatabase) Delete(key []byte) error
- func (db *RedblackDatabase) DeleteBatch(b Batch)
- func (db *RedblackDatabase) Get(key []byte) ([]byte, error)
- func (db *RedblackDatabase) Has(key []byte) (bool, error)
- func (db *RedblackDatabase) Iterate(start, limit []byte, reverse bool, callback func(key, value []byte) bool)
- func (db *RedblackDatabase) NewBatch() Batch
- func (db *RedblackDatabase) Put(key []byte, value []byte) error
- type RevDatabase
- type Revertible
- type RevertibleDatabase
- func (db *RevertibleDatabase) Close()
- func (db *RevertibleDatabase) Delete(key []byte) error
- func (db *RevertibleDatabase) DeleteBatch(b Batch)
- func (db *RevertibleDatabase) EnableReversion(b bool) error
- func (db *RevertibleDatabase) Get(key []byte) ([]byte, error)
- func (db *RevertibleDatabase) GetRevision() uint64
- func (db *RevertibleDatabase) GetRevisionAndBase() (current uint64, base uint64)
- func (db *RevertibleDatabase) GetRevisionTag(r uint64) string
- func (db *RevertibleDatabase) GetTagRevision(tag string) (uint64, error)
- func (db *RevertibleDatabase) Has(key []byte) (bool, error)
- func (db *RevertibleDatabase) Iterate(start, limit []byte, reverse bool, callback func(key, value []byte) bool)
- func (db *RevertibleDatabase) NewBatch() Batch
- func (db *RevertibleDatabase) PresetTag(tag string)
- func (db *RevertibleDatabase) Put(key []byte, value []byte) error
- func (db *RevertibleDatabase) RebaseToRevision(r uint64) error
- func (db *RevertibleDatabase) RebaseToTag(tag string) error
- func (db *RevertibleDatabase) ReversionEnabled() bool
- func (db *RevertibleDatabase) RevertToRevision(r uint64) error
- func (db *RevertibleDatabase) RevertToTag(tag string) error
- func (db *RevertibleDatabase) TagRevision(r uint64, tag string) (err error)
- type SimpleDatabaseGroup
- func (g *SimpleDatabaseGroup) Close()
- func (g *SimpleDatabaseGroup) Crashed() bool
- func (g *SimpleDatabaseGroup) Delete(key []byte) error
- func (g *SimpleDatabaseGroup) DeleteBatch(b Batch)
- func (g *SimpleDatabaseGroup) Get(key []byte) ([]byte, error)
- func (g *SimpleDatabaseGroup) Has(key []byte) (bool, error)
- func (g *SimpleDatabaseGroup) Iterate(start, limit []byte, reverse bool, callback func(key, value []byte) bool)
- func (g *SimpleDatabaseGroup) NewBatch() Batch
- func (g *SimpleDatabaseGroup) Put(key []byte, value []byte) error
- type SquashDatabase
- type Squashable
- type SquashableDatabase
- func (db *SquashableDatabase) BeginTransaction()
- func (db *SquashableDatabase) BeginTransactionWithTag(tag string)
- func (dq *SquashableDatabase) Close()
- func (dq *SquashableDatabase) Delete(key []byte) error
- func (dq *SquashableDatabase) DeleteBatch(b Batch)
- func (db *SquashableDatabase) EndTransaction(commit bool) error
- func (dq *SquashableDatabase) Get(key []byte) ([]byte, error)
- func (dq *SquashableDatabase) Has(key []byte) (bool, error)
- func (dq *SquashableDatabase) HashOfTopSession() (hash uint32)
- func (dq *SquashableDatabase) Iterate(start, limit []byte, reverse bool, callback func(key, value []byte) bool)
- func (dq *SquashableDatabase) NewBatch() Batch
- func (dq *SquashableDatabase) PopBack(commit bool) error
- func (dq *SquashableDatabase) PopBackN(n int, commit bool) error
- func (dq *SquashableDatabase) PopFront(commit bool) error
- func (dq *SquashableDatabase) PushBack()
- func (dq *SquashableDatabase) PushFront()
- func (dq *SquashableDatabase) Put(key []byte, value []byte) error
- func (db *SquashableDatabase) RollbackTag(tag string) error
- func (dq *SquashableDatabase) Size() uint
- func (db *SquashableDatabase) Squash(tag string) error
- type TagRevDatabase
- type TagRevertible
- type Transactional
- type TransactionalDatabase
- func (db *TransactionalDatabase) BeginTransaction()
- func (dq *TransactionalDatabase) Close()
- func (dq *TransactionalDatabase) Delete(key []byte) error
- func (dq *TransactionalDatabase) DeleteBatch(b Batch)
- func (db *TransactionalDatabase) EndTransaction(commit bool) error
- func (dq *TransactionalDatabase) Get(key []byte) ([]byte, error)
- func (dq *TransactionalDatabase) Has(key []byte) (bool, error)
- func (dq *TransactionalDatabase) HashOfTopSession() (hash uint32)
- func (db *TransactionalDatabase) HashOfTopTransaction() uint32
- func (dq *TransactionalDatabase) Iterate(start, limit []byte, reverse bool, callback func(key, value []byte) bool)
- func (dq *TransactionalDatabase) NewBatch() Batch
- func (dq *TransactionalDatabase) PopBack(commit bool) error
- func (dq *TransactionalDatabase) PopBackN(n int, commit bool) error
- func (dq *TransactionalDatabase) PopFront(commit bool) error
- func (dq *TransactionalDatabase) PushBack()
- func (dq *TransactionalDatabase) PushFront()
- func (dq *TransactionalDatabase) Put(key []byte, value []byte) error
- func (dq *TransactionalDatabase) Size() uint
- func (db *TransactionalDatabase) TransactionHeight() uint
- type TrxDatabase
- type WriteAheadLog
- type WriteTask
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeWriteTask ¶
func NewDBDeque ¶ added in v1.0.2
Types ¶
type Batch ¶
type Batch interface { DatabaseWriter // execute all batched operations Write() error // reset the batch to empty Reset() }
interface for transaction executor methods must be thread safe write operations must be executed atomically
type Database ¶
type Database interface { DatabaseGetter DatabasePutter DatabaseDeleter DatabaseScanner DatabaseBatcher Close() }
interface for full functional database methods must be thread safe
func NewMemoryDatabase ¶
func NewMemoryDatabase() Database
type DatabaseBatcher ¶
type DatabaseBatcher interface { // create a batch which can pack DatabasePutter & DatabaseDeleter operations and execute them atomically NewBatch() Batch // release a Batch DeleteBatch(b Batch) }
interface for transactional execution of multiple writes methods must be thread safe
type DatabaseDeleter ¶
type DatabaseDeleter interface { // delete the given key and its value // if the given key does not exist, just return nil, indicating a successful deletion without doing anything. Delete(key []byte) error }
interface for deletion methods must be thread safe
type DatabaseDispatcher ¶
type DatabaseDispatcher interface { // return members of database group. // members must be fixed once the DatabaseDispatcher object is created MemberDatabases() []Database // return the index number of the mapped member database DatabaseForKey(key []byte) int // return databases who possibly contains keys from given range DatabasesForKeyRange(start []byte, limit []byte) []int }
interface for key->database mapping policy for a group of databases
type DatabaseGetter ¶
type DatabaseGetter interface { // check existence of the given key Has(key []byte) (bool, error) // query the value of the given key Get(key []byte) ([]byte, error) }
interface for key & value query methods must be thread safe
type DatabaseGroup ¶
type DatabaseGroup interface { DatabaseDispatcher Database }
interface for a logical database consisting of a group of databases
type DatabasePatch ¶ added in v1.0.2
type DatabasePatch struct {
// contains filtered or unexported fields
}
func NewDatabasePatch ¶ added in v1.0.2
func NewDatabasePatch(serviceId uint32, branchId string, db Database) *DatabasePatch
func (*DatabasePatch) Apply ¶ added in v1.0.2
func (p *DatabasePatch) Apply() error
func (*DatabasePatch) BranchId ¶ added in v1.0.2
func (p *DatabasePatch) BranchId() string
func (*DatabasePatch) Delete ¶ added in v1.0.2
func (p *DatabasePatch) Delete(key []byte) error
func (*DatabasePatch) DeleteBatch ¶ added in v1.0.2
func (p *DatabasePatch) DeleteBatch(b iservices.IDatabaseBatch)
func (*DatabasePatch) Iterate ¶ added in v1.0.2
func (p *DatabasePatch) Iterate(start, limit []byte, reverse bool, callback func(key, value []byte) bool)
func (*DatabasePatch) NewBatch ¶ added in v1.0.2
func (p *DatabasePatch) NewBatch() iservices.IDatabaseBatch
func (*DatabasePatch) NewPatch ¶ added in v1.0.2
func (p *DatabasePatch) NewPatch(branchId ...string) iservices.IDatabasePatch
func (*DatabasePatch) Put ¶ added in v1.0.2
func (p *DatabasePatch) Put(key []byte, value []byte) error
func (*DatabasePatch) ServiceId ¶ added in v1.0.2
func (p *DatabasePatch) ServiceId() uint32
type DatabasePutter ¶
type DatabasePutter interface { // insert a new key-value pair, or update the value if the given key already exists Put(key []byte, value []byte) error }
interface for insertion and updating methods must be thread safe
type DatabaseScanner ¶
type DatabaseScanner interface { // Iterate enumerates keys in range [start, limit) and calls callback with each enumerated key and its value. // If callback returns false, the enumeration stops immediately, otherwise all matched keys will be enumerated. // a nil start is the logical minimal key that is lesser than any existing keys // a nil limit is the logical maximum key that is greater than any existing keys Iterate(start, limit []byte, reverse bool, callback func(key, value []byte) bool) }
interface for key-space range scan methods must be thread safe
func NewMergedIterator ¶ added in v1.0.2
func NewMergedIterator(databases []Database) DatabaseScanner
NewMergedIterator returns a DatabaseScanner for given group of databases. Group members must have zero-intersection of their key spaces. In other words, they must be shards.
func NewPatchedIterator ¶ added in v1.0.2
func NewPatchedIterator(patch, base Database, patchDeletes map[string]bool) DatabaseScanner
NewPatchedIterator returns a DatabaseScanner for given patch and base database.
type DatabaseService ¶
type DatabaseService struct {
// contains filtered or unexported fields
}
the service type
func NewDatabase ¶
func NewDatabase(dbPath string) (*DatabaseService, error)
func NewDatabaseService ¶
func NewDatabaseService(ctx *node.ServiceContext, dbPath string) (*DatabaseService, error)
service constructor
func (*DatabaseService) BeginTransaction ¶
func (s *DatabaseService) BeginTransaction()
func (*DatabaseService) BeginTransactionWithTag ¶ added in v1.0.2
func (s *DatabaseService) BeginTransactionWithTag(tag string)
func (*DatabaseService) BranchId ¶ added in v1.0.2
func (s *DatabaseService) BranchId() string
func (*DatabaseService) Close ¶
func (s *DatabaseService) Close()
func (*DatabaseService) Delete ¶
func (s *DatabaseService) Delete(key []byte) error
func (*DatabaseService) DeleteAll ¶
func (s *DatabaseService) DeleteAll() error
func (*DatabaseService) DeleteBatch ¶
func (s *DatabaseService) DeleteBatch(b iservices.IDatabaseBatch)
func (*DatabaseService) EnableReversion ¶ added in v1.0.2
func (s *DatabaseService) EnableReversion(b bool) error
func (*DatabaseService) EndTransaction ¶
func (s *DatabaseService) EndTransaction(commit bool) error
func (*DatabaseService) GetRevision ¶
func (s *DatabaseService) GetRevision() uint64
func (*DatabaseService) GetRevisionAndBase ¶
func (s *DatabaseService) GetRevisionAndBase() (current uint64, base uint64)
func (*DatabaseService) GetRevisionTag ¶
func (s *DatabaseService) GetRevisionTag(r uint64) string
func (*DatabaseService) GetTagRevision ¶
func (s *DatabaseService) GetTagRevision(tag string) (uint64, error)
func (*DatabaseService) Has ¶
func (s *DatabaseService) Has(key []byte) (bool, error)
implementation of Database interface
func (*DatabaseService) HashOfTopTransaction ¶ added in v1.0.2
func (s *DatabaseService) HashOfTopTransaction() uint32
func (*DatabaseService) Iterate ¶ added in v1.0.2
func (s *DatabaseService) Iterate(start, limit []byte, reverse bool, callback func(key, value []byte) bool)
func (*DatabaseService) Lock ¶ added in v1.0.2
func (s *DatabaseService) Lock()
func (*DatabaseService) NewBatch ¶
func (s *DatabaseService) NewBatch() iservices.IDatabaseBatch
func (*DatabaseService) NewPatch ¶ added in v1.0.2
func (s *DatabaseService) NewPatch(branchId ...string) iservices.IDatabasePatch
func (*DatabaseService) RLock ¶ added in v1.0.2
func (s *DatabaseService) RLock()
func (*DatabaseService) RUnlock ¶ added in v1.0.2
func (s *DatabaseService) RUnlock()
func (*DatabaseService) RebaseToRevision ¶
func (s *DatabaseService) RebaseToRevision(r uint64) error
func (*DatabaseService) RebaseToTag ¶
func (s *DatabaseService) RebaseToTag(tag string) error
func (*DatabaseService) ReversionEnabled ¶ added in v1.0.2
func (s *DatabaseService) ReversionEnabled() bool
func (*DatabaseService) RevertToRevision ¶
func (s *DatabaseService) RevertToRevision(r uint64) error
func (*DatabaseService) RevertToTag ¶
func (s *DatabaseService) RevertToTag(tag string) error
func (*DatabaseService) RollbackTag ¶ added in v1.0.2
func (s *DatabaseService) RollbackTag(tag string) error
func (*DatabaseService) ServiceId ¶ added in v1.0.2
func (s *DatabaseService) ServiceId() uint32
func (*DatabaseService) Squash ¶ added in v1.0.2
func (s *DatabaseService) Squash(tag string) error
func (*DatabaseService) Stop ¶
func (s *DatabaseService) Stop() error
func (*DatabaseService) TagRevision ¶
func (s *DatabaseService) TagRevision(r uint64, tag string) error
func (*DatabaseService) TransactionHeight ¶
func (s *DatabaseService) TransactionHeight() uint
func (*DatabaseService) Unlock ¶ added in v1.0.2
func (s *DatabaseService) Unlock()
type DatabaseWriter ¶ added in v1.0.2
type DatabaseWriter interface { DatabasePutter DatabaseDeleter }
type GuardedDatabaseService ¶
type GuardedDatabaseService struct {
DatabaseService
}
func NewGuardedDatabaseService ¶
func NewGuardedDatabaseService(ctx *node.ServiceContext, dbPath string) (*GuardedDatabaseService, error)
func (*GuardedDatabaseService) RevertToRevision ¶
func (s *GuardedDatabaseService) RevertToRevision(r uint64) error
func (*GuardedDatabaseService) RevertToTag ¶
func (s *GuardedDatabaseService) RevertToTag(tag string) error
type KeyHashDispatcher ¶
type KeyHashDispatcher struct {
// contains filtered or unexported fields
}
func NewKeyHashDispatcher ¶
func NewKeyHashDispatcher(databases []Database) *KeyHashDispatcher
func (*KeyHashDispatcher) DatabaseForKey ¶
func (dp *KeyHashDispatcher) DatabaseForKey(key []byte) int
func (*KeyHashDispatcher) DatabasesForKeyRange ¶
func (dp *KeyHashDispatcher) DatabasesForKeyRange(start []byte, limit []byte) []int
func (*KeyHashDispatcher) MemberDatabases ¶
func (dp *KeyHashDispatcher) MemberDatabases() []Database
type LevelDatabase ¶
type LevelDatabase struct {
// contains filtered or unexported fields
}
func NewLevelDatabase ¶
func NewLevelDatabase(file string) (*LevelDatabase, error)
create a database
func (*LevelDatabase) Delete ¶
func (db *LevelDatabase) Delete(key []byte) error
delete the given key and its value
func (*LevelDatabase) Get ¶
func (db *LevelDatabase) Get(key []byte) ([]byte, error)
query the value of the given key
func (*LevelDatabase) Has ¶
func (db *LevelDatabase) Has(key []byte) (bool, error)
check existence of the given key
func (*LevelDatabase) Iterate ¶ added in v1.0.2
func (db *LevelDatabase) Iterate(start, limit []byte, reverse bool, callback func(key, value []byte) bool)
func (*LevelDatabase) NewBatch ¶
func (db *LevelDatabase) NewBatch() Batch
create a batch which can pack DatabasePutter & DatabaseDeleter operations and execute them atomically
type LevelDatabaseBatch ¶
type LevelDatabaseBatch struct {
// contains filtered or unexported fields
}
func (*LevelDatabaseBatch) Delete ¶
func (b *LevelDatabaseBatch) Delete(key []byte) error
func (*LevelDatabaseBatch) Write ¶
func (b *LevelDatabaseBatch) Write() error
execute all batched operations
type LevelWriteAheadLog ¶
type LevelWriteAheadLog struct {
// contains filtered or unexported fields
}
func NewLevelWriteAheadLog ¶
func NewLevelWriteAheadLog(file string) (*LevelWriteAheadLog, error)
func (*LevelWriteAheadLog) Close ¶
func (wal *LevelWriteAheadLog) Close()
func (*LevelWriteAheadLog) DeleteTask ¶
func (wal *LevelWriteAheadLog) DeleteTask(taskId uint64) error
func (*LevelWriteAheadLog) DeleteTasks ¶
func (wal *LevelWriteAheadLog) DeleteTasks(taskIds []uint64) error
func (*LevelWriteAheadLog) GetTask ¶
func (wal *LevelWriteAheadLog) GetTask(taskId uint64) (*WriteTask, error)
func (*LevelWriteAheadLog) GetTasks ¶
func (wal *LevelWriteAheadLog) GetTasks() ([]*WriteTask, error)
func (*LevelWriteAheadLog) NewTaskID ¶
func (wal *LevelWriteAheadLog) NewTaskID() uint64
func (*LevelWriteAheadLog) PutTask ¶
func (wal *LevelWriteAheadLog) PutTask(task *WriteTask) error
func (*LevelWriteAheadLog) PutTasks ¶
func (wal *LevelWriteAheadLog) PutTasks(tasks []*WriteTask) error
type RedblackDatabase ¶ added in v1.0.2
type RedblackDatabase struct {
// contains filtered or unexported fields
}
func NewRedblackDatabase ¶ added in v1.0.2
func NewRedblackDatabase() *RedblackDatabase
func (*RedblackDatabase) Close ¶ added in v1.0.2
func (db *RedblackDatabase) Close()
func (*RedblackDatabase) Delete ¶ added in v1.0.2
func (db *RedblackDatabase) Delete(key []byte) error
func (*RedblackDatabase) DeleteBatch ¶ added in v1.0.2
func (db *RedblackDatabase) DeleteBatch(b Batch)
func (*RedblackDatabase) Get ¶ added in v1.0.2
func (db *RedblackDatabase) Get(key []byte) ([]byte, error)
func (*RedblackDatabase) Has ¶ added in v1.0.2
func (db *RedblackDatabase) Has(key []byte) (bool, error)
func (*RedblackDatabase) Iterate ¶ added in v1.0.2
func (db *RedblackDatabase) Iterate(start, limit []byte, reverse bool, callback func(key, value []byte) bool)
func (*RedblackDatabase) NewBatch ¶ added in v1.0.2
func (db *RedblackDatabase) NewBatch() Batch
type RevDatabase ¶
type RevDatabase interface { Revertible Database }
interface for databases that support reversion
type Revertible ¶
type Revertible interface { // get current revision GetRevision() uint64 // get current revision and base revision GetRevisionAndBase() (current uint64, base uint64) // revert to the given revision // you can only revert to a revision that is less than or equal to current revision. // after reverted to revision r, r will be the current revision. RevertToRevision(r uint64) error // rebase to the given revision // after rebased to revision r, r will be the minimal revision you can revert to. RebaseToRevision(r uint64) error EnableReversion(b bool) error ReversionEnabled() bool }
interface for revertible feature methods must be thread safe
type RevertibleDatabase ¶
type RevertibleDatabase struct {
// contains filtered or unexported fields
}
func NewRevertibleDatabase ¶
func NewRevertibleDatabase(db Database) *RevertibleDatabase
func (*RevertibleDatabase) Close ¶
func (db *RevertibleDatabase) Close()
func (*RevertibleDatabase) Delete ¶
func (db *RevertibleDatabase) Delete(key []byte) error
func (*RevertibleDatabase) DeleteBatch ¶
func (db *RevertibleDatabase) DeleteBatch(b Batch)
func (*RevertibleDatabase) EnableReversion ¶ added in v1.0.2
func (db *RevertibleDatabase) EnableReversion(b bool) error
func (*RevertibleDatabase) GetRevision ¶
func (db *RevertibleDatabase) GetRevision() uint64
func (*RevertibleDatabase) GetRevisionAndBase ¶
func (db *RevertibleDatabase) GetRevisionAndBase() (current uint64, base uint64)
func (*RevertibleDatabase) GetRevisionTag ¶
func (db *RevertibleDatabase) GetRevisionTag(r uint64) string
func (*RevertibleDatabase) GetTagRevision ¶
func (db *RevertibleDatabase) GetTagRevision(tag string) (uint64, error)
func (*RevertibleDatabase) Iterate ¶ added in v1.0.2
func (db *RevertibleDatabase) Iterate(start, limit []byte, reverse bool, callback func(key, value []byte) bool)
func (*RevertibleDatabase) NewBatch ¶
func (db *RevertibleDatabase) NewBatch() Batch
func (*RevertibleDatabase) PresetTag ¶ added in v1.0.2
func (db *RevertibleDatabase) PresetTag(tag string)
func (*RevertibleDatabase) RebaseToRevision ¶
func (db *RevertibleDatabase) RebaseToRevision(r uint64) error
func (*RevertibleDatabase) RebaseToTag ¶
func (db *RevertibleDatabase) RebaseToTag(tag string) error
func (*RevertibleDatabase) ReversionEnabled ¶ added in v1.0.2
func (db *RevertibleDatabase) ReversionEnabled() bool
func (*RevertibleDatabase) RevertToRevision ¶
func (db *RevertibleDatabase) RevertToRevision(r uint64) error
func (*RevertibleDatabase) RevertToTag ¶
func (db *RevertibleDatabase) RevertToTag(tag string) error
func (*RevertibleDatabase) TagRevision ¶
func (db *RevertibleDatabase) TagRevision(r uint64, tag string) (err error)
type SimpleDatabaseGroup ¶
type SimpleDatabaseGroup struct {
// contains filtered or unexported fields
}
the database group
func NewSimpleDatabaseGroup ¶
func NewSimpleDatabaseGroup(dp DatabaseDispatcher, wal WriteAheadLog) (*SimpleDatabaseGroup, error)
func (*SimpleDatabaseGroup) Close ¶
func (g *SimpleDatabaseGroup) Close()
func (*SimpleDatabaseGroup) Crashed ¶
func (g *SimpleDatabaseGroup) Crashed() bool
func (*SimpleDatabaseGroup) Delete ¶
func (g *SimpleDatabaseGroup) Delete(key []byte) error
func (*SimpleDatabaseGroup) DeleteBatch ¶
func (g *SimpleDatabaseGroup) DeleteBatch(b Batch)
func (*SimpleDatabaseGroup) Iterate ¶ added in v1.0.2
func (g *SimpleDatabaseGroup) Iterate(start, limit []byte, reverse bool, callback func(key, value []byte) bool)
func (*SimpleDatabaseGroup) NewBatch ¶
func (g *SimpleDatabaseGroup) NewBatch() Batch
type SquashDatabase ¶ added in v1.0.2
type SquashDatabase interface { Squashable Database }
type Squashable ¶ added in v1.0.2
type Squashable interface { Transactional // start a new transaction session named @tag BeginTransactionWithTag(tag string) // Squash() commits the transaction named @tag. // If the transaction is nested, its ancestor transactions will get committed too. Squash(tag string) error // RollbackTag() discards the transaction named @tag. // If any nested transactions were atop the target transaction, they will get discarded too. RollbackTag(tag string) error }
interface for squashable transactional feature
type SquashableDatabase ¶ added in v1.0.2
type SquashableDatabase struct { TransactionalDatabase // contains filtered or unexported fields }
func NewSquashableDatabase ¶ added in v1.0.2
func NewSquashableDatabase(db Database, dirtyRead bool) *SquashableDatabase
func (*SquashableDatabase) BeginTransaction ¶ added in v1.0.2
func (db *SquashableDatabase) BeginTransaction()
func (*SquashableDatabase) BeginTransactionWithTag ¶ added in v1.0.2
func (db *SquashableDatabase) BeginTransactionWithTag(tag string)
func (*SquashableDatabase) DeleteBatch ¶ added in v1.0.2
func (dq *SquashableDatabase) DeleteBatch(b Batch)
func (*SquashableDatabase) EndTransaction ¶ added in v1.0.2
func (db *SquashableDatabase) EndTransaction(commit bool) error
func (*SquashableDatabase) HashOfTopSession ¶ added in v1.0.2
func (dq *SquashableDatabase) HashOfTopSession() (hash uint32)
func (*SquashableDatabase) NewBatch ¶ added in v1.0.2
func (dq *SquashableDatabase) NewBatch() Batch
func (*SquashableDatabase) RollbackTag ¶ added in v1.0.2
func (db *SquashableDatabase) RollbackTag(tag string) error
func (*SquashableDatabase) Squash ¶ added in v1.0.2
func (db *SquashableDatabase) Squash(tag string) error
type TagRevDatabase ¶
type TagRevDatabase interface { TagRevertible Database }
interface for databases that support reversion and revision tagging
type TagRevertible ¶
type TagRevertible interface { Revertible // tag a revision TagRevision(r uint64, tag string) error // get revision of a tag GetTagRevision(tag string) (uint64, error) // get tag of a revision GetRevisionTag(r uint64) string // revert to a revision by its tag RevertToTag(tag string) error // rebase to a revision by its tag RebaseToTag(tag string) error }
interface for databases that support reversion and revision tagging
type Transactional ¶
type Transactional interface { // start a new transaction session BeginTransaction() // end current transaction session, Commit or discard changes EndTransaction(commit bool) error // current transaction height TransactionHeight() uint }
interface for transaction feature methods must be thread safe transaction sessions can be nested. BeginTransaction()/EndTransaction() must be paired.
type TransactionalDatabase ¶
type TransactionalDatabase struct {
// contains filtered or unexported fields
}
TransactionalDatabase adds transactional feature on its underlying database
func NewTransactionalDatabase ¶
func NewTransactionalDatabase(db Database, dirtyRead bool) *TransactionalDatabase
func (*TransactionalDatabase) BeginTransaction ¶
func (db *TransactionalDatabase) BeginTransaction()
start a transaction session
func (*TransactionalDatabase) DeleteBatch ¶
func (dq *TransactionalDatabase) DeleteBatch(b Batch)
func (*TransactionalDatabase) EndTransaction ¶
func (db *TransactionalDatabase) EndTransaction(commit bool) error
end a transaction session. Commit or discard changes
func (*TransactionalDatabase) HashOfTopSession ¶ added in v1.0.2
func (dq *TransactionalDatabase) HashOfTopSession() (hash uint32)
func (*TransactionalDatabase) HashOfTopTransaction ¶ added in v1.0.2
func (db *TransactionalDatabase) HashOfTopTransaction() uint32
func (*TransactionalDatabase) PushBack ¶ added in v1.0.2
func (dq *TransactionalDatabase) PushBack()
func (*TransactionalDatabase) PushFront ¶ added in v1.0.2
func (dq *TransactionalDatabase) PushFront()
func (*TransactionalDatabase) TransactionHeight ¶
func (db *TransactionalDatabase) TransactionHeight() uint
type TrxDatabase ¶
type TrxDatabase interface { Transactional Database }
interface for databases that support transactions