Documentation ¶
Index ¶
- Constants
- func Options() *options
- type Adaptable
- type AssociationsHandler
- type BelongsTo
- type Collection
- func (collection *Collection) Adapter() Adaptable
- func (collection *Collection) Create(values helpers.H) *SingleResult
- func (collection *Collection) CreateWithOptions(values helpers.H, options *options) *SingleResult
- func (collection *Collection) List() *List
- func (collection *Collection) Name() string
- func (collection *Collection) New(values helpers.H) Modellable
- func (collection *Collection) Query() Queryable
- type Context
- func (context *Context) AssociationsHandler() *AssociationsHandler
- func (context *Context) Attributes() *helpers.Dictionary
- func (context *Context) Collection() *Collection
- func (context *Context) HooksHandler() *HooksHandler
- func (context *Context) Item() Modellable
- func (context *Context) SetItem(item Modellable)
- type CountResult
- type FindPredicate
- type FiniteStateMachine
- func (fsm *FiniteStateMachine) Equals(stateName string) bool
- func (fsm *FiniteStateMachine) GetActiveAgent() interface{}
- func (fsm *FiniteStateMachine) GetEndAt() int64
- func (fsm *FiniteStateMachine) GetName() string
- func (fsm *FiniteStateMachine) GoTo(stateName string, item Modellable)
- func (fsm *FiniteStateMachine) IsTurnExpired() bool
- func (fsm *FiniteStateMachine) RegisterState(stateName string) *StateHandler
- func (fsm *FiniteStateMachine) Run(item Modellable, dt float64)
- func (fsm *FiniteStateMachine) SetTurn(activeAgent Modellable, endAt time.Time)
- type HooksHandler
- func (handler *HooksHandler) ExecuteAfterCreateHook()
- func (handler *HooksHandler) ExecuteInitializeHook(values *helpers.Dictionary)
- func (handler *HooksHandler) ExecuteValidationHooks() error
- func (handler *HooksHandler) RegisterAfterCreateHook(afterCreateHook func())
- func (handler *HooksHandler) RegisterInitializeHook(initializeHook func(*helpers.Dictionary))
- func (handler *HooksHandler) RegisterValidationHook(validationHook Validator)
- type List
- func (list *List) Add(item Modellable)
- func (list *List) Count() int
- func (list *List) Find(predicate FindPredicate) Modellable
- func (list *List) FindAll(predicate FindPredicate) []Modellable
- func (list *List) FindByID(id string) Modellable
- func (list *List) First() Modellable
- func (list *List) Items() []Modellable
- type ListResults
- type Manager
- func (manager *Manager) Adapter(clientName string) Adaptable
- func (manager *Manager) Collection(clientName string, collectionName string) *Collection
- func (manager *Manager) CreateCollection(clientName string, collectionName string, newHandler NewHandler) *Collection
- func (manager *Manager) RegisterAdapter(clientName string, adapter Adaptable)
- func (manager *Manager) RegisterCollection(clientName string, collectionName string, newHandler NewHandler) *Collection
- func (manager *Manager) Setup()
- type Modellable
- type NewHandler
- type Queryable
- type SingleResult
- func (result *SingleResult) Error() error
- func (result *SingleResult) ErrorMessage() string
- func (result *SingleResult) Item() Modellable
- func (result *SingleResult) Set(item Modellable, err error, notFound bool)
- func (result *SingleResult) Status() string
- func (result *SingleResult) StatusError() bool
- func (result *SingleResult) StatusNotFound() bool
- func (result *SingleResult) StatusSuccess() bool
- type StateHandler
- type Validator
Constants ¶
const StatusError = "error"
StatusError used to represent errored query or operation
const StatusNotFound = "notfound"
StatusNotFound used to represent not found query
const StatusSuccess = "success"
StatusSuccess used to represent success query or operation
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Adaptable ¶ added in v0.0.46
type Adaptable interface { NewQuery(*Collection) Queryable RegisterCollection(string, *Collection) Collection(string) *Collection Collections() []*Collection }
Adaptable is the interface for all adapters implementing adapter's functionalities
type AssociationsHandler ¶ added in v0.1.0
type AssociationsHandler struct {
// contains filtered or unexported fields
}
func (*AssociationsHandler) RegisterBelongsTo ¶ added in v0.1.0
func (handler *AssociationsHandler) RegisterBelongsTo(collection *Collection) *BelongsTo
type BelongsTo ¶ added in v0.1.0
type BelongsTo struct {
// contains filtered or unexported fields
}
func (*BelongsTo) Item ¶ added in v0.1.0
func (belongsTo *BelongsTo) Item() Modellable
func (*BelongsTo) WithForeignKey ¶ added in v0.1.3
type Collection ¶
type Collection struct {
// contains filtered or unexported fields
}
Collection used to contain models
func (*Collection) Adapter ¶ added in v0.0.46
func (collection *Collection) Adapter() Adaptable
Adapter used to retrieve collection's adapter
func (*Collection) Create ¶
func (collection *Collection) Create(values helpers.H) *SingleResult
Create used to create item
func (*Collection) CreateWithOptions ¶ added in v0.1.1
func (collection *Collection) CreateWithOptions(values helpers.H, options *options) *SingleResult
CreateWithOptions used to create item with options
func (*Collection) List ¶ added in v0.0.51
func (collection *Collection) List() *List
List used to retrieve in-memory list
func (*Collection) Name ¶ added in v0.0.46
func (collection *Collection) Name() string
Name used to retrieve collection's name
func (*Collection) New ¶ added in v0.0.39
func (collection *Collection) New(values helpers.H) Modellable
New used to initialize item
func (*Collection) Query ¶ added in v0.0.39
func (collection *Collection) Query() Queryable
Query returns query wrapper for retrieving records in adapter
type Context ¶ added in v0.1.0
type Context struct {
// contains filtered or unexported fields
}
func (*Context) AssociationsHandler ¶ added in v0.1.0
func (context *Context) AssociationsHandler() *AssociationsHandler
func (*Context) Attributes ¶ added in v0.1.0
func (context *Context) Attributes() *helpers.Dictionary
func (*Context) Collection ¶ added in v0.1.0
func (context *Context) Collection() *Collection
func (*Context) HooksHandler ¶ added in v0.1.0
func (context *Context) HooksHandler() *HooksHandler
func (*Context) Item ¶ added in v0.1.0
func (context *Context) Item() Modellable
func (*Context) SetItem ¶ added in v0.1.0
func (context *Context) SetItem(item Modellable)
type CountResult ¶ added in v0.0.55
type CountResult struct {
// contains filtered or unexported fields
}
CountResult used to wrap count records result from query
func MakeCountResult ¶ added in v0.0.55
func MakeCountResult() *CountResult
MakeCountResult used to instantiate count result
func (*CountResult) Count ¶ added in v0.0.55
func (result *CountResult) Count() int64
Count use to retrieve result's count
func (*CountResult) Set ¶ added in v0.0.55
func (result *CountResult) Set(count int64, err error)
Set used to set result count and error
func (*CountResult) Status ¶ added in v0.0.55
func (result *CountResult) Status() string
Status used to retrieve result's status
func (*CountResult) StatusError ¶ added in v0.0.57
func (result *CountResult) StatusError() bool
StatusError used to check if operation is errored
func (*CountResult) StatusSuccess ¶ added in v0.0.57
func (result *CountResult) StatusSuccess() bool
StatusSuccess used to check if operation is success
type FindPredicate ¶ added in v0.0.21
type FindPredicate func(Modellable) bool
FindPredicate is alias for func(Modellable) bool
type FiniteStateMachine ¶
type FiniteStateMachine struct {
// contains filtered or unexported fields
}
FiniteStateMachine used to implement fsm
func MakeFiniteStateMachine ¶
func MakeFiniteStateMachine(defaultStateName string) *FiniteStateMachine
MakeFiniteStateMachine used to instantiate fsm
func (*FiniteStateMachine) Equals ¶
func (fsm *FiniteStateMachine) Equals(stateName string) bool
Equals used to compare fsm's state
func (*FiniteStateMachine) GetActiveAgent ¶
func (fsm *FiniteStateMachine) GetActiveAgent() interface{}
GetActiveAgent used to get fsm's active agent at current turn
func (*FiniteStateMachine) GetEndAt ¶
func (fsm *FiniteStateMachine) GetEndAt() int64
GetEndAt used to get turn's end time
func (*FiniteStateMachine) GetName ¶
func (fsm *FiniteStateMachine) GetName() string
GetName used to get fsm's state name
func (*FiniteStateMachine) GoTo ¶
func (fsm *FiniteStateMachine) GoTo(stateName string, item Modellable)
GoTo used for fsm's state transition
func (*FiniteStateMachine) IsTurnExpired ¶
func (fsm *FiniteStateMachine) IsTurnExpired() bool
IsTurnExpired used to check if turn is expired
func (*FiniteStateMachine) RegisterState ¶ added in v0.0.75
func (fsm *FiniteStateMachine) RegisterState(stateName string) *StateHandler
RegisterState used to add handler for fsm's state
func (*FiniteStateMachine) Run ¶
func (fsm *FiniteStateMachine) Run(item Modellable, dt float64)
Run used to run fsm's state
func (*FiniteStateMachine) SetTurn ¶
func (fsm *FiniteStateMachine) SetTurn(activeAgent Modellable, endAt time.Time)
SetTurn used to set new turn
type HooksHandler ¶ added in v0.0.39
type HooksHandler struct {
// contains filtered or unexported fields
}
HooksHandler used to mange callbacks for models
func (*HooksHandler) ExecuteAfterCreateHook ¶ added in v0.1.0
func (handler *HooksHandler) ExecuteAfterCreateHook()
ExecuteAfterCreateHook used to execute after create hook
func (*HooksHandler) ExecuteInitializeHook ¶ added in v0.0.46
func (handler *HooksHandler) ExecuteInitializeHook(values *helpers.Dictionary)
ExecuteInitializeHook used to execute after initialize hook
func (*HooksHandler) ExecuteValidationHooks ¶ added in v0.0.46
func (handler *HooksHandler) ExecuteValidationHooks() error
ExecuteValidationHooks used to execute validation hooks
func (*HooksHandler) RegisterAfterCreateHook ¶ added in v0.1.0
func (handler *HooksHandler) RegisterAfterCreateHook(afterCreateHook func())
RegisterAfterCreateHook used to add after create hook
func (*HooksHandler) RegisterInitializeHook ¶ added in v0.0.40
func (handler *HooksHandler) RegisterInitializeHook(initializeHook func(*helpers.Dictionary))
RegisterInitializeHook used to add initialize hook
func (*HooksHandler) RegisterValidationHook ¶ added in v0.0.39
func (handler *HooksHandler) RegisterValidationHook(validationHook Validator)
RegisterValidationHook used to add a validation hook
type List ¶ added in v0.0.51
type List struct {
// contains filtered or unexported fields
}
List is an in-memory storage of items
func MakeList ¶ added in v0.0.69
func MakeList(items ...Modellable) *List
MakeList used to instantiate list instance
func (*List) Add ¶ added in v0.0.51
func (list *List) Add(item Modellable)
Add used to store item to list
func (*List) Find ¶ added in v0.0.51
func (list *List) Find(predicate FindPredicate) Modellable
Find used to find item in collection, return nil if not found
func (*List) FindAll ¶ added in v0.0.51
func (list *List) FindAll(predicate FindPredicate) []Modellable
FindAll used to find items in collection
func (*List) FindByID ¶ added in v0.0.51
func (list *List) FindByID(id string) Modellable
FindByID used to find item in collection by id, return nil if not found
func (*List) First ¶ added in v0.0.51
func (list *List) First() Modellable
First used to return first item in collection
func (*List) Items ¶ added in v0.0.51
func (list *List) Items() []Modellable
Items used to return all items in collections
type ListResults ¶ added in v0.0.55
type ListResults struct {
// contains filtered or unexported fields
}
ListResults used to wrap multiple record results from query
func MakeListResults ¶ added in v0.0.55
func MakeListResults() *ListResults
MakeListResults used to instantiate list results
func (*ListResults) Error ¶ added in v0.0.59
func (results *ListResults) Error() error
func (*ListResults) List ¶ added in v0.0.69
func (results *ListResults) List() *List
List used to retrieve result's list
func (*ListResults) Set ¶ added in v0.0.55
func (results *ListResults) Set(list *List, err error)
Set used to set result's list and err
func (*ListResults) StatusError ¶ added in v0.0.57
func (results *ListResults) StatusError() bool
StatusError used to check if operation is errored
func (*ListResults) StatusSuccess ¶ added in v0.0.57
func (results *ListResults) StatusSuccess() bool
StatusSuccess used to check if operation is success
type Manager ¶ added in v0.0.22
type Manager struct {
// contains filtered or unexported fields
}
Manager is a singleton used to manager model's behavior
func (*Manager) Collection ¶ added in v0.0.66
func (manager *Manager) Collection(clientName string, collectionName string) *Collection
Collection used to retrieve registered collection
func (*Manager) CreateCollection ¶ added in v0.0.23
func (manager *Manager) CreateCollection(clientName string, collectionName string, newHandler NewHandler) *Collection
CreateCollection used to create a collection without registering
func (*Manager) RegisterAdapter ¶ added in v0.0.39
RegisterAdapter used to register adapter
func (*Manager) RegisterCollection ¶ added in v0.0.22
func (manager *Manager) RegisterCollection(clientName string, collectionName string, newHandler NewHandler) *Collection
RegisterCollection used to create a collection and register with adapter
type Modellable ¶ added in v0.0.21
type Modellable interface { InitializeBase(*Context) GetID() string Save() error GetHooksHandler() *HooksHandler Store() StoreInList(*List) }
Modellable is the interface for all models implementing model's functionalities
type NewHandler ¶ added in v0.0.39
type NewHandler func(*Context)
NewHandler is alias for func(*Context)
type Queryable ¶ added in v0.0.39
type Queryable interface { Where(filter helpers.H) Queryable Count() *CountResult Each(func(Modellable, error) bool) error First() *SingleResult FirstOrCreate(helpers.H) *SingleResult Find(string) *SingleResult ToList() *ListResults }
Queryable is the interface for all query adapter implementing query's functionalities
type SingleResult ¶ added in v0.0.55
type SingleResult struct {
// contains filtered or unexported fields
}
SingleResult used to wrap single record result from query or create operation
func MakeSingleResult ¶ added in v0.0.55
func MakeSingleResult() *SingleResult
MakeSingleResult used to instantiate single result
func (*SingleResult) Error ¶ added in v0.0.55
func (result *SingleResult) Error() error
func (*SingleResult) ErrorMessage ¶ added in v0.0.55
func (result *SingleResult) ErrorMessage() string
ErrorMessage used to retrieve result's error message
func (*SingleResult) Item ¶ added in v0.0.55
func (result *SingleResult) Item() Modellable
Item used to retrieve result's item
func (*SingleResult) Set ¶ added in v0.0.55
func (result *SingleResult) Set(item Modellable, err error, notFound bool)
Set used to set result item, error and status
func (*SingleResult) Status ¶ added in v0.0.55
func (result *SingleResult) Status() string
Status used to retrieve result's status
func (*SingleResult) StatusError ¶ added in v0.0.57
func (result *SingleResult) StatusError() bool
StatusError used to check if operation is errored
func (*SingleResult) StatusNotFound ¶ added in v0.0.57
func (result *SingleResult) StatusNotFound() bool
StatusNotFound used to check if record is not found
func (*SingleResult) StatusSuccess ¶ added in v0.0.57
func (result *SingleResult) StatusSuccess() bool
StatusSuccess used to check if operation is success
type StateHandler ¶
type StateHandler struct {
// contains filtered or unexported fields
}
StateHandler used to handle fsm's callback
func (*StateHandler) WithEnterHook ¶ added in v0.0.75
func (handler *StateHandler) WithEnterHook(hook func(string)) *StateHandler
WithEnterHook used to register state handler's enter hook
func (*StateHandler) WithExitHook ¶ added in v0.0.75
func (handler *StateHandler) WithExitHook(hook func()) *StateHandler
WithExitHook used to register state handler's exit hook
func (*StateHandler) WithRunHook ¶ added in v0.0.75
func (handler *StateHandler) WithRunHook(hook func(float64)) *StateHandler
WithRunHook used to register state handler's run hook