boltz

package
v0.15.25 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RootBucket    = "ziti"
	IndexesBucket = "indexes"
)
View Source
const (
	EventCreate events.EventName = "CREATE"
	EventDelete events.EventName = "DELETE"
	EventUpdate events.EventName = "UPDATE"

	FieldId        = "id"
	FieldCreatedAt = "createdAt"
	FieldUpdatedAt = "updatedAt"
	FieldTags      = "tags"
)
View Source
const (
	CascadeNone   = 1
	CascadeDelete = 2
)
View Source
const (
	ListSizeKeyName = "__list__size__36484231-110c-4767-afe2-01b6e3db107a"
)
View Source
const MaxLinkedSetKeySize = 4096
View Source
const (
	SortMax = 5
)

Variables

This section is empty.

Functions

func BytesToBool

func BytesToBool(value []byte) *bool

func BytesToDatetime

func BytesToDatetime(buf []byte, name string) *time.Time

func BytesToFloat64

func BytesToFloat64(buf []byte) *float64

func BytesToInt32

func BytesToInt32(buf []byte) *int32

func BytesToInt64

func BytesToInt64(buf []byte) *int64

func BytesToString

func BytesToString(buf []byte) *string

func DecodeNext

func DecodeNext(val []byte) ([]byte, []byte, error)

func DecodeStringSlice

func DecodeStringSlice(compoundKey []byte) ([]string, error)

func DumpBoltDb

func DumpBoltDb(tx *bbolt.Tx)

func EncodeByteSlice

func EncodeByteSlice(value []byte) ([]byte, error)

func EncodeStringSlice

func EncodeStringSlice(values []string) ([]byte, error)

func FieldToBool

func FieldToBool(fieldType FieldType, value []byte) *bool

func FieldToDatetime

func FieldToDatetime(fieldType FieldType, value []byte, name string) *time.Time

func FieldToFloat64

func FieldToFloat64(fieldType FieldType, value []byte) *float64

func FieldToInt32 added in v0.11.15

func FieldToInt32(fieldType FieldType, value []byte) *int32

func FieldToInt64

func FieldToInt64(fieldType FieldType, value []byte) *int64

func FieldToString

func FieldToString(fieldType FieldType, value []byte) *string

func GetSingularEntityType

func GetSingularEntityType(entityType string) string

func Int32ToBytes added in v0.14.4

func Int32ToBytes(value int32) []byte

func IsErrNotFoundErr

func IsErrNotFoundErr(err error) bool

func NewBoltCursor

func NewBoltCursor(cursor *bbolt.Cursor, forward bool) ast.SeekableSetCursor

func NewForwardBoltCursor

func NewForwardBoltCursor(cursor *bbolt.Cursor) ast.SeekableSetCursor

func NewNotFoundError

func NewNotFoundError(entityType, field, id string) error

func NewReverseBoltCursor

func NewReverseBoltCursor(cursor *bbolt.Cursor) ast.SeekableSetCursor

func NewTypedForwardBoltCursor

func NewTypedForwardBoltCursor(cursor *bbolt.Cursor, fieldType FieldType) ast.SeekableSetCursor

func NewTypedReverseBoltCursor

func NewTypedReverseBoltCursor(cursor *bbolt.Cursor, fieldType FieldType) ast.SeekableSetCursor

func PrependFieldType

func PrependFieldType(fieldType FieldType, value []byte) []byte

func Traverse

func Traverse(tx *bbolt.Tx, visitor BoltVisitor)

func ValidateDeleted

func ValidateDeleted(tx *bbolt.Tx, id string) error

func ValidateSymbolsArePublic

func ValidateSymbolsArePublic(query ast.Query, store ListStore) error

Types

type BaseBoltCursor

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

func (*BaseBoltCursor) Current

func (f *BaseBoltCursor) Current() []byte

func (*BaseBoltCursor) IsValid

func (f *BaseBoltCursor) IsValid() bool

type BaseExtEntity

type BaseExtEntity struct {
	Id string
	ExtEntityFields
}

func NewExtEntity

func NewExtEntity(id string, tags map[string]interface{}) *BaseExtEntity

func (*BaseExtEntity) GetId

func (entity *BaseExtEntity) GetId() string

func (*BaseExtEntity) SetId

func (entity *BaseExtEntity) SetId(id string)

type BaseStore

type BaseStore struct {
	Indexer

	events.EventEmmiter
	// contains filtered or unexported fields
}

func NewBaseStore

func NewBaseStore(entityType string, entityNotFoundF func(id string) error, basePath ...string) *BaseStore

func NewChildBaseStore added in v0.11.2

func NewChildBaseStore(parent CrudStore, entityNotFoundF func(id string) error, basePath ...string) *BaseStore

func (*BaseStore) AddDeleteHandler

func (store *BaseStore) AddDeleteHandler(handler EntityChangeHandler)

func (*BaseStore) AddExtEntitySymbols

func (store *BaseStore) AddExtEntitySymbols()

func (*BaseStore) AddFkSetSymbol

func (store *BaseStore) AddFkSetSymbol(name string, listStore ListStore) EntitySetSymbol

func (*BaseStore) AddFkSymbol

func (store *BaseStore) AddFkSymbol(name string, linkedStore ListStore, prefix ...string) EntitySymbol

func (*BaseStore) AddFkSymbolWithKey

func (store *BaseStore) AddFkSymbolWithKey(name string, key string, linkedStore ListStore, prefix ...string) EntitySymbol

func (*BaseStore) AddIdSymbol

func (store *BaseStore) AddIdSymbol(name string, nodeType ast.NodeType) EntitySymbol

func (*BaseStore) AddLinkCollection

func (store *BaseStore) AddLinkCollection(local EntitySymbol, remote EntitySymbol) LinkCollection

func (*BaseStore) AddMapSymbol

func (store *BaseStore) AddMapSymbol(name string, nodeType ast.NodeType, key string, prefix ...string)

func (*BaseStore) AddRefCountedLinkCollection added in v0.11.13

func (store *BaseStore) AddRefCountedLinkCollection(local EntitySymbol, remote EntitySymbol) RefCountedLinkCollection

