Documentation
¶
Overview ¶
Package entity contains all logic for entity definition, entity commands, entity events, and manipulation with entities.
Index ¶
- Constants
- func NewTypedCommands(commands map[TypeCommandKey]interface{})
- type Accessor
- type Command
- type CommandFunc
- type CommandKey
- type CommandProducer
- type CommandResult
- type CommandUpdate
- type CreatedEvent
- type Definition
- type Event
- type Executor
- type ExecutorProvider
- type FuncCommandProducer
- type Instance
- type Key
- type Query
- type Reference
- type Repository
- type Spec
- type TypeCommand
- type TypeCommandExecutionContext
- type TypeCommandFunc
- type TypeCommandKey
- type TypeFuncFunc
- type TypeFuncKey
- type UpdatedEvent
Constants ¶
View Source
const (
CommandUpdateKey = CommandKey("update")
)
Variables ¶
This section is empty.
Functions ¶
func NewTypedCommands ¶
func NewTypedCommands(commands map[TypeCommandKey]interface{})
Types ¶
type Accessor ¶
type Accessor interface { Get(id int64) (Instance, error) GetAll() ([]Instance, error) Find(attributes map[string]values.Value, orderBy []query.OrderClause) ([]Instance, error) FindByQuery(q Query) ([]Instance, error) Create(attrs interface{}) (Instance, error) InvokeCommand(id int64, key CommandKey, input values.Values) (output values.Values, err error) Delete(id int64) error InvokeTypeCommand(key TypeCommandKey, input interface{}, output interface{}) error }
type Command ¶
type Command struct { Key CommandKey Function CommandFunc InputFields field.StructType GetDefaultInputValuesFunction func(instance Instance) values.Values }
func (Command) ProduceCommand ¶
type CommandFunc ¶
type CommandFunc func(instance Instance, input values.Values) (CommandResult, error)
type CommandKey ¶
type CommandKey string
type CommandProducer ¶
type CommandResult ¶
type CommandUpdate ¶
func (CommandUpdate) ProduceCommand ¶
func (c CommandUpdate) ProduceCommand(spec *Spec) Command
type CreatedEvent ¶
type CreatedEvent struct {
Reference Reference
}
func (CreatedEvent) AffectedEntity ¶
func (e CreatedEvent) AffectedEntity() Reference
type Definition ¶
type Definition struct { // TODO: don't export, and don't allow/provide whole map access (mutability issue), provide GetXYZByKey TypeCommands map[TypeCommandKey]TypeCommand TypeFunctions map[TypeFuncKey]TypeFuncFunc // contains filtered or unexported fields }
func NewDefinition ¶
func NewDefinition(spec Spec) *Definition
func (*Definition) DisplayName ¶
func (t *Definition) DisplayName() func(Instance) string
func (*Definition) Fields ¶
func (t *Definition) Fields() field.StructType
func (*Definition) GetCommands ¶
func (t *Definition) GetCommands() map[CommandKey]Command
func (*Definition) GetName ¶
func (t *Definition) GetName() string
func (*Definition) GetNamePlural ¶
func (t *Definition) GetNamePlural() string
func (*Definition) Key ¶
func (t *Definition) Key() Key
type ExecutorProvider ¶
type FuncCommandProducer ¶
type FuncCommandProducer struct {
// contains filtered or unexported fields
}
func NewFuncCommand ¶
func NewFuncCommand(key CommandKey, f CommandFunc) *FuncCommandProducer
func (*FuncCommandProducer) ProduceCommand ¶
func (f *FuncCommandProducer) ProduceCommand(spec *Spec) Command
type Instance ¶
type Instance interface { Reference() Reference GetId() int64 SetId(id int64) GetRevision() int64 GetAllAttributes() values.Values SetAllAttributes(values values.Values) GetAttribute(name string) (value interface{}) SetAttribute(name string, value interface{}) DisplayName() string // TODO: this is wrong GetTableName() string }
type Query ¶
type Query struct { Root Key Where query.Expression SortBy []query.OrderClause }
type Reference ¶
func (*Reference) UnmarshalJSON ¶
type Repository ¶
type Repository interface { Store(entity Instance, events []interface{}) error Find() ([]Instance, error) Get(id int64) (Instance, error) Remove(instance Instance) error // TODO: query should be DTO with tree structure containing clauses/conditions FindByQuery(query string, params []interface{}, orderBy []query.OrderClause) []Instance }
Repository interface defines contract for entity persistence.
type Spec ¶
type Spec struct { Uname Key Name string NamePlural string Description string DisplayName func(Instance) string Fields field.StructType Commands []CommandProducer TypeCommands []TypeCommand TypeFunctions map[TypeFuncKey]TypeFuncFunc }
type TypeCommand ¶
type TypeCommand struct { Key TypeCommandKey Func TypeCommandFunc }
func NewTypedEntityTypeCommand ¶
func NewTypedEntityTypeCommand(key TypeCommandKey, function interface{}) TypeCommand
type TypeCommandExecutionContext ¶
type TypeCommandExecutionContext struct { EntityFactory func(values values.Values) Instance Repository Repository }
type TypeCommandFunc ¶
type TypeCommandKey ¶
type TypeCommandKey string
type TypeFuncFunc ¶
type TypeFuncKey ¶
type TypeFuncKey string
type UpdatedEvent ¶
type UpdatedEvent struct {
Reference Reference
}
func (UpdatedEvent) AffectedEntity ¶
func (e UpdatedEvent) AffectedEntity() Reference
Source Files
¶
Click to show internal directories.
Click to hide internal directories.