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 EncodeKV(key []byte, value []byte) *store.KV
- func EncodeKey(key []byte) []byte
- func EncodeReference(key, referencedKey []byte, atTx uint64) *store.KV
- func EncodeZAdd(set []byte, score float64, key []byte, atTx uint64) *store.KV
- 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 DbOptions
- func (o *DbOptions) GetCorruptionChecker() bool
- func (o *DbOptions) GetDbName() string
- func (o *DbOptions) GetDbRootPath() string
- func (o *DbOptions) GetReplicationOptions() *ReplicationOptions
- func (o *DbOptions) GetStoreOptions() *store.Options
- func (o *DbOptions) WithCorruptionChecker(cc bool) *DbOptions
- func (o *DbOptions) WithDbName(dbName string) *DbOptions
- func (o *DbOptions) WithDbRootPath(Path string) *DbOptions
- func (o *DbOptions) WithReplicationOptions(replicationOpts *ReplicationOptions) *DbOptions
- func (o *DbOptions) WithStoreOptions(storeOpts *store.Options) *DbOptions
- type ReplicationOptions
- func (o *ReplicationOptions) AsReplica(replica bool) *ReplicationOptions
- func (o *ReplicationOptions) WithFollowerPwd(followerPwd string) *ReplicationOptions
- func (o *ReplicationOptions) WithFollowerUsr(followerUsr string) *ReplicationOptions
- func (o *ReplicationOptions) WithSrcAddress(srcAddress string) *ReplicationOptions
- func (o *ReplicationOptions) WithSrcDatabase(srcDatabase string) *ReplicationOptions
- func (o *ReplicationOptions) WithSrcPort(srcPort int) *ReplicationOptions
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 TrimPrefix ¶ added in v0.9.1
func WrapReferenceValueAt ¶
Types ¶
type DB ¶
type DB interface {
CurrentState() (*schema.ImmutableState, error)
WaitForTx(txID uint64, cancellation <-chan struct{}) error
WaitForIndexingUpto(txID uint64, cancellation <-chan struct{}) error
Set(req *schema.SetRequest) (*schema.TxMetadata, error)
Get(req *schema.KeyRequest) (*schema.Entry, error)
VerifiableSet(req *schema.VerifiableSetRequest) (*schema.VerifiableTx, error)
VerifiableGet(req *schema.VerifiableGetRequest) (*schema.VerifiableEntry, error)
GetAll(req *schema.KeyListRequest) (*schema.Entries, error)
ExecAll(operations *schema.ExecAllRequest) (*schema.TxMetadata, error)
Size() (uint64, error)
Count(prefix *schema.KeyPrefix) (*schema.EntryCount, error)
CountAll() (*schema.EntryCount, error)
TxByID(req *schema.TxRequest) (*schema.Tx, error)
ExportTxByID(req *schema.TxRequest) ([]byte, error)
ReplicateTx(exportedTx []byte) (*schema.TxMetadata, error)
VerifiableTxByID(req *schema.VerifiableTxRequest) (*schema.VerifiableTx, error)
TxScan(req *schema.TxScanRequest) (*schema.TxList, error)
History(req *schema.HistoryRequest) (*schema.Entries, error)
SetReference(req *schema.ReferenceRequest) (*schema.TxMetadata, error)
VerifiableSetReference(req *schema.VerifiableReferenceRequest) (*schema.VerifiableTx, error)
ZAdd(req *schema.ZAddRequest) (*schema.TxMetadata, error)
ZScan(req *schema.ZScanRequest) (*schema.ZEntries, error)
VerifiableZAdd(req *schema.VerifiableZAddRequest) (*schema.VerifiableTx, error)
Scan(req *schema.ScanRequest) (*schema.Entries, error)
Close() error
GetOptions() *DbOptions
UpdateReplicationOptions(replicationOpts *ReplicationOptions)
IsReplica() bool
CompactIndex() error
VerifiableSQLGet(req *schema.VerifiableSQLGetRequest) (*schema.VerifiableSQLEntry, error)
SQLExec(req *schema.SQLExecRequest) (*schema.SQLExecResult, error)
SQLExecPrepared(stmts []sql.SQLStmt, namedParams []*schema.NamedParam, waitForIndexing bool) (*schema.SQLExecResult, error)
InferParameters(sql string) (map[string]sql.SQLValueType, error)
InferParametersPrepared(stmt sql.SQLStmt) (map[string]sql.SQLValueType, error)
UseSnapshot(req *schema.UseSnapshotRequest) error
SQLQuery(req *schema.SQLQueryRequest) (*schema.SQLQueryResult, error)
SQLQueryPrepared(stmt *sql.SelectStmt, namedParams []*schema.NamedParam, renewSnapshot bool) (*schema.SQLQueryResult, error)
SQLQueryRowReader(stmt *sql.SelectStmt, renewSnapshot bool) (sql.RowReader, error)
ListTables() (*schema.SQLQueryResult, error)
DescribeTable(table string) (*schema.SQLQueryResult, error)
GetName() string
}
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 DbOptions ¶
type DbOptions struct {
// contains filtered or unexported fields
}
DbOptions database instance options
func DefaultOption ¶
func DefaultOption() *DbOptions
DefaultOption Initialise Db Optionts to default values
func (*DbOptions) GetCorruptionChecker ¶
GetCorruptionChecker returns if corruption checker should start for this database instance
func (*DbOptions) GetDbRootPath ¶
GetDbRootPath returns the directory in which this database resides
func (*DbOptions) GetReplicationOptions ¶ added in v1.0.5
func (o *DbOptions) GetReplicationOptions() *ReplicationOptions
GetReplicationOptions returns replication options
func (*DbOptions) GetStoreOptions ¶
GetStoreOptions returns backing store options
func (*DbOptions) WithCorruptionChecker ¶
WithCorruptionChecker sets if corruption checker should start for this database instance
func (*DbOptions) WithDbName ¶
WithDbName sets dbName, which is also db instance directory
func (*DbOptions) WithDbRootPath ¶
WithDbRootPath sets the directory in which this database will reside
func (*DbOptions) WithReplicationOptions ¶ added in v1.0.5
func (o *DbOptions) WithReplicationOptions(replicationOpts *ReplicationOptions) *DbOptions
WithReplicationOptions sets replication options
type ReplicationOptions ¶ added in v1.0.5
type ReplicationOptions struct {
Replica bool
SrcDatabase string
SrcAddress string
SrcPort int
FollowerUsr string
FollowerPwd string
}
func (*ReplicationOptions) AsReplica ¶ added in v1.0.5
func (o *ReplicationOptions) AsReplica(replica bool) *ReplicationOptions
AsReplica sets if the database is a replica
func (*ReplicationOptions) WithFollowerPwd ¶ added in v1.0.5
func (o *ReplicationOptions) WithFollowerPwd(followerPwd string) *ReplicationOptions
WithFollowerPwd sets follower password
func (*ReplicationOptions) WithFollowerUsr ¶ added in v1.0.5
func (o *ReplicationOptions) WithFollowerUsr(followerUsr string) *ReplicationOptions
WithFollowerUsr sets follower username
func (*ReplicationOptions) WithSrcAddress ¶ added in v1.0.5
func (o *ReplicationOptions) WithSrcAddress(srcAddress string) *ReplicationOptions
WithSrcAddress sets the source database address
func (*ReplicationOptions) WithSrcDatabase ¶ added in v1.0.5
func (o *ReplicationOptions) WithSrcDatabase(srcDatabase string) *ReplicationOptions
WithSrcDatabase sets the source database name
func (*ReplicationOptions) WithSrcPort ¶ added in v1.0.5
func (o *ReplicationOptions) WithSrcPort(srcPort int) *ReplicationOptions
WithSrcPort sets the source database port