Documentation
¶
Overview ¶
see marker below
Package ptr provides utilities for pointer operations using storage layer paths.
Index ¶
- Constants
- Variables
- func New(ctx context.Context, _ logging.Logger, prom prometheus.Registerer, ...) (storage.Store, error)
- func NewNotFoundError(path storage.Path) *storage.Error
- func NewNotFoundErrorWithHint(path storage.Path, hint string) *storage.Error
- func NewNotFoundErrorf(f string, a ...interface{}) *storage.Error
- func NewWriteConflictError(p storage.Path) *storage.Error
- func Ptr(data interface{}, path storage.Path) (interface{}, error)
- func ValidateArrayIndex(arr []interface{}, s string, path storage.Path) (int, error)
- func ValidateArrayIndexForWrite(arr []interface{}, s string, i int, path storage.Path) (int, error)
- type Discovery
- type Options
- type Store
- func (db *Store) Abort(ctx context.Context, txn storage.Transaction)
- func (db *Store) Close(context.Context) error
- func (db *Store) Commit(ctx context.Context, txn storage.Transaction) error
- func (db *Store) MakeDir(_ context.Context, txn storage.Transaction, _ storage.Path) error
- func (db *Store) NewTransaction(ctx context.Context, params ...storage.TransactionParams) (storage.Transaction, error)
- func (db *Store) Read(ctx context.Context, txn storage.Transaction, path storage.Path) (interface{}, error)
- func (db *Store) ReadBJSON(ctx context.Context, txn storage.Transaction, path storage.Path) (bjson.Json, error)
- func (db *Store) Truncate(_ context.Context, _ storage.Transaction, _ storage.TransactionParams, ...) error
- func (db *Store) Write(ctx context.Context, txn storage.Transaction, op storage.PatchOp, ...) error
- type Table
- type TableOpt
- func (t *TableOpt) AbsolutePath(path storage.Path) storage.Path
- func (t *TableOpt) DeleteArgs(path storage.Path) []interface{}
- func (t *TableOpt) DeleteQuery() string
- func (t *TableOpt) DocPath(path storage.Path) storage.Path
- func (t *TableOpt) InsertArgs(path storage.Path, value interface{}) ([]interface{}, error)
- func (t *TableOpt) InsertQuery() string
- func (t *TableOpt) RelativePath(path storage.Path) storage.Path
- func (t *TableOpt) Scan(rows *sql.Rows) (storage.Path, interface{}, error)
- func (t *TableOpt) Schema() string
- func (t *TableOpt) SelectArgs(path storage.Path) []interface{}
- func (t *TableOpt) SelectQuery(path storage.Path) string
- type ValueColumn
- type ValueColumnOpt
Constants ¶
const ( ColumnTypeJSON = "json" ColumnTypeString = "string" ColumnTypeBool = "bool" ColumnTypeFloat64 = "float64" ColumnTypeInt64 = "int64" )
const ArrayIndexTypeMsg = "array index must be integer"
const DoesNotExistMsg = "document does not exist"
const OutOfRangeMsg = "array index out of range"
Variables ¶
Functions ¶
func New ¶
func New(ctx context.Context, _ logging.Logger, prom prometheus.Registerer, options interface{}) (storage.Store, error)
New returns a new SQL-based store based on the provided options. It does not validate the table configuration with the existing tables in the database.
func NewNotFoundErrorf ¶
func ValidateArrayIndex ¶
func ValidateArrayIndexForWrite ¶
ValidateArrayIndexForWrite also checks that `s` is a valid way to address an array element like `ValidateArrayIndex`, but returns a `resource_conflict` error if it is not.
Types ¶
type Options ¶
type Options struct {
Driver string // SQL driver name
DataSourceName string // SQL data source name
Tables []TableOpt
}
Options contains parameters that configure the SQL-based store.
func OptionsFromConfig ¶
OptionsFromConfig parses the passed config, extracts the disk storage settings, validates it, and returns a *Options struct pointer on success.
func (Options) WithTables ¶
type Store ¶
type Store struct {
storage.PolicyNotSupported
storage.TriggersNotSupported
// contains filtered or unexported fields
}
Store provides an SQL-based implementation of the storage.Store interface.
func (*Store) Abort ¶
func (db *Store) Abort(ctx context.Context, txn storage.Transaction)
Abort implements the storage.Store interface.
func (*Store) MakeDir ¶
MakeDir makes Store a storage.MakeDirer, to avoid the superfluous MakeDir steps -- MakeDir is implicit in the disk storage's data layout.
Here, we only check if it's a write transaction, for consistency with other implementations, and do nothing.
func (*Store) NewTransaction ¶
func (db *Store) NewTransaction(ctx context.Context, params ...storage.TransactionParams) (storage.Transaction, error)
NewTransaction implements the storage.Store interface.
func (*Store) Read ¶
func (db *Store) Read(ctx context.Context, txn storage.Transaction, path storage.Path) (interface{}, error)
Read implements the storage.Store interface.
func (*Store) ReadBJSON ¶
func (db *Store) ReadBJSON(ctx context.Context, txn storage.Transaction, path storage.Path) (bjson.Json, error)
ReadBJSON implements the storage.Store interface.
type Table ¶
type Table struct {
Path string `json:"path"` // Tables path in the namespace.
Table string `json:"table"` // Table name
PrimaryKey []string `json:"primary_key"` // Column names
Values []ValueColumn `json:"values"` // Value columns
}
type TableOpt ¶
type TableOpt struct {
Path storage.Path // Base path for the table (wild carded primary key included).
Table string
KeyColumns []string
ValueColumns []ValueColumnOpt
// contains filtered or unexported fields
}
func (*TableOpt) AbsolutePath ¶
AbsolutePath converts a table relative path to an absolute path.
func (*TableOpt) DeleteArgs ¶
func (*TableOpt) DeleteQuery ¶
func (*TableOpt) InsertArgs ¶
func (*TableOpt) InsertQuery ¶
func (*TableOpt) RelativePath ¶
RelativePath converts an absolute path to a table relative path.