func (*BaseStore) AddSetSymbol

func (store *BaseStore) AddSetSymbol(name string, nodeType ast.NodeType) EntitySetSymbol

func (*BaseStore) AddSymbol

func (store *BaseStore) AddSymbol(name string, nodeType ast.NodeType, prefix ...string) EntitySymbol

func (*BaseStore) AddSymbolWithKey

func (store *BaseStore) AddSymbolWithKey(name string, nodeType ast.NodeType, key string, prefix ...string) EntitySymbol

func (*BaseStore) BaseLoadOneById

func (store *BaseStore) BaseLoadOneById(tx *bbolt.Tx, id string, entity Entity) (bool, error)

func (*BaseStore) BaseLoadOneByQuery

func (store *BaseStore) BaseLoadOneByQuery(tx *bbolt.Tx, query string, entity Entity) (bool, error)

func (*BaseStore) BaseLoadOneChildById

func (store *BaseStore) BaseLoadOneChildById(tx *bbolt.Tx, id string, childId string, entity Entity) (bool, error)

func (*BaseStore) CheckIntegrity added in v0.11.16

func (store *BaseStore) CheckIntegrity(tx *bbolt.Tx, fix bool, errorSink func(err error, fixed bool)) error

func (*BaseStore) CleanupExternal

func (store *BaseStore) CleanupExternal(ctx MutateContext, id string) error

func (*BaseStore) Create

func (store *BaseStore) Create(ctx MutateContext, entity Entity) error

func (*BaseStore) CreateChild

func (store *BaseStore) CreateChild(ctx MutateContext, id string, entity Entity) error

func (*BaseStore) DeleteById

func (store *BaseStore) DeleteById(ctx MutateContext, id string) error

func (*BaseStore) DeleteChild

func (store *BaseStore) DeleteChild(ctx MutateContext, id string, entity Entity) error

func (*BaseStore) DeleteWhere

func (store *BaseStore) DeleteWhere(ctx MutateContext, query string) error

func (*BaseStore) Extended

func (store *BaseStore) Extended() *BaseStore

func (*BaseStore) FindMatching

func (*BaseStore) FindMatching(tx *bbolt.Tx, readIndex SetReadIndex, values []string) []string

func (*BaseStore) FindMatchingAnyOf

func (*BaseStore) FindMatchingAnyOf(tx *bbolt.Tx, readIndex SetReadIndex, values []string) []string

func (*BaseStore) GetEntitiesBucket

func (store *BaseStore) GetEntitiesBucket(tx *bbolt.Tx) *TypedBucket

func (*BaseStore) GetEntityBucket

func (store *BaseStore) GetEntityBucket(tx *bbolt.Tx, id []byte) *TypedBucket

func (*BaseStore) GetEntityType

func (store *BaseStore) GetEntityType() string

func (*BaseStore) GetLinkCollection

func (store *BaseStore) GetLinkCollection(name string) LinkCollection

func (*BaseStore) GetOrCreateEntitiesBucket

func (store *BaseStore) GetOrCreateEntitiesBucket(tx *bbolt.Tx) *TypedBucket

func (*BaseStore) GetOrCreateEntityBucket

func (store *BaseStore) GetOrCreateEntityBucket(tx *bbolt.Tx, id []byte) *TypedBucket

func (*BaseStore) GetParentStore

func (store *BaseStore) GetParentStore() CrudStore

func (*BaseStore) GetPublicSymbols

func (store *BaseStore) GetPublicSymbols() []string

func (*BaseStore) GetRefCountedLinkCollection added in v0.11.13

func (store *BaseStore) GetRefCountedLinkCollection(name string) RefCountedLinkCollection

func (*BaseStore) GetRelatedEntitiesCursor

func (store *BaseStore) GetRelatedEntitiesCursor(tx *bbolt.Tx, id string, field string, forward bool) ast.SetCursor

func (*BaseStore) GetRelatedEntitiesIdList

func (store *BaseStore) GetRelatedEntitiesIdList(tx *bbolt.Tx, id string, field string) []string

func (*BaseStore) GetSetSymbolTypes

func (store *BaseStore) GetSetSymbolTypes(name string) ast.SymbolTypes

func (*BaseStore) GetSingularEntityType

func (store *BaseStore) GetSingularEntityType() string

func (*BaseStore) GetSymbol

func (store *BaseStore) GetSymbol(name string) EntitySymbol

GetSymbol returns the symbol for the given name, or nil if the symbol doesn't exist

func (*BaseStore) GetSymbolType

func (store *BaseStore) GetSymbolType(name string) (ast.NodeType, bool)

func (*BaseStore) GetValue

func (store *BaseStore) GetValue(tx *bbolt.Tx, id []byte, path ...string) []byte

func (*BaseStore) GetValueCursor

func (store *BaseStore) GetValueCursor(tx *bbolt.Tx, id []byte, path ...string) *bbolt.Cursor

func (*BaseStore) GrantSymbols

func (store *BaseStore) GrantSymbols(child ListStore)

func (*BaseStore) InitImpl

func (store *BaseStore) InitImpl(impl CrudStore)

func (*BaseStore) IsChildStore

func (store *BaseStore) IsChildStore() bool

func (*BaseStore) IsEntityPresent

func (store *BaseStore) IsEntityPresent(tx *bbolt.Tx, id string) bool

func (*BaseStore) IsEntityRelated

func (store *BaseStore) IsEntityRelated(tx *bbolt.Tx, id string, field string, relatedEntityId string) bool

func (*BaseStore) IsExtended added in v0.14.0

func (store *BaseStore) IsExtended() bool

func (*BaseStore) IsSet

func (store *BaseStore) IsSet(name string) (bool, bool)

func (*BaseStore) IterateIds added in v0.11.13

func (store *BaseStore) IterateIds(tx *bbolt.Tx, filter ast.BoolNode) ast.SeekableSetCursor

func (*BaseStore) IterateValidIds added in v0.11.19

func (store *BaseStore) IterateValidIds(tx *bbolt.Tx, filter ast.BoolNode) ast.SetCursor

func (*BaseStore) IteratorMatchingAllOf

