models

package
v0.23.34 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2023 License: Apache-2.0 Imports: 9 Imported by: 4

Documentation

Index

Constants

View Source
const (
	ListLimitMax      = 500
	ListOffsetMax     = 100000
	ListLimitDefault  = 10
	ListOffsetDefault = 0
)

Variables

This section is empty.

Functions

func ToApiError added in v0.18.0

func ToApiError(err error) *errorz.ApiError

Types

type BaseEntity

type BaseEntity struct {
	Id        string
	CreatedAt time.Time
	UpdatedAt time.Time
	Tags      map[string]interface{}
	IsSystem  bool
}

func (*BaseEntity) FillCommon

func (entity *BaseEntity) FillCommon(boltEntity boltz.ExtEntity)

func (*BaseEntity) GetCreatedAt

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

func (*BaseEntity) GetId

func (entity *BaseEntity) GetId() string

func (*BaseEntity) GetTags

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

func (*BaseEntity) GetUpdatedAt

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

func (*BaseEntity) IsSystemEntity added in v0.16.45

func (entity *BaseEntity) IsSystemEntity() bool

func (*BaseEntity) SetId

func (entity *BaseEntity) SetId(id string)

func (*BaseEntity) ToBoltBaseExtEntity added in v0.21.39

func (entity *BaseEntity) ToBoltBaseExtEntity() *boltz.BaseExtEntity

type BaseEntityManager added in v0.18.0

type BaseEntityManager[E boltz.ExtEntity] struct {
	Store boltz.EntityStore[E]
}

func (*BaseEntityManager[E]) GetListStore added in v0.23.0

func (ctrl *BaseEntityManager[E]) GetListStore() boltz.Store

func (*BaseEntityManager[E]) GetStore added in v0.18.0

func (ctrl *BaseEntityManager[E]) GetStore() boltz.EntityStore[E]

func (*BaseEntityManager[E]) ListWithTx added in v0.18.0

func (ctrl *BaseEntityManager[E]) ListWithTx(tx *bbolt.Tx, queryString string, resultHandler ListResultHandler) error

func (*BaseEntityManager[E]) PreparedListAssociatedWithTx added in v0.18.0

func (ctrl *BaseEntityManager[E]) PreparedListAssociatedWithTx(tx *bbolt.Tx, id, association string, query ast.Query, resultHandler ListResultHandler) error

func (*BaseEntityManager[E]) PreparedListIndexedWithTx added in v0.18.0

func (ctrl *BaseEntityManager[E]) PreparedListIndexedWithTx(tx *bbolt.Tx, cursorProvider ast.SetCursorProvider, query ast.Query, resultHandler ListResultHandler) error

func (*BaseEntityManager[E]) PreparedListWithTx added in v0.18.0

func (ctrl *BaseEntityManager[E]) PreparedListWithTx(tx *bbolt.Tx, query ast.Query, resultHandler ListResultHandler) error

func (*BaseEntityManager[E]) ValidateName added in v0.18.0

func (handler *BaseEntityManager[E]) ValidateName(db boltz.Db, boltEntity Named) error

func (*BaseEntityManager[E]) ValidateNameOnCreate added in v0.18.0

func (handler *BaseEntityManager[E]) ValidateNameOnCreate(tx *bbolt.Tx, entity interface{}) error

func (*BaseEntityManager[E]) ValidateNameOnUpdate added in v0.18.0

func (ctrl *BaseEntityManager[E]) ValidateNameOnUpdate(ctx boltz.MutateContext, updatedEntity, existingEntity boltz.Entity, checker boltz.FieldChecker) error

type Entity

type Entity interface {
	GetId() string
	SetId(string)
	GetCreatedAt() time.Time
	GetUpdatedAt() time.Time
	GetTags() map[string]interface{}
	IsSystemEntity() bool
}

type EntityListResult

type EntityListResult[T Entity] struct {
	Loader interface {
		BaseLoadInTx(tx *bbolt.Tx, id string) (T, error)
	}
	Entities []T
	QueryMetaData
}

func (*EntityListResult[T]) Collect

func (result *EntityListResult[T]) Collect(tx *bbolt.Tx, ids []string, queryMetaData *QueryMetaData) error

func (*EntityListResult[T]) GetEntities

func (result *EntityListResult[T]) GetEntities() []T

func (*EntityListResult[T]) GetMetaData

func (result *EntityListResult[T]) GetMetaData() *QueryMetaData

type EntityRetriever

type EntityRetriever[T Entity] interface {
	BaseLoad(id string) (T, error)
	BaseLoadInTx(tx *bbolt.Tx, id string) (T, error)

	BaseList(query string) (*EntityListResult[T], error)
	BasePreparedList(query ast.Query) (*EntityListResult[T], error)

	ListWithHandler(query string, handler ListResultHandler) error
	PreparedListWithHandler(query ast.Query, handler ListResultHandler) error

	PreparedListAssociatedWithHandler(id string, association string, query ast.Query, handler ListResultHandler) error

	GetListStore() boltz.Store

	// GetEntityTypeId returns a unique id for the entity type. Some entities may share a storage type, such
	// as fabric and edge services, and fabric and edge routers. However, they should have distinct entity type
	// ids, so we can figure out to which controller to route commands
	GetEntityTypeId() string
}

type ListResultHandler

type ListResultHandler func(tx *bbolt.Tx, ids []string, qmd *QueryMetaData) error

type NameIndexedStore added in v0.22.23

type NameIndexedStore interface {
	boltz.Store
	GetNameIndex() boltz.ReadIndex
}

type Named added in v0.18.0

type Named interface {
	GetName() string
}

type QueryMetaData

type QueryMetaData struct {
	Count            int64
	Limit            int64
	Offset           int64
	FilterableFields []string
}

Jump to

Keyboard shortcuts

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