Documentation
¶
Overview ¶
Copyright 2021 CodeNotary, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 CodeNotary, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 CodeNotary, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021 CodeNotary, Inc. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- Variables
- func EncodeEntrySpec(key []byte, md *store.KVMetadata, value []byte) *store.EntrySpec
- func EncodeKey(key []byte) []byte
- func EncodeReference(key []byte, md *store.KVMetadata, referencedKey []byte, atTx uint64) *store.EntrySpec
- func EncodeZAdd(set []byte, score float64, key []byte, atTx uint64) *store.EntrySpec
- func TrimPrefix(prefixed []byte) []byte
- func WrapReferenceValueAt(key []byte, atTx uint64) []byte
- func WrapWithPrefix(b []byte, prefix byte) []byte
- func WrapZAddReferenceAt(set []byte, score float64, key []byte, atTx uint64) []byte
- type DB
- type DatabaseList
- type Options
- func (o *Options) AsReplica(replica bool) *Options
- func (o *Options) GetCorruptionChecker() bool
- func (o *Options) GetDBName() string
- func (o *Options) GetDBRootPath() string
- func (o *Options) GetStoreOptions() *store.Options
- func (o *Options) WithCorruptionChecker(cc bool) *Options
- func (o *Options) WithDBName(dbName string) *Options
- func (o *Options) WithDBRootPath(Path string) *Options
- func (o *Options) WithStoreOptions(storeOpts *store.Options) *Options
Constants ¶
const ( SetKeyPrefix byte = iota SortedSetKeyPrefix SQLPrefix )
const ( PlainValuePrefix = iota ReferenceValuePrefix )
const MaxKeyResolutionLimit = 1
const MaxKeyScanLimit = 1000
Variables ¶
var ( ErrIndexKeyMismatch = status.New(codes.InvalidArgument, "mismatch between provided index and key").Err() ErrNoReferenceProvided = status.New(codes.InvalidArgument, "provided argument is not a reference").Err() ErrReferenceKeyMissing = status.New(codes.InvalidArgument, "reference key not provided").Err() ErrZAddIndexMissing = status.New(codes.InvalidArgument, "zAdd index not provided").Err() ErrReferenceIndexMissing = status.New(codes.InvalidArgument, "reference index not provided").Err() ErrDatabaseNotExists = status.New(codes.NotFound, "database does not exist").Err() )
var ErrFinalKeyCannotBeConvertedIntoReference = errors.New("final key cannot be converted into a reference")
var ErrIllegalArguments = store.ErrIllegalArguments
var ErrIllegalState = store.ErrIllegalState
var ErrIsReplica = errors.New("database is read-only because it's a replica")
var ErrMaxKeyResolutionLimitReached = errors.New("max key resolution limit reached. It may be due to cyclic references")
var ErrMaxKeyScanLimitExceeded = errors.New("max key scan limit exceeded")
var ErrNotReplica = errors.New("database is NOT a replica")
var ErrReferencedKeyCannotBeAReference = errors.New("referenced key cannot be a reference")
var ErrSQLNotReady = errors.New("SQL catalog not yet replicated")
Functions ¶
func EncodeEntrySpec ¶ added in v1.2.0
func EncodeReference ¶
func EncodeZAdd ¶
func TrimPrefix ¶ added in v0.9.1
func WrapReferenceValueAt ¶
Types ¶
type DB ¶
type DB interface {
GetName() string
// Setttings
GetOptions() *Options
AsReplica(asReplica bool)
IsReplica() bool
UseTimeFunc(timeFunc store.TimeFunc) error
// State
CurrentState() (*schema.ImmutableState, error)
Size() (uint64, error)
// Key-Value
Set(req *schema.SetRequest) (*schema.TxHeader, error)
VerifiableSet(req *schema.VerifiableSetRequest) (*schema.VerifiableTx, error)
Get(req *schema.KeyRequest) (*schema.Entry, error)
VerifiableGet(req *schema.VerifiableGetRequest) (*schema.VerifiableEntry, error)
GetAll(req *schema.KeyListRequest) (*schema.Entries, error)
Delete(req *schema.DeleteKeysRequest) (*schema.TxHeader, error)
SetReference(req *schema.ReferenceRequest) (*schema.TxHeader, error)
VerifiableSetReference(req *schema.VerifiableReferenceRequest) (*schema.VerifiableTx, error)
Scan(req *schema.ScanRequest) (*schema.Entries, error)
History(req *schema.HistoryRequest) (*schema.Entries, error)
ExecAll(operations *schema.ExecAllRequest) (*schema.TxHeader, error)
Count(prefix *schema.KeyPrefix) (*schema.EntryCount, error)
CountAll() (*schema.EntryCount, error)
ZAdd(req *schema.ZAddRequest) (*schema.TxHeader, error)
VerifiableZAdd(req *schema.VerifiableZAddRequest) (*schema.VerifiableTx, error)
ZScan(req *schema.ZScanRequest) (*schema.ZEntries, error)
// SQL-related
SQLExec(req *schema.SQLExecRequest, tx *sql.SQLTx) (ntx *sql.SQLTx, ctxs []*sql.SQLTx, err error)
SQLExecPrepared(stmts []sql.SQLStmt, namedParams []*schema.NamedParam, tx *sql.SQLTx) (ntx *sql.SQLTx, ctxs []*sql.SQLTx, err error)
InferParameters(sql string, tx *sql.SQLTx) (map[string]sql.SQLValueType, error)
InferParametersPrepared(stmt sql.SQLStmt, tx *sql.SQLTx) (map[string]sql.SQLValueType, error)
SQLQuery(req *schema.SQLQueryRequest, tx *sql.SQLTx) (*schema.SQLQueryResult, error)
SQLQueryPrepared(stmt *sql.SelectStmt, namedParams []*schema.NamedParam, tx *sql.SQLTx) (*schema.SQLQueryResult, error)
SQLQueryRowReader(stmt *sql.SelectStmt, tx *sql.SQLTx) (sql.RowReader, error)
VerifiableSQLGet(req *schema.VerifiableSQLGetRequest) (*schema.VerifiableSQLEntry, error)
ListTables(tx *sql.SQLTx) (*schema.SQLQueryResult, error)
DescribeTable(table string, tx *sql.SQLTx) (*schema.SQLQueryResult, error)
// Transactional layer
WaitForTx(txID uint64, cancellation <-chan struct{}) error
WaitForIndexingUpto(txID uint64, cancellation <-chan struct{}) error
TxByID(req *schema.TxRequest) (*schema.Tx, error)
ExportTxByID(req *schema.TxRequest) ([]byte, error)
ReplicateTx(exportedTx []byte) (*schema.TxHeader, error)
VerifiableTxByID(req *schema.VerifiableTxRequest) (*schema.VerifiableTx, error)
TxScan(req *schema.TxScanRequest) (*schema.TxList, error)
// Maintenance
CompactIndex() error
Close() error
}
type DatabaseList ¶ added in v1.0.0
type DatabaseList interface {
Append(database DB)
GetByIndex(index int64) DB
GetByName(string) (DB, error)
GetId(dbname string) int64
Length() int
}
DatabaseList interface
func NewDatabaseList ¶ added in v1.0.0
func NewDatabaseList() DatabaseList
NewDatabaseList constructs a new database list
type Options ¶ added in v1.1.0
type Options struct {
// contains filtered or unexported fields
}
Options database instance options
func DefaultOption ¶
func DefaultOption() *Options
DefaultOption Initialise Db Optionts to default values
func (*Options) GetCorruptionChecker ¶ added in v1.1.0
GetCorruptionChecker returns if corruption checker should start for this database instance
func (*Options) GetDBName ¶ added in v1.1.0
GetDbName Returns Database name which is also db instance directory
func (*Options) GetDBRootPath ¶ added in v1.1.0
GetDbRootPath returns the directory in which this database resides
func (*Options) GetStoreOptions ¶ added in v1.1.0
GetStoreOptions returns backing store options
func (*Options) WithCorruptionChecker ¶ added in v1.1.0
WithCorruptionChecker sets if corruption checker should start for this database instance
func (*Options) WithDBName ¶ added in v1.1.0
WithDbName sets dbName, which is also db instance directory
func (*Options) WithDBRootPath ¶ added in v1.1.0
WithDbRootPath sets the directory in which this database will reside