func (*BaseStore) IteratorMatchingAllOf(readIndex SetReadIndex, values []string) ast.SetCursorProvider

func (*BaseStore) IteratorMatchingAnyOf

func (*BaseStore) IteratorMatchingAnyOf(readIndex SetReadIndex, values []string) ast.SetCursorProvider

func (*BaseStore) ListChildIds

func (store *BaseStore) ListChildIds(tx *bbolt.Tx, id string, childType string) []string

func (*BaseStore) MapSymbol

func (store *BaseStore) MapSymbol(name string, mapper SymbolMapper)

func (*BaseStore) NewEntitySymbol

func (store *BaseStore) NewEntitySymbol(name string, nodeType ast.NodeType) EntitySymbol

func (*BaseStore) NewIndexingContext added in v0.11.8

func (store *BaseStore) NewIndexingContext(isCreate bool, ctx MutateContext, id string, holder errorz.ErrorHolder) *IndexingContext

func (*BaseStore) NewRowComparator

func (store *BaseStore) NewRowComparator(sort []ast.SortField) (RowComparator, error)

func (*BaseStore) NewScanner

func (store *BaseStore) NewScanner(sort []ast.SortField) Scanner

func (*BaseStore) QueryIds

func (store *BaseStore) QueryIds(tx *bbolt.Tx, queryString string) ([]string, int64, error)

func (*BaseStore) QueryIdsC

func (store *BaseStore) QueryIdsC(tx *bbolt.Tx, query ast.Query) ([]string, int64, error)

func (*BaseStore) QueryIdsf

func (store *BaseStore) QueryIdsf(tx *bbolt.Tx, queryString string, args ...interface{}) ([]string, int64, error)

func (*BaseStore) QueryWithCursorC

func (store *BaseStore) QueryWithCursorC(tx *bbolt.Tx, cursorProvider ast.SetCursorProvider, query ast.Query) ([]string, int64, error)

func (*BaseStore) Update

func (store *BaseStore) Update(ctx MutateContext, entity Entity, checker FieldChecker) error

func (*BaseStore) UpdateChild

func (store *BaseStore) UpdateChild(ctx MutateContext, id string, entity Entity, checker FieldChecker) error

type BaseTestContext

type BaseTestContext struct {
	require.Assertions

	ReferenceTime time.Time
	Impl          TestContext
	// contains filtered or unexported fields
}

func NewTestContext

func NewTestContext(t *testing.T) *BaseTestContext

func (*BaseTestContext) Cleanup

func (ctx *BaseTestContext) Cleanup()

func (*BaseTestContext) Create

func (ctx *BaseTestContext) Create(entity Entity) error

func (*BaseTestContext) CreateTags

func (ctx *BaseTestContext) CreateTags() map[string]interface{}

func (*BaseTestContext) Delete

func (ctx *BaseTestContext) Delete(entity Entity) error

func (*BaseTestContext) GetDb

func (ctx *BaseTestContext) GetDb() Db

func (*BaseTestContext) GetDbFile

func (ctx *BaseTestContext) GetDbFile() *os.File

func (*BaseTestContext) GetRelatedIds

func (ctx *BaseTestContext) GetRelatedIds(entity Entity, field string) []string

func (*BaseTestContext) GetStoreForEntity

func (ctx *BaseTestContext) GetStoreForEntity(entity Entity) CrudStore

func (*BaseTestContext) InitDbFile

func (ctx *BaseTestContext) InitDbFile()

func (*BaseTestContext) NextTest

func (ctx *BaseTestContext) NextTest(t *testing.T)

func (*BaseTestContext) Patch added in v0.15.12

func (ctx *BaseTestContext) Patch(entity Entity, checker FieldChecker) error

func (*BaseTestContext) Reload

func (ctx *BaseTestContext) Reload(entity Entity) error

func (*BaseTestContext) RequireCreate

func (ctx *BaseTestContext) RequireCreate(entity Entity)

func (*BaseTestContext) RequireDelete

func (ctx *BaseTestContext) RequireDelete(entity Entity)

func (*BaseTestContext) RequirePatch added in v0.15.12

func (ctx *BaseTestContext) RequirePatch(entity Entity, checker FieldChecker)

func (*BaseTestContext) RequireReload

func (ctx *BaseTestContext) RequireReload(entity Entity)

func (*BaseTestContext) RequireUpdate

func (ctx *BaseTestContext) RequireUpdate(entity Entity)

func (*BaseTestContext) Update

func (ctx *BaseTestContext) Update(entity Entity) error

func (*BaseTestContext) ValidateBaseline

func (ctx *BaseTestContext) ValidateBaseline(entity ExtEntity, opts ...cmp.Option)

func (*BaseTestContext) ValidateDeleted

func (ctx *BaseTestContext) ValidateDeleted(id string)

func (*BaseTestContext) ValidateUpdated

func (ctx *BaseTestContext) ValidateUpdated(entity ExtEntity)

type BoltVisitor

type BoltVisitor interface {
	VisitBucket(path string, key []byte, bucket *bbolt.Bucket) bool
	VisitKeyValue(path string, key, value []byte) bool
}

type CascadeType added in v0.13.0

type CascadeType int

type CommitAction added in v0.15.0

type CommitAction interface {
	Exec()
}

type Constrained added in v0.15.22

type Constrained interface {
	AddConstraint(constraint Constraint)
}

type Constraint

type Constraint interface {
	ProcessBeforeUpdate(ctx *IndexingContext)
	ProcessAfterUpdate(ctx *IndexingContext)
	ProcessBeforeDelete(ctx *IndexingContext)
	ProcessAfterDelete(ctx *IndexingContext)
	Initialize(tx *bbolt.Tx, errorHolder errorz.ErrorHolder)
	CheckIntegrity(tx *bbolt.Tx, fix bool, errorSink func(err error, fixed bool)) error
}

type CrudStore

