database

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsErrNotFound

func IsErrNotFound(err error) bool

IsErrNotFound returns true if err is type of ErrNotFound, false otherwise.

Types

type DecodeError

type DecodeError struct {
	ID string
}

DecodeError represents a service impossible to decode.

func (*DecodeError) Error

func (e *DecodeError) Error() string

type ErrNotFound

type ErrNotFound struct {
	ID string
}

ErrNotFound is an not found error.

func (*ErrNotFound) Error

func (e *ErrNotFound) Error() string

type ExecutionDB added in v0.4.0

type ExecutionDB interface {
	Find(executionHash []byte) (*execution.Execution, error)
	Save(execution *execution.Execution) error
	OpenTransaction() (ExecutionTransaction, error)
	io.Closer
}

ExecutionDB exposes all the functionalities

type ExecutionTransaction added in v0.7.0

type ExecutionTransaction interface {
	Find(executionHash []byte) (*execution.Execution, error)
	Save(execution *execution.Execution) error
	Commit() error
	Discard()
}

ExecutionTransaction is the transaction handle.

type LevelDBExecutionDB added in v0.4.0

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

LevelDBExecutionDB is a concrete implementation of the DB interface

func NewExecutionDB added in v0.4.0

func NewExecutionDB(path string) (*LevelDBExecutionDB, error)

NewExecutionDB creates a new DB instance

func (*LevelDBExecutionDB) Close added in v0.4.0

func (db *LevelDBExecutionDB) Close() error

Close closes database.

func (*LevelDBExecutionDB) Find added in v0.4.0

func (db *LevelDBExecutionDB) Find(executionHash []byte) (*execution.Execution, error)

Find the execution based on an executionHash, returns an error if not found

func (*LevelDBExecutionDB) OpenTransaction added in v0.7.0

func (db *LevelDBExecutionDB) OpenTransaction() (ExecutionTransaction, error)

OpenTransaction opens an atomic DB transaction. Only one transaction can be opened at a time.

func (*LevelDBExecutionDB) Save added in v0.4.0

func (db *LevelDBExecutionDB) Save(execution *execution.Execution) error

Save an instance of executable in the database Returns an error if anything from marshaling to database saving goes wrong

type LevelDBExecutionTransaction added in v0.7.0

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

LevelDBExecutionTransaction is the transaction handle.

func (*LevelDBExecutionTransaction) Commit added in v0.7.0

func (tx *LevelDBExecutionTransaction) Commit() error

Commit commits the transaction.

func (*LevelDBExecutionTransaction) Discard added in v0.7.0

func (tx *LevelDBExecutionTransaction) Discard()

Discard discards the transaction.

func (*LevelDBExecutionTransaction) Find added in v0.7.0

func (tx *LevelDBExecutionTransaction) Find(executionHash []byte) (*execution.Execution, error)

Find the execution based on an executionHash, returns an error if not found

func (*LevelDBExecutionTransaction) Save added in v0.7.0

Save an instance of executable in the database Returns an error if anything from marshaling to database saving goes wrong

type LevelDBServiceDB added in v0.4.0

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

LevelDBServiceDB is a database for storing service definition.

func NewServiceDB

func NewServiceDB(path string) (*LevelDBServiceDB, error)

NewServiceDB returns the database which is located under given path.

func (*LevelDBServiceDB) All added in v0.4.0

func (d *LevelDBServiceDB) All() ([]*service.Service, error)

All returns every service in database.

func (*LevelDBServiceDB) Close added in v0.4.0

func (d *LevelDBServiceDB) Close() error

Close closes database.

func (*LevelDBServiceDB) Delete added in v0.4.0

func (d *LevelDBServiceDB) Delete(hashOrSid string) error

Delete deletes service from database.

func (*LevelDBServiceDB) Get added in v0.4.0

func (d *LevelDBServiceDB) Get(hashOrSid string) (*service.Service, error)

Get retrives service from database.

func (*LevelDBServiceDB) Save added in v0.4.0

func (d *LevelDBServiceDB) Save(s *service.Service) error

Save stores service in database. If there is an another service that uses the same sid, it'll be deleted.

type ServiceDB

type ServiceDB interface {
	// Save saves a service to database.
	Save(s *service.Service) error

	// Get gets a service from database by its unique id
	// or unique sid.
	Get(hashOrSid string) (*service.Service, error)

	// Delete deletes a service from database by its unique id
	// or unique sid.
	Delete(hashOrSid string) error

	// All returns all services from database.
	All() ([]*service.Service, error)

	// Close closes underlying database connection.
	Close() error
}

ServiceDB describes the API of database package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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