boltz

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2020 License: Apache-2.0 Imports: 29 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 MaxLinkedSetKeySize = 4096
View Source
const (
	SortMax = 5
)

Variables

View Source
var FieldTypeNames = map[FieldType]string{
	TypeBool:    "TypeBool",
	TypeInt32:   "TypeInt32",
	TypeInt64:   "TypeInt64",
	TypeFloat64: "TypeFloat64",
	TypeString:  "TypeString",
	TypeTime:    "TypeTime",
	TypeNil:     "TypeNil",
}

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 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 IsErrNotFoundErr

func IsErrNotFoundErr(err error) bool

func NewBoltCursor

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

func NewForwardBoltCursor

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

func NewNotFoundError

func NewNotFoundError(entityType, field, id string) error

func NewReverseBoltCursor

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

func NewTypedForwardBoltCursor

func NewTypedForwardBoltCursor(cursor *bbolt.Cursor) ast.SetCursor

func NewTypedReverseBoltCursor

func NewTypedReverseBoltCursor(cursor *bbolt.Cursor) ast.SetCursor

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) 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) 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) 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) IsSet

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

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) 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) 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) 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)

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 Constraint

type Constraint interface {
	ProcessBeforeUpdate(ctx *IndexingContext)
	ProcessAfterUpdate(ctx *IndexingContext)
	ProcessDelete(ctx *IndexingContext)
	Initialize(tx *bbolt.Tx, errorHolder errorz.ErrorHolder)
}

type CrudStore

type CrudStore interface {
	ListStore

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

	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)
	events.EventEmmiter
}

type Db

type Db interface {
	io.Closer
	Update(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()

type Indexer

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

func NewIndexer

func NewIndexer(basePath ...string) *Indexer

func (*Indexer) AddFkIndex

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

func (*Indexer) AddNullableFkIndex

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

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)

func (*Indexer) NewIndexingContext

func (indexer *Indexer) NewIndexingContext(isCreate bool, tx *bbolt.Tx, id string, holder errorz.ErrorHolder) *IndexingContext

func (*Indexer) ProcessAfterUpdate

func (indexer *Indexer) ProcessAfterUpdate(ctx *IndexingContext)

func (*Indexer) ProcessBeforeUpdate

func (indexer *Indexer) ProcessBeforeUpdate(ctx *IndexingContext)

func (*Indexer) ProcessDelete

func (indexer *Indexer) ProcessDelete(ctx *IndexingContext)

type IndexingContext

type IndexingContext struct {
	IsCreate  bool
	Tx        *bbolt.Tx
	RowId     []byte
	ErrHolder errorz.ErrorHolder
	// contains filtered or unexported fields
}

type LinkCollection

type LinkCollection interface {
	AddLinks(tx *bbolt.Tx, id string, keys ...string) error
	RemoveLinks(tx *bbolt.Tx, id string, keys ...string) error
	SetLinks(tx *bbolt.Tx, id string, keys []string) error
	GetLinks(tx *bbolt.Tx, id string) []string
	EntityDeleted(tx *bbolt.Tx, id string) error
	GetFieldSymbol() EntitySymbol
	GetLinkedSymbol() EntitySymbol
}

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 (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

	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)
	// 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 {
	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 ReverseBoltCursor

type ReverseBoltCursor struct {
	BaseBoltCursor
}

func (*ReverseBoltCursor) Next

func (f *ReverseBoltCursor) Next()

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(tx *bbolt.Tx, 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) 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) Extended

func (bucket *TypedBucket) Extended() *TypedBucket

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) 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) 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) IsKeyPresent

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

func (*TypedBucket) IsStringListEmpty

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

func (*TypedBucket) OpenCursor

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

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) PutMap

func (bucket *TypedBucket) PutMap(name string, value map[string]interface{}, checker FieldChecker) *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) 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
}

func (*TypedForwardBoltCursor) Next

func (f *TypedForwardBoltCursor) Next()

type TypedReverseBoltCursor

type TypedReverseBoltCursor struct {
	BaseBoltCursor
}

func (*TypedReverseBoltCursor) Next

func (f *TypedReverseBoltCursor) Next()

Jump to

Keyboard shortcuts

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