type CrudStore interface {
	ListStore
	Constrained

	GetParentStore() CrudStore
	AddLinkCollection(local EntitySymbol, remove EntitySymbol) LinkCollection
	AddRefCountedLinkCollection(local EntitySymbol, remove EntitySymbol) RefCountedLinkCollection
	GetLinkCollection(name string) LinkCollection
	GetRefCountedLinkCollection(name string) RefCountedLinkCollection

	Create(ctx MutateContext, entity Entity) error
	Update(ctx MutateContext, entity Entity, checker FieldChecker) error
	DeleteById(ctx MutateContext, id string) error
	DeleteWhere(ctx MutateContext, query string) error
	CleanupExternal(ctx MutateContext, id string) error

	CreateChild(ctx MutateContext, parentId string, entity Entity) error
	UpdateChild(ctx MutateContext, parentId string, entity Entity, checker FieldChecker) error
	DeleteChild(ctx MutateContext, parentId string, entity Entity) error
	ListChildIds(tx *bbolt.Tx, parentId string, childType string) []string

	BaseLoadOneById(tx *bbolt.Tx, id string, entity Entity) (bool, error)
	BaseLoadOneByQuery(tx *bbolt.Tx, query string, entity Entity) (bool, error)
	BaseLoadOneChildById(tx *bbolt.Tx, id string, childId string, entity Entity) (bool, error)
	NewStoreEntity() Entity

	AddDeleteHandler(handler EntityChangeHandler)
	NewIndexingContext(isCreate bool, ctx MutateContext, id string, holder errorz.ErrorHolder) *IndexingContext

	CheckIntegrity(tx *bbolt.Tx, fix bool, errorSink func(err error, fixed bool)) error

	events.EventEmmiter
}

type Db

type Db interface {
	io.Closer
	Update(fn func(tx *bbolt.Tx) error) error
	Batch(fn func(tx *bbolt.Tx) error) error
	View(fn func(tx *bbolt.Tx) error) error
	RootBucket(tx *bbolt.Tx) (*bbolt.Bucket, error)

	// Snapshot makes a copy of the bolt file
	Snapshot(tx *bbolt.Tx) error
}

type Entity

type Entity interface {
	GetId() string
	SetId(id string)
	LoadValues(store CrudStore, bucket *TypedBucket)
	SetValues(ctx *PersistContext)
	GetEntityType() string
}

type EntityChangeHandler

type EntityChangeHandler func(ctx MutateContext, entityId string) error

type EntityChangeHandlers

type EntityChangeHandlers struct {
	atomic.Value
	sync.Mutex
}

func (*EntityChangeHandlers) Add

func (handlers *EntityChangeHandlers) Add(handler EntityChangeHandler)

func (*EntityChangeHandlers) Get

func (handlers *EntityChangeHandlers) Get() []EntityChangeHandler

func (*EntityChangeHandlers) Handle

func (handlers *EntityChangeHandlers) Handle(ctx MutateContext, entityId string) error

type EntitySetSymbol

type EntitySetSymbol interface {
	EntitySymbol
	GetRuntimeSymbol() RuntimeEntitySetSymbol
	EvalStringList(tx *bbolt.Tx, key []byte) []string
	Map(tx *bbolt.Tx, key []byte, f func(ctx *MapContext)) error
}

type EntitySymbol

type EntitySymbol interface {
	GetStore() ListStore
	GetLinkedType() ListStore
	GetPath() []string
	GetType() ast.NodeType
	GetName() string
	IsSet() bool
	Eval(tx *bbolt.Tx, rowId []byte) (FieldType, []byte)
}

type ExtEntity

type ExtEntity interface {
	Entity
	GetCreatedAt() time.Time
	GetUpdatedAt() time.Time
	GetTags() map[string]interface{}

	SetCreatedAt(createdAt time.Time)
	SetUpdatedAt(updatedAt time.Time)
	SetTags(tags map[string]interface{})
}

type ExtEntityFields

type ExtEntityFields struct {
	CreatedAt time.Time
	UpdatedAt time.Time
	Tags      map[string]interface{}
	Migrate   bool
}

func (*ExtEntityFields) CreateBaseValues

func (entity *ExtEntityFields) CreateBaseValues(bucket *TypedBucket)

func (*ExtEntityFields) GetCreatedAt

func (entity *ExtEntityFields) GetCreatedAt() time.Time

func (*ExtEntityFields) GetTags

func (entity *ExtEntityFields) GetTags() map[string]interface{}

func (*ExtEntityFields) GetUpdatedAt

func (entity *ExtEntityFields) GetUpdatedAt() time.Time

func (*ExtEntityFields) LoadBaseValues

func (entity *ExtEntityFields) LoadBaseValues(bucket *TypedBucket)

func (*ExtEntityFields) SetBaseValues

func (entity *ExtEntityFields) SetBaseValues(ctx *PersistContext)

func (*ExtEntityFields) SetCreatedAt

func (entity *ExtEntityFields) SetCreatedAt(createdAt time.Time)

func (*ExtEntityFields) SetTags

func (entity *ExtEntityFields) SetTags(tags map[string]interface{})

func (*ExtEntityFields) SetUpdatedAt

func (entity *ExtEntityFields) SetUpdatedAt(updatedAt time.Time)

func (*ExtEntityFields) UpdateBaseValues

func (entity *ExtEntityFields) UpdateBaseValues(bucket *TypedBucket, fieldChecker FieldChecker)

type FieldChecker

type FieldChecker interface {
	IsUpdated(string) bool
}

func NewMappedFieldChecker

func NewMappedFieldChecker(checker FieldChecker, mappings map[string]string) FieldChecker

type FieldType

type FieldType byte
const (
	TypeBool    FieldType = 1
	TypeInt32   FieldType = 2
	TypeInt64   FieldType = 3
	TypeFloat64 FieldType = 4
	TypeString  FieldType = 5
	TypeTime    FieldType = 6
	TypeNil     FieldType = 7
)

func GetTypeAndValue

func GetTypeAndValue(bytes []byte) (FieldType, []byte)

type FieldTypeAndValue

type FieldTypeAndValue struct {
	FieldType
	Value []byte
}

type ForwardBoltCursor

type ForwardBoltCursor struct {
	BaseBoltCursor
}

func (*ForwardBoltCursor) Next

func (f *ForwardBoltCursor) Next()

func (*ForwardBoltCursor) Seek added in v0.11.13

