Documentation
¶
Index ¶
- Constants
- Variables
- func RunIDBTests(t *testing.T, connParams1 interface{}, connParams2 interface{}) context.Context
- type ConditionType
- type ContextKeyType
- type ErrUnacceptableConditionOnKeyField
- type FieldCondition
- type FieldDef
- type FieldType
- type FieldValue
- type GetRequest
- type GetRequestBuilder
- type InsertRequest
- type InsertRequestBuilder
- func (irb *InsertRequestBuilder) Build() *InsertRequest
- func (irb *InsertRequestBuilder) Key(field *FieldDef, value interface{}) *InsertRequestBuilder
- func (irb *InsertRequestBuilder) TTL(ttlValue int) *InsertRequestBuilder
- func (irb *InsertRequestBuilder) Val(field *FieldDef, value interface{}) *InsertRequestBuilder
- type KeyValue
- type RRBWhereStep
- type RangeRequest
- type RangeRequestBuilder
- type Scan
- type TableBuilder
- func (tb *TableBuilder) Build() *TableDef
- func (tb *TableBuilder) BuildTemplate() *TableTemplate
- func (tb *TableBuilder) ClusterKeyField(field *FieldDef) *TableBuilder
- func (tb *TableBuilder) DeriveFrom(tableTemplate *TableTemplate) *TableBuilder
- func (tb *TableBuilder) Field(field *FieldDef) *TableBuilder
- func (tb *TableBuilder) PartitionKeyField(field *FieldDef) *TableBuilder
- type TableDef
- type TableTemplate
- type URBWhereStep
- type UpdateRequest
- type UpdateRequestBuilder
- func (urb *UpdateRequestBuilder) Build() *UpdateRequest
- func (urb *UpdateRequestBuilder) Key(field *FieldDef, value interface{}) *UpdateRequestBuilder
- func (urb *UpdateRequestBuilder) TTL(ttlValue int) *UpdateRequestBuilder
- func (urb *UpdateRequestBuilder) Val(field *FieldDef, value interface{}) *UpdateRequestBuilder
- func (urb *UpdateRequestBuilder) Where(field *FieldDef) *URBWhereStep
Constants ¶
const ConnectionParametersKey = ContextKeyType("ConnectionParameters")
ConnectionParametersKey s.e.
Variables ¶
var ( ErrNonCompleteKey = errors.New("All key fields must be specified") ErrEmptyPartitionKey = errors.New("Partition key is not specified") ErrNothingToSelect = errors.New("Nothing to select") ErrIfNotExistsWithConditions = errors.New("IfNotExists has no sence with Where conditions") ErrNothingToSet = errors.New("No values to set specified") ErrNoTableDef = errors.New("Table is not specified") )
Err
var Finit func(ctx context.Context)
Finit closes connection (if any) and associated data structures
var Get func(ctx context.Context, gr *GetRequest) bool
Get s.e. returns if value exists for the key
Init database connection and create all tables registered in `TableDefs“ Must work in multi-process environment (another processes may also trying to create same tables) Connection parameters must be passed through `ctx` using `ConnectionParametersKey`
var Insert func(ctx context.Context, ir *InsertRequest) bool
Insert saves values for a given key into database only if no value exists for the provided key Values to be saved and the key are described by InsertRequest Function returns true if value has been added and false if table already has value for the provided key Panics if something goes wrong
var Put func(ctx context.Context, ir *InsertRequest)
Put in Cassandra terms does INSERT, LWT is not involved (no "if not exist" etc.)
var Range func(ctx context.Context, rr *RangeRequest) Scan
Range s.e. If something goes wrong function panics
var TableDefs map[string]*TableDef
TableDefs keeps table definitions
var Update func(ctx context.Context, ur *UpdateRequest) bool
Update updates values for a given key and conditions Values to be saved, the key and conditions are described by UpdateRequest Function returns true if value has been updated and false if no value for the provided key and\or conditions Panics if something goes wrong
Functions ¶
Types ¶
type ConditionType ¶ added in v0.4.0
type ConditionType int
ConditionType s.e.
const ( // ConditionTypeNone represents no condition ConditionTypeNone ConditionType = iota // ConditionTypeIn represents "in" condition ConditionTypeIn // ConditionTypeEq represents "==" condition ConditionTypeEq // ConditionTypeGt represents ">" condition ConditionTypeGt )
type ErrUnacceptableConditionOnKeyField ¶ added in v0.4.0
ErrUnacceptableConditionOnKeyField s.e.
func (*ErrUnacceptableConditionOnKeyField) Error ¶ added in v0.4.0
func (e *ErrUnacceptableConditionOnKeyField) Error() string
type FieldCondition ¶ added in v0.4.0
type FieldCondition struct { FieldDef *FieldDef ConditionType ConditionType Operands []interface{} }
FieldCondition represents FieldDef and condition on it
type FieldType ¶ added in v0.4.0
type FieldType int
FieldType s.e.
const ( FieldTypeASCII FieldType = iota FieldTypeBIGINT FieldTypeBLOB FieldTypeBOOLEAN FieldTypeDATE FieldTypeDECIMAL FieldTypeDOUBLE FieldTypeDURATION FieldTypeFLOAT FieldTypeINT FieldTypeSMALLINT FieldTypeTEXT FieldTypeTIME FieldTypeTIMESTAMP FieldTypeTIMEUUID FieldTypeTINYINT FieldTypeUUID FieldTypeVARINT )
Field types, ref.
type FieldValue ¶ added in v0.4.0
type FieldValue struct { FieldDef *FieldDef Value interface{} }
FieldValue is FieldDef with its value used to build condition or to receive result
type GetRequest ¶
type GetRequest struct { KeyFields []*FieldValue TableDef *TableDef Results []*FieldValue }
GetRequest represents select command
type GetRequestBuilder ¶
type GetRequestBuilder struct {
// contains filtered or unexported fields
}
GetRequestBuilder s.e.
func (*GetRequestBuilder) Build ¶
func (grb *GetRequestBuilder) Build() *GetRequest
Build returns GetRequest if not all key fields are specified Panics with ErrNonCompleteKey if not all key fields are specified Panics with ErrNothingToSelect if Get() was never called
func (*GetRequestBuilder) Get ¶ added in v0.4.0
func (grb *GetRequestBuilder) Get(field *FieldDef, ptrToResultVar interface{}) *GetRequestBuilder
Get adds field to be selected
func (*GetRequestBuilder) Key ¶
func (grb *GetRequestBuilder) Key(field *FieldDef, value interface{}) *GetRequestBuilder
Key adds field+value to be used as key to select operation
type InsertRequest ¶ added in v0.4.0
InsertRequest s.e.
func (*InsertRequest) Exec ¶ added in v0.4.0
func (ir *InsertRequest) Exec(ctx context.Context) bool
Exec executes Insert operation returns if the inserted value is new for the key
func (*InsertRequest) Put ¶ added in v0.4.0
func (ir *InsertRequest) Put(ctx context.Context)
Put executes insert or update operation with no "if exists"
type InsertRequestBuilder ¶ added in v0.4.0
type InsertRequestBuilder struct {
// contains filtered or unexported fields
}
InsertRequestBuilder s.e.
func NewInsertRequest ¶ added in v0.4.0
func NewInsertRequest(td *TableDef) *InsertRequestBuilder
NewInsertRequest s.e.
func (*InsertRequestBuilder) Build ¶ added in v0.4.0
func (irb *InsertRequestBuilder) Build() *InsertRequest
Build returns InsertRequest Panics with ErrNonCompleteKey if not all key fields are specified Panics with ErrNothingToSet if not all key fields are specified
func (*InsertRequestBuilder) Key ¶ added in v0.4.0
func (irb *InsertRequestBuilder) Key(field *FieldDef, value interface{}) *InsertRequestBuilder
Key adds key field+value definition to be used on insert operation
func (*InsertRequestBuilder) TTL ¶ added in v0.4.0
func (irb *InsertRequestBuilder) TTL(ttlValue int) *InsertRequestBuilder
TTL 0 -> uncpecified
func (*InsertRequestBuilder) Val ¶ added in v0.4.0
func (irb *InsertRequestBuilder) Val(field *FieldDef, value interface{}) *InsertRequestBuilder
Val adds value field+value to be set on insert operation
type KeyValue ¶ added in v0.4.0
type KeyValue struct { KeyFields []*FieldValue ValueFields []*FieldValue }
KeyValue represents basic storage for key and value fields
type RRBWhereStep ¶ added in v0.4.0
type RRBWhereStep struct {
// contains filtered or unexported fields
}
RRBWhereStep represents where step for Range Request Builder
func (*RRBWhereStep) Eq ¶ added in v0.4.0
func (rrbws *RRBWhereStep) Eq(value interface{}) *RangeRequestBuilder
Eq s.e.
func (*RRBWhereStep) Gt ¶ added in v0.4.0
func (rrbws *RRBWhereStep) Gt(value interface{}) *RangeRequestBuilder
Gt s.e.
func (*RRBWhereStep) In ¶ added in v0.4.0
func (rrbws *RRBWhereStep) In(values ...interface{}) *RangeRequestBuilder
In s.e.
type RangeRequest ¶
type RangeRequest struct { TableDef *TableDef Conditions []*FieldCondition Results []*FieldDef }
RangeRequest represents select with "from" to "to" range instead of exact conditions
type RangeRequestBuilder ¶
type RangeRequestBuilder struct {
// contains filtered or unexported fields
}
RangeRequestBuilder s.e.
func NewRangeRequest ¶
func NewRangeRequest(td *TableDef) *RangeRequestBuilder
NewRangeRequest creates new empty RangeRequest
func (*RangeRequestBuilder) Build ¶
func (rrb *RangeRequestBuilder) Build() *RangeRequest
Build returns Range Request Panics with ErrNonCompleteKey if not all key fields are specified Panics with ErrUnacceptableConditionOnKeyField if > condition on partition key field is met (> is acceptable for cluster fields only) Panics with ErrNothingToSelect if Get() was never called
func (*RangeRequestBuilder) Get ¶ added in v0.4.0
func (rrb *RangeRequestBuilder) Get(field *FieldDef) *RangeRequestBuilder
Get adds field to be selected
func (*RangeRequestBuilder) Where ¶ added in v0.4.0
func (rrb *RangeRequestBuilder) Where(field *FieldDef) *RRBWhereStep
Where s.e.
type Scan ¶ added in v0.4.0
type Scan func(...interface{}) bool
Scan fills provided dests with values of fields of next row returns if next row existed
type TableBuilder ¶
type TableBuilder struct {
// contains filtered or unexported fields
}
TableBuilder represents table builder instance which holds data to be used to create a table
func (*TableBuilder) Build ¶
func (tb *TableBuilder) Build() *TableDef
Build returns TableDef panics with EEmptyPartitionKey if no fields for Partition Key were set
func (*TableBuilder) BuildTemplate ¶ added in v0.4.0
func (tb *TableBuilder) BuildTemplate() *TableTemplate
BuildTemplate BuildAbstract returns TableDef with no checks. Used for derive this TableDef
func (*TableBuilder) ClusterKeyField ¶
func (tb *TableBuilder) ClusterKeyField(field *FieldDef) *TableBuilder
ClusterKeyField adds field as cluster key field to a table definition
func (*TableBuilder) DeriveFrom ¶ added in v0.4.0
func (tb *TableBuilder) DeriveFrom(tableTemplate *TableTemplate) *TableBuilder
DeriveFrom s.e.
func (*TableBuilder) Field ¶
func (tb *TableBuilder) Field(field *FieldDef) *TableBuilder
Field adds field to a table definition
func (*TableBuilder) PartitionKeyField ¶
func (tb *TableBuilder) PartitionKeyField(field *FieldDef) *TableBuilder
PartitionKeyField adds field as partition key field to a table definition
type TableDef ¶
type TableDef struct { UniqueName string PartitionKeyFields []*FieldDef // must not be empty ClusterKeyFields []*FieldDef // may be empty Fields []*FieldDef // may be empty }
TableDef defines cassandra-like table All fields are non-nil
type TableTemplate ¶ added in v0.4.0
type TableTemplate struct {
*TableDef
}
TableTemplate is used to build template tables to derive from
type URBWhereStep ¶ added in v0.4.0
type URBWhereStep struct {
// contains filtered or unexported fields
}
URBWhereStep represents where step for Update Request Builder
func (*URBWhereStep) Eq ¶ added in v0.4.0
func (urbws *URBWhereStep) Eq(value interface{}) *UpdateRequestBuilder
Eq s.e.
func (*URBWhereStep) Gt ¶ added in v0.4.0
func (urbws *URBWhereStep) Gt(value interface{}) *UpdateRequestBuilder
Gt s.e.
func (*URBWhereStep) In ¶ added in v0.4.0
func (urbws *URBWhereStep) In(values ...interface{}) *UpdateRequestBuilder
In s.e.
type UpdateRequest ¶ added in v0.4.0
type UpdateRequest struct { *KeyValue TableDef *TableDef Conditions []*FieldCondition TTL int }
UpdateRequest s.e.
type UpdateRequestBuilder ¶ added in v0.4.0
type UpdateRequestBuilder struct {
// contains filtered or unexported fields
}
UpdateRequestBuilder s.e.
func NewUpdateRequest ¶ added in v0.4.0
func NewUpdateRequest(td *TableDef) *UpdateRequestBuilder
NewUpdateRequest s.e.
func (*UpdateRequestBuilder) Build ¶ added in v0.4.0
func (urb *UpdateRequestBuilder) Build() *UpdateRequest
Build returns UpdateRequest Panics with ErrNonCompleteKey if not all key fields are specified
func (*UpdateRequestBuilder) Key ¶ added in v0.4.0
func (urb *UpdateRequestBuilder) Key(field *FieldDef, value interface{}) *UpdateRequestBuilder
Key adds key field+value definition to be used on update operation
func (*UpdateRequestBuilder) TTL ¶ added in v0.4.0
func (urb *UpdateRequestBuilder) TTL(ttlValue int) *UpdateRequestBuilder
TTL 0 -> unspecified
func (*UpdateRequestBuilder) Val ¶ added in v0.4.0
func (urb *UpdateRequestBuilder) Val(field *FieldDef, value interface{}) *UpdateRequestBuilder
Val adds value field+value to be set on update operation
func (*UpdateRequestBuilder) Where ¶ added in v0.4.0
func (urb *UpdateRequestBuilder) Where(field *FieldDef) *URBWhereStep
Where s.e.