func (f *ForwardBoltCursor) Seek(val []byte)

type Indexer

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

func NewIndexer

func NewIndexer(basePath ...string) *Indexer

func (*Indexer) AddConstraint added in v0.15.22

func (indexer *Indexer) AddConstraint(constraint Constraint)

func (*Indexer) AddFkConstraint added in v0.13.0

func (indexer *Indexer) AddFkConstraint(symbol EntitySymbol, nullable bool, cascade CascadeType)

func (*Indexer) AddFkIndex

func (indexer *Indexer) AddFkIndex(symbol EntitySymbol, fkSymbol EntitySetSymbol)

func (*Indexer) AddNullableFkIndex

func (indexer *Indexer) AddNullableFkIndex(symbol EntitySymbol, fkSymbol EntitySetSymbol)

func (*Indexer) AddNullableUniqueIndex added in v0.13.0

func (indexer *Indexer) AddNullableUniqueIndex(symbol EntitySymbol) ReadIndex

func (*Indexer) AddSetIndex

func (indexer *Indexer) AddSetIndex(symbol EntitySetSymbol) SetReadIndex

func (*Indexer) AddUniqueIndex

func (indexer *Indexer) AddUniqueIndex(symbol EntitySymbol) ReadIndex

func (*Indexer) InitializeIndexes

func (indexer *Indexer) InitializeIndexes(tx *bbolt.Tx, errorHolder errorz.ErrorHolder)

type IndexingContext

type IndexingContext struct {
	Parent *IndexingContext
	*Indexer
	IsCreate   bool
	Ctx        MutateContext
	RowId      []byte
	ErrHolder  errorz.ErrorHolder
	AtomStates map[Constraint][]byte
	// contains filtered or unexported fields
}

func (*IndexingContext) ProcessAfterDelete added in v0.15.22

func (ctx *IndexingContext) ProcessAfterDelete()

func (*IndexingContext) ProcessAfterUpdate added in v0.11.8

func (ctx *IndexingContext) ProcessAfterUpdate()

func (*IndexingContext) ProcessBeforeDelete added in v0.15.22

func (ctx *IndexingContext) ProcessBeforeDelete()

func (*IndexingContext) ProcessBeforeUpdate added in v0.11.8

func (ctx *IndexingContext) ProcessBeforeUpdate()

func (*IndexingContext) Tx

func (ctx *IndexingContext) Tx() *bbolt.Tx

type LinkCollection

type LinkCollection interface {
	AddLinks(tx *bbolt.Tx, id string, keys ...string) error
	AddLink(tx *bbolt.Tx, id []byte, key []byte) (bool, error)
	RemoveLinks(tx *bbolt.Tx, id string, keys ...string) error
	RemoveLink(tx *bbolt.Tx, id []byte, keys []byte) (bool, error)
	SetLinks(tx *bbolt.Tx, id string, keys []string) error
	GetLinks(tx *bbolt.Tx, id string) []string
	IterateLinks(tx *bbolt.Tx, id []byte) ast.SeekableSetCursor
	IsLinked(tx *bbolt.Tx, id, relatedId []byte) bool
	EntityDeleted(tx *bbolt.Tx, id string) error
	GetFieldSymbol() EntitySymbol
	GetLinkedSymbol() EntitySymbol
	CheckIntegrity(tx *bbolt.Tx, fix bool, errorSink func(err error, fixed bool)) error
}

type LinkedSetSymbol

type LinkedSetSymbol struct {
	EntitySymbol
}
func (symbol *LinkedSetSymbol) AddCompoundLink(tx *bbolt.Tx, id string, linkIds []string) error
func (symbol *LinkedSetSymbol) AddLink(tx *bbolt.Tx, id []byte, link []byte) error
func (symbol *LinkedSetSymbol) AddLinkS(tx *bbolt.Tx, id string, link string) error

func (*LinkedSetSymbol) IsLinked added in v0.11.16

func (symbol *LinkedSetSymbol) IsLinked(tx *bbolt.Tx, id []byte, link []byte) bool
func (symbol *LinkedSetSymbol) RemoveCompoundLink(tx *bbolt.Tx, id string, linkIds []string) error
func (symbol *LinkedSetSymbol) RemoveLink(tx *bbolt.Tx, id []byte, link []byte) error

type ListStore

type ListStore interface {
	ast.SymbolTypes

	GetEntityType() string
	GetSingularEntityType() string
	GetEntitiesBucket(tx *bbolt.Tx) *TypedBucket
	GetOrCreateEntitiesBucket(tx *bbolt.Tx) *TypedBucket
	GetEntityBucket(tx *bbolt.Tx, id []byte) *TypedBucket
	GetOrCreateEntityBucket(tx *bbolt.Tx, id []byte) *TypedBucket
	GetValue(tx *bbolt.Tx, id []byte, path ...string) []byte
	GetValueCursor(tx *bbolt.Tx, id []byte, path ...string) *bbolt.Cursor
	IsChildStore() bool
	IsEntityPresent(tx *bbolt.Tx, id string) bool
	IsExtended() bool

	GetSymbol(name string) EntitySymbol
	MapSymbol(name string, wrapper SymbolMapper)
	GrantSymbols(child ListStore)

	AddIdSymbol(name string, nodeType ast.NodeType) EntitySymbol
	AddSymbol(name string, nodeType ast.NodeType, path ...string) EntitySymbol
	AddFkSymbol(name string, linkedType ListStore, path ...string) EntitySymbol
	AddSymbolWithKey(name string, nodeType ast.NodeType, key string, path ...string) EntitySymbol
	AddFkSymbolWithKey(name string, key string, linkedType ListStore, path ...string) EntitySymbol
	AddMapSymbol(name string, nodeType ast.NodeType, key string, path ...string)
	AddSetSymbol(name string, nodeType ast.NodeType) EntitySetSymbol
	AddFkSetSymbol(name string, linkedType ListStore) EntitySetSymbol
	NewEntitySymbol(name string, nodeType ast.NodeType) EntitySymbol
	AddExtEntitySymbols()

	NewRowComparator(sort []ast.SortField) (RowComparator, error)
	GetPublicSymbols() []string

	FindMatching(tx *bbolt.Tx, readIndex SetReadIndex, values []string) []string

	GetRelatedEntitiesIdList(tx *bbolt.Tx, id string, field string) []string
	GetRelatedEntitiesCursor(tx *bbolt.Tx, id string, field string, forward bool) ast.SetCursor
	IsEntityRelated(tx *bbolt.Tx, id string, field string, relatedEntityId string) bool

	// QueryIds compiles the query and runs it against the store
	QueryIds(tx *bbolt.Tx, query string) ([]string, int64, error)

	// QueryIdsf compiles the query with the given params and runs it against the store
	QueryIdsf(tx *bbolt.Tx, query string, args ...interface{}) ([]string, int64, error)

	// QueryIdsC executes a compile query against the store
	QueryIdsC(tx *bbolt.Tx, query ast.Query) ([]string, int64, error)

	QueryWithCursorC(tx *bbolt.Tx, cursorProvider ast.SetCursorProvider, query ast.Query) ([]string, int64, error)

	IterateIds(tx *bbolt.Tx, filter ast.BoolNode) ast.SeekableSetCursor

	// Skips non-present entities in extended stores
	IterateValidIds(tx *bbolt.Tx, filter ast.BoolNode) ast.SetCursor
	// contains filtered or unexported methods
}

type MapContext

type MapContext struct {
	errorz.ErrorHolderImpl
	// contains filtered or unexported fields
}

func (*MapContext) Delete

func (ctx *MapContext) Delete()

func (*MapContext) Replace

func (ctx *MapContext) Replace(fieldType FieldType, val []byte)

func (*MapContext) ReplaceS

func (ctx *MapContext) ReplaceS(val string)

func (*MapContext) Stop

func (ctx *MapContext) Stop()

func (*MapContext) Type

func (ctx *MapContext) Type() FieldType

func (*MapContext) Value

func (ctx *MapContext) Value() []byte

func (*MapContext) ValueS

func (ctx *MapContext) ValueS() string

type MapFieldChecker

type MapFieldChecker map[string]struct{}

func (MapFieldChecker) IsUpdated

func (m MapFieldChecker) IsUpdated(name string) bool

type MappedFieldChecker

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

func (*MappedFieldChecker) IsUpdated

func (f *MappedFieldChecker) IsUpdated(field string) bool

type MigrationManager

type MigrationManager interface {
	Migrate(component string, targetVersion int, migrator Migrator) error
}

func NewMigratorManager

func NewMigratorManager(db Db) MigrationManager

type MigrationStep

type MigrationStep struct {
	errorz.ErrorHolderImpl
	Component      string
	Ctx            MutateContext
	CurrentVersion int
}

type Migrator

type Migrator func(step *MigrationStep) int

type MutateContext

type MutateContext interface {
	Tx() *bbolt.Tx
	AddEvent(em events.EventEmmiter, name events.EventName, entity Entity)
}

func NewMutateContext

func NewMutateContext(tx *bbolt.Tx) MutateContext

type NamedExtEntity

type NamedExtEntity interface {
	ExtEntity
	GetName() string
}

type NotNilStringMapper

type NotNilStringMapper struct {
}

func (NotNilStringMapper) Map

func (n NotNilStringMapper) Map(_ EntitySymbol, fieldType FieldType, value []byte) (FieldType, []byte)

type PersistContext

type PersistContext struct {
	MutateContext
	Id           string
	Store        CrudStore
	Bucket       *TypedBucket
	FieldChecker FieldChecker
	IsCreate     bool
}

func (*PersistContext) GetAndSetString

func (ctx *PersistContext) GetAndSetString(field string, value string) (*string, bool)

func (*PersistContext) GetAndSetStringList

func (ctx *PersistContext) GetAndSetStringList(field string, value []string) ([]string, bool)

func (*PersistContext) GetParentContext

func (ctx *PersistContext) GetParentContext() *PersistContext

func (*PersistContext) ProceedWithSet

func (ctx *PersistContext) ProceedWithSet(field string) bool

func (*PersistContext) SetBool

func (ctx *PersistContext) SetBool(field string, value bool)

func (*PersistContext) SetInt32

func (ctx *PersistContext) SetInt32(field string, value int32)

func (*PersistContext) SetInt64

func (ctx *PersistContext) SetInt64(field string, value int64)

func (*PersistContext) SetLinkedIds

func (ctx *PersistContext) SetLinkedIds(field string, value []string)

func (*PersistContext) SetMap

func (ctx *PersistContext) SetMap(field string, value map[string]interface{})

func (*PersistContext) SetRequiredString

func (ctx *PersistContext) SetRequiredString(field string, value string)

func (*PersistContext) SetString

func (ctx *PersistContext) SetString(field string, value string)

func (*PersistContext) SetStringList

func (ctx *PersistContext) SetStringList(field string, value []string)

func (*PersistContext) SetStringP

func (ctx *PersistContext) SetStringP(field string, value *string)

func (*PersistContext) SetTimeP

func (ctx *PersistContext) SetTimeP(field string, value *time.Time)

func (*PersistContext) WithFieldOverrides

func (ctx *PersistContext) WithFieldOverrides(overrides map[string]string)

type ReadIndex

type ReadIndex interface {
	Read(tx *bbolt.Tx, val []byte) []byte
}

type RecordNotFoundError

type RecordNotFoundError struct {
	EntityType string
	Field      string
	Id         string
}

func (*RecordNotFoundError) Error

func (err *RecordNotFoundError) Error() string

type RefCountedLinkCollection added in v0.11.13

type RefCountedLinkCollection interface {
	IncrementLinkCount(tx *bbolt.Tx, id []byte, key []byte) (int, error)
	DecrementLinkCount(tx *bbolt.Tx, id []byte, key []byte) (int, error)
	GetLinkCount(tx *bbolt.Tx, id []byte, relatedId []byte) *int32
	GetLinkCounts(tx *bbolt.Tx, id []byte, relatedId []byte) (*int32, *int32)
	SetLinkCount(tx *bbolt.Tx, id []byte, key []byte, count int) (*int32, *int32, error)
	EntityDeleted(tx *bbolt.Tx, id string) error
	IterateLinks(tx *bbolt.Tx, id []byte) ast.SeekableSetCursor
	GetFieldSymbol() EntitySymbol
	GetLinkedSymbol() EntitySymbol
}

type RefCountedLinkedSetSymbol added in v0.11.13

type RefCountedLinkedSetSymbol struct {
	EntitySymbol
}

type ReverseBoltCursor

type ReverseBoltCursor struct {
	BaseBoltCursor
}

func (*ReverseBoltCursor) Next

func (f *ReverseBoltCursor) Next()

func (*ReverseBoltCursor) Seek added in v0.11.13

func (f *ReverseBoltCursor) Seek(val []byte)

type Row

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

func (*Row) Compare

func (r *Row) Compare(other llrb.Comparable) int

type RowComparator

type RowComparator interface {
	Compare(rowId1, rowId2 RowCursor) int
}

type RowContext

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

type RowCursor

type RowCursor interface {
	CurrentRow() []byte
	Tx() *bbolt.Tx
}

type RuntimeEntitySetSymbol

type RuntimeEntitySetSymbol interface {
	EntitySymbol
	OpenCursor(tx *bbolt.Tx, rowId []byte) ast.SetCursor
}

type Scanner

type Scanner interface {
	Scan(tx *bbolt.Tx, query ast.Query) ([]string, int64, error)
	ScanCursor(tx *bbolt.Tx, cursorProvider ast.SetCursorProvider, query ast.Query) ([]string, int64, error)
}

type SetChangeListener

type SetChangeListener func(ctx MutateContext, rowId []byte, old []FieldTypeAndValue, new []FieldTypeAndValue, holder errorz.ErrorHolder)

type SetReadIndex

type SetReadIndex interface {
	GetSymbol() EntitySetSymbol
	Read(tx *bbolt.Tx, key []byte, f func(val []byte))
	ReadKeys(tx *bbolt.Tx, f func(val []byte))
	OpenValueCursor(tx *bbolt.Tx, key []byte, forward bool) ast.SetCursor
	OpenKeyCursor(tx *bbolt.Tx, forward bool) ast.SetCursor
	AddListener(listener SetChangeListener)
}

type SymbolMapper

type SymbolMapper interface {
	Map(source EntitySymbol, fieldType FieldType, value []byte) (FieldType, []byte)
}

type TestContext

type TestContext interface {
	GetDb() Db
	GetStoreForEntity(entity Entity) CrudStore
	NextTest(t *testing.T)
}

type TypedBucket

type TypedBucket struct {
	*bbolt.Bucket

	*errorz.ErrorHolderImpl
	// contains filtered or unexported fields
}

func ErrBucket

func ErrBucket(err error) *TypedBucket

func GetOrCreatePath

func GetOrCreatePath(tx *bbolt.Tx, path ...string) *TypedBucket

func Path

func Path(tx *bbolt.Tx, path ...string) *TypedBucket

func (*TypedBucket) CheckAndDeleteListEntry added in v0.11.13

func (bucket *TypedBucket) CheckAndDeleteListEntry(fieldType FieldType, value []byte) (bool, error)

func (*TypedBucket) CheckAndSetListEntry added in v0.11.13

func (bucket *TypedBucket) CheckAndSetListEntry(fieldType FieldType, value []byte) (bool, error)

func (*TypedBucket) Copy added in v0.11.4

func (bucket *TypedBucket) Copy(other *TypedBucket, filterF func(path []string) bool) error

func (*TypedBucket) DecrementLinkCount added in v0.11.13

func (bucket *TypedBucket) DecrementLinkCount(fieldType FieldType, value []byte) (int, error)

func (*TypedBucket) DeleteEntity

func (bucket *TypedBucket) DeleteEntity(id string)

func (*TypedBucket) DeleteListEntry

func (bucket *TypedBucket) DeleteListEntry(fieldType FieldType, value []byte) *TypedBucket

func (*TypedBucket) DeleteValue

func (bucket *TypedBucket) DeleteValue(key []byte) *TypedBucket

func (*TypedBucket) EmptyBucket

func (bucket *TypedBucket) EmptyBucket(name string) (*TypedBucket, error)

func (*TypedBucket) GetAndSetString

func (bucket *TypedBucket) GetAndSetString(name string, value string, fieldChecker FieldChecker) (*string, bool)

func (*TypedBucket) GetAndSetStringList

func (bucket *TypedBucket) GetAndSetStringList(name string, value []string, fieldChecker FieldChecker) ([]string, bool)

func (*TypedBucket) GetBool

func (bucket *TypedBucket) GetBool(name string) *bool

func (*TypedBucket) GetBoolWithDefault

func (bucket *TypedBucket) GetBoolWithDefault(name string, defaultValue bool) bool

func (*TypedBucket) GetBucket

func (bucket *TypedBucket) GetBucket(name string) *TypedBucket

func (*TypedBucket) GetBucketByKey added in v0.11.19

func (bucket *TypedBucket) GetBucketByKey(key []byte) *TypedBucket

func (*TypedBucket) GetFloat64

func (bucket *TypedBucket) GetFloat64(name string) *float64

func (*TypedBucket) GetInt32

func (bucket *TypedBucket) GetInt32(name string) *int32

func (*TypedBucket) GetInt32WithDefault

func (bucket *TypedBucket) GetInt32WithDefault(name string, defaultValue int32) int32

func (*TypedBucket) GetInt64

func (bucket *TypedBucket) GetInt64(name string) *int64

func (*TypedBucket) GetInt64WithDefault

func (bucket *TypedBucket) GetInt64WithDefault(name string, defaultValue int64) int64

func (*TypedBucket) GetLinkCount added in v0.11.13

func (bucket *TypedBucket) GetLinkCount(fieldType FieldType, value []byte) *int32

func (*TypedBucket) GetList added in v0.14.4

func (bucket *TypedBucket) GetList(name string) []interface{}

func (*TypedBucket) GetMap

func (bucket *TypedBucket) GetMap(name string) map[string]interface{}

func (*TypedBucket) GetOrCreateBucket

func (bucket *TypedBucket) GetOrCreateBucket(name string) *TypedBucket

func (*TypedBucket) GetOrCreatePath

func (bucket *TypedBucket) GetOrCreatePath(path ...string) *TypedBucket

func (*TypedBucket) GetParent

func (bucket *TypedBucket) GetParent() *TypedBucket

func (*TypedBucket) GetPath

func (bucket *TypedBucket) GetPath(path ...string) *TypedBucket

func (*TypedBucket) GetString

func (bucket *TypedBucket) GetString(name string) *string

func (*TypedBucket) GetStringList

func (bucket *TypedBucket) GetStringList(name string) []string

func (*TypedBucket) GetStringOrError

func (bucket *TypedBucket) GetStringOrError(name string) string

func (*TypedBucket) GetStringWithDefault

func (bucket *TypedBucket) GetStringWithDefault(name string, defaultValue string) string

func (*TypedBucket) GetTime

func (bucket *TypedBucket) GetTime(name string) *time.Time

func (*TypedBucket) GetTimeOrError

func (bucket *TypedBucket) GetTimeOrError(name string) time.Time

func (*TypedBucket) IncrementLinkCount added in v0.11.13

func (bucket *TypedBucket) IncrementLinkCount(fieldType FieldType, value []byte) (int, error)

func (*TypedBucket) IsKeyPresent

func (bucket *TypedBucket) IsKeyPresent(key []byte) bool

func (*TypedBucket) IsStringListEmpty

func (bucket *TypedBucket) IsStringListEmpty(name string) bool

func (*TypedBucket) IterateStringList added in v0.11.13

func (bucket *TypedBucket) IterateStringList() ast.SeekableSetCursor

func (*TypedBucket) OpenCursor

func (bucket *TypedBucket) OpenCursor(_ *bbolt.Tx, forward bool) ast.SetCursor

func (*TypedBucket) OpenSeekableCursor added in v0.11.13

func (bucket *TypedBucket) OpenSeekableCursor() ast.SeekableSetCursor

func (*TypedBucket) OpenTypedCursor

func (bucket *TypedBucket) OpenTypedCursor(_ *bbolt.Tx, forward bool) ast.SetCursor

func (*TypedBucket) ProceedWithSet

func (bucket *TypedBucket) ProceedWithSet(name string, checker FieldChecker) bool

func (*TypedBucket) PutList added in v0.14.4

func (bucket *TypedBucket) PutList(name string, value []interface{}, checker FieldChecker) *TypedBucket

func (*TypedBucket) PutMap

func (bucket *TypedBucket) PutMap(name string, value map[string]interface{}, checker FieldChecker, allowNested bool) *TypedBucket

func (*TypedBucket) PutValue

func (bucket *TypedBucket) PutValue(key []byte, value []byte) *TypedBucket

func (*TypedBucket) ReadStringList

func (bucket *TypedBucket) ReadStringList() []string

func (*TypedBucket) SetBool

func (bucket *TypedBucket) SetBool(name string, value bool, checker FieldChecker) *TypedBucket

func (*TypedBucket) SetFloat64

func (bucket *TypedBucket) SetFloat64(name string, value float64, fieldChecker FieldChecker) *TypedBucket

func (*TypedBucket) SetInt32

func (bucket *TypedBucket) SetInt32(name string, value int32, fieldChecker FieldChecker) *TypedBucket

func (*TypedBucket) SetInt64

func (bucket *TypedBucket) SetInt64(name string, value int64, fieldChecker FieldChecker) *TypedBucket

func (*TypedBucket) SetLinkCount added in v0.11.13

func (bucket *TypedBucket) SetLinkCount(fieldType FieldType, value []byte, count int) (*int32, error)

func (*TypedBucket) SetListEntry

func (bucket *TypedBucket) SetListEntry(fieldType FieldType, value []byte) *TypedBucket

func (*TypedBucket) SetNil

func (bucket *TypedBucket) SetNil(name string)

func (*TypedBucket) SetString

func (bucket *TypedBucket) SetString(name string, value string, fieldChecker FieldChecker) *TypedBucket

func (*TypedBucket) SetStringList

func (bucket *TypedBucket) SetStringList(name string, value []string, fieldChecker FieldChecker) *TypedBucket

func (*TypedBucket) SetStringP

func (bucket *TypedBucket) SetStringP(name string, value *string, fieldChecker FieldChecker) *TypedBucket

func (*TypedBucket) SetTime

func (bucket *TypedBucket) SetTime(name string, value time.Time, fieldChecker FieldChecker) *TypedBucket

func (*TypedBucket) SetTimeP

func (bucket *TypedBucket) SetTimeP(name string, value *time.Time, fieldChecker FieldChecker) *TypedBucket

func (*TypedBucket) Tx

func (bucket *TypedBucket) Tx() *bbolt.Tx

type TypedForwardBoltCursor

type TypedForwardBoltCursor struct {
	BaseBoltCursor
	// contains filtered or unexported fields
}

func (*TypedForwardBoltCursor) Next

func (f *TypedForwardBoltCursor) Next()

func (*TypedForwardBoltCursor) Seek added in v0.11.13

func (f *TypedForwardBoltCursor) Seek(val []byte)

type TypedReverseBoltCursor

type TypedReverseBoltCursor struct {
	BaseBoltCursor
	// contains filtered or unexported fields
}

func (*TypedReverseBoltCursor) Next

func (f *TypedReverseBoltCursor) Next()

func (*TypedReverseBoltCursor) Seek added in v0.11.13

func (f *TypedReverseBoltCursor) Seek(val []byte)

type ValidIdsCursors added in v0.11.19

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

func (*ValidIdsCursors) Current added in v0.11.19

func (cursor *ValidIdsCursors) Current() []byte

func (*ValidIdsCursors) IsExtendedDataPresent added in v0.11.19

func (cursor *ValidIdsCursors) IsExtendedDataPresent() bool

func (*ValidIdsCursors) IsValid added in v0.11.19

func (cursor *ValidIdsCursors) IsValid() bool

func (*ValidIdsCursors) Next added in v0.11.19

func (cursor *ValidIdsCursors) Next()

Jump to

Keyboard shortcuts

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