Documentation
¶
Overview ¶
Transaction.go
Data descibes a Data object with its respective properties to store things in a database ¶
Vector ¶
Map ¶
parser for the datastructure markup language
Vector ¶
Vector
Index ¶
- Constants
- func DataTypeDecode(code string) (interface{}, error)
- func NewBaseBehaviour(runtime *Runtime) (*behaviour, error)
- func NewBehaviourHandler(runtime *Runtime) behaviourHandler
- func NewEventHandler() eventHandler
- func NewMethodHandler() methodHandler
- func NewObject(rntm *Runtime) (*object, error)
- func NewPrintManager() *printManager
- func NewPropertyHandler() propertyHandler
- func SetupGlobals(rntm *Runtime)
- func UnifyDataType(val interface{}) interface{}
- type Behaviour
- type BehaviourHandler
- type Boolean
- type CreatorFunc
- type DML
- type Data
- type DataImpl
- func (self *DataImpl) AddBehaviourObject(behaviour Behaviour) error
- func (self *DataImpl) AddChildIdentifier(id Identifier, child Identifier) error
- func (self *DataImpl) AddChildObject(child Data)
- func (self DataImpl) BeforePropertyChange(id Identifier, name string) error
- func (self *DataImpl) Behaviours() []string
- func (self DataImpl) BuildVersionedKey(id Identifier, storage datastore.StorageType, entries ...interface{}) datastore.Key
- func (self *DataImpl) Created(id Identifier) error
- func (self DataImpl) EraseFromDB(id Identifier) error
- func (self *DataImpl) EventEmitted(id Identifier, event string, args ...interface{}) error
- func (self DataImpl) FixStateAsVersion(id Identifier) (datastore.VersionID, error)
- func (self *DataImpl) GetBehaviour(id Identifier, name string) (dmlSet, error)
- func (self *DataImpl) GetBehaviourIdentifier(id Identifier, name string) (Identifier, error)
- func (self *DataImpl) GetBehaviourObject(name string) Behaviour
- func (self *DataImpl) GetByKey(id Identifier, key Key) (interface{}, error)
- func (self *DataImpl) GetChildByName(id Identifier, name string) (dmlSet, error)
- func (self *DataImpl) GetChildIdentifierByName(id Identifier, name string) (Identifier, error)
- func (self *DataImpl) GetChildIdentifiers(id Identifier) ([]Identifier, error)
- func (self *DataImpl) GetChildObjects() []Data
- func (self *DataImpl) GetChildren(id Identifier) ([]dmlSet, error)
- func (self DataImpl) GetCurrentVersion(id Identifier) (datastore.VersionID, error)
- func (self DataImpl) GetDBList(id Identifier, key []byte) (datastore.List, error)
- func (self DataImpl) GetDBListVersioned(id Identifier, key []byte) (datastore.ListVersioned, error)
- func (self DataImpl) GetDBMap(id Identifier, key []byte) (datastore.Map, error)
- func (self DataImpl) GetDBMapVersioned(id Identifier, key []byte) (datastore.MapVersioned, error)
- func (self DataImpl) GetDBValue(id Identifier, key []byte) (datastore.Value, error)
- func (self DataImpl) GetDBValueVersioned(id Identifier, key []byte) (datastore.ValueVersioned, error)
- func (self DataImpl) GetDataType(id Identifier) (DataType, error)
- func (self DataImpl) GetJSObject(id Identifier) *goja.Object
- func (self DataImpl) GetJSPrototype() *goja.Object
- func (self DataImpl) GetJSRuntime() *goja.Runtime
- func (self *DataImpl) GetKeys(id Identifier) ([]Key, error)
- func (self DataImpl) GetLatestVersion(id Identifier) (datastore.VersionID, error)
- func (self DataImpl) GetObjectDataType() DataType
- func (self DataImpl) GetObjectPath(id Identifier) (string, error)
- func (self DataImpl) GetParent(id Identifier) (dmlSet, error)
- func (self DataImpl) GetParentIdentifier(id Identifier) (Identifier, error)
- func (self DataImpl) GetRuntime() *Runtime
- func (self *DataImpl) GetSubobjects(id Identifier) ([]dmlSet, error)
- func (self *DataImpl) HandleBehaviourEvent(id Identifier, source Identifier, event string, args []interface{}, ...) ([]string, error)
- func (self *DataImpl) HandleBehaviourKeywords(id Identifier, kwargs map[string]interface{}, behaviours []string, ...) ([]string, error)
- func (self *DataImpl) HasBehaviour(name string) bool
- func (self *DataImpl) HasBehaviourIdentifier(id Identifier, name string) (bool, error)
- func (self *DataImpl) HasKey(id Identifier, key Key) (bool, error)
- func (self DataImpl) HasUpdates(id Identifier) (bool, error)
- func (self DataImpl) HasVersions(id Identifier) (bool, error)
- func (self DataImpl) InitializeDB(id Identifier) error
- func (self DataImpl) KeysAllHaveVersions(keys []datastore.Key) (bool, error)
- func (self DataImpl) KeysAnyHasUpdates(keys []datastore.Key) (bool, error)
- func (self DataImpl) KeysFixStateAsVersion(keys []datastore.Key) ([]datastore.VersionID, error)
- func (self DataImpl) KeysGetCurrentVersion(keys []datastore.Key) ([]datastore.VersionID, error)
- func (self DataImpl) KeysGetLatestVersion(keys []datastore.Key) ([]datastore.VersionID, error)
- func (self DataImpl) KeysLoadVersion(keys []datastore.Key, versions []datastore.VersionID) error
- func (self DataImpl) KeysRemoveVersionsUpFrom(keys []datastore.Key, versions []datastore.VersionID) error
- func (self DataImpl) KeysRemoveVersionsUpTo(keys []datastore.Key, versions []datastore.VersionID) error
- func (self DataImpl) KeysResetHead(keys []datastore.Key) error
- func (self DataImpl) LoadVersion(id Identifier, vId datastore.VersionID) error
- func (self *DataImpl) ProcessBehaviourKeywords(id Identifier, kwargs map[string]interface{}) error
- func (self DataImpl) PropertyChanged(id Identifier, name string) error
- func (self DataImpl) RemoveVersionsUpFrom(id Identifier, vId datastore.VersionID) error
- func (self DataImpl) RemoveVersionsUpTo(id Identifier, vId datastore.VersionID) error
- func (self DataImpl) ResetHead(id Identifier) error
- func (self *DataImpl) SetBehaviourIdentifier(id Identifier, name string, behaviour Identifier) error
- func (self DataImpl) SetDataType(id Identifier, dt DataType) error
- func (self DataImpl) SetObjectDataType(dt DataType)
- func (self *DataImpl) SetObjectPath(id Identifier, path string) error
- func (self DataImpl) SetParentIdentifier(id Identifier, parent Identifier) error
- type DataType
- func (self DataType) AsString() string
- func (self DataType) Encode() string
- func (self DataType) GetDefaultValue() interface{}
- func (self DataType) IsBool() bool
- func (self DataType) IsComplex() bool
- func (self DataType) IsEqual(dt DataType) bool
- func (self DataType) IsFloat() bool
- func (self DataType) IsInt() bool
- func (self DataType) IsKey() bool
- func (self DataType) IsNone() bool
- func (self DataType) IsPOD() bool
- func (self DataType) IsRaw() bool
- func (self DataType) IsString() bool
- func (self DataType) IsType() bool
- func (self DataType) IsValid() bool
- func (self DataType) IsVar() bool
- func (self DataType) MustBeTypeOf(val interface{}) error
- type EmmitedEvent
- type Event
- type EventCallback
- type EventEmitNotifyer
- type EventHandler
- type EventObjectCallback
- type Identifier
- type JSObject
- type Key
- type Method
- type MethodHandler
- type Object
- func NewContinuityBehaviour(rntm *Runtime) (Object, error)
- func NewData(rntm *Runtime) (Object, error)
- func NewGraph(rntm *Runtime) (Object, error)
- func NewMap(rntm *Runtime) (Object, error)
- func NewObjectTransactionBehaviour(rntm *Runtime) (Object, error)
- func NewPartialTransactionBehaviour(rntm *Runtime) (Object, error)
- func NewVariant(rntm *Runtime) (Object, error)
- func NewVector(rntm *Runtime) (Object, error)
- type PropGetter
- type PropSetter
- type Property
- type PropertyChangeNotifyer
- type PropertyHandler
- type PropertyType
- type Runtime
- func (self *Runtime) Call(ds *datastore.Datastore, user User, fullpath string, args []interface{}, ...) (interface{}, []EmmitedEvent, error)
- func (self Runtime) GetMessages() []string
- func (self *Runtime) InitializeDatastore(ds *datastore.Datastore) error
- func (self *Runtime) IsReadOnly(ds *datastore.Datastore, fullpath string, args []interface{}) (bool, error)
- func (self *Runtime) Parse(reader io.Reader) error
- func (self *Runtime) ParseFolder(path string) error
- func (self *Runtime) RegisterObjectCreator(name string, fnc CreatorFunc) error
- func (self *Runtime) RunJavaScript(ds *datastore.Datastore, user User, code string) (interface{}, []EmmitedEvent, error)
- type System
- type SystemCreatorFunc
- type SystemHandler
- func (self SystemHandler) GetEventBehaviours(event string) []string
- func (self SystemHandler) GetKeywordBehaviours(kws map[string]interface{}) []string
- func (self SystemHandler) GetSystem(name string) System
- func (self SystemHandler) GetSystems() []System
- func (self *SystemHandler) HasSystem(name string) bool
- func (self *SystemHandler) RegisterSystem(rntm *Runtime, name string, creator SystemCreatorFunc)
- type TransactionManager
- func (self *TransactionManager) Abort() error
- func (self *TransactionManager) AddMethod(name string, method Method)
- func (self *TransactionManager) AfterOperation() error
- func (self *TransactionManager) BeforeOperation() error
- func (self *TransactionManager) CanHandleEvent(event string) bool
- func (self *TransactionManager) CanHandleKeyword(string) bool
- func (self *TransactionManager) Close() error
- func (self *TransactionManager) ExposedToJS() bool
- func (self *TransactionManager) GetJSObject() *goja.Object
- func (self *TransactionManager) GetJSRuntime() *goja.Runtime
- func (self *TransactionManager) GetMethod(name string) Method
- func (self *TransactionManager) HasMethod(name string) bool
- func (self *TransactionManager) IsOpen() bool
- func (self *TransactionManager) Methods() []string
- func (self *TransactionManager) Open() error
- func (self *TransactionManager) SetupJSMethods(rntm *Runtime, obj *goja.Object) error
- type User
Constants ¶
const Error_Arguments_Wrong = "arguments_wrong"
const Error_Compiler = "compilation_failed"
const Error_Fatal = "fatal_problem"
const Error_Filesystem = "filesystem_not_accessible"
const Error_Key_Not_Available = "key_not_available"
const Error_Operation_Invalid = "operation_invalid"
const Error_Setup_Invalid = "setup_invalid"
const Error_Syntax = "syntax_error"
const Error_Type = "type"
Variables ¶
This section is empty.
Functions ¶
func DataTypeDecode ¶
func NewBaseBehaviour ¶
func NewBehaviourHandler ¶
func NewBehaviourHandler(runtime *Runtime) behaviourHandler
func NewEventHandler ¶
func NewEventHandler() eventHandler
func NewMethodHandler ¶
func NewMethodHandler() methodHandler
func NewPrintManager ¶
func NewPrintManager() *printManager
func NewPropertyHandler ¶
func NewPropertyHandler() propertyHandler
func SetupGlobals ¶
func SetupGlobals(rntm *Runtime)
func UnifyDataType ¶
func UnifyDataType(val interface{}) interface{}
changes Value to its main type from multiple subtypes, e.g. int64 from int and int16 Note: No type checking is done!
Types ¶
type Behaviour ¶
type Behaviour interface {
Object
GetBehaviourType() string //returns the type of behaviour, e.g. "Transaction". Needed to allow multiple different structs implement single behaviour
HandleEvent(Identifier, Identifier, string, []interface{}) error //Entry for any kind of behhaviour handling. Here the event that can be handled according to the relevant Manager are provided
HandleKeyword(Identifier, string, interface{}) error //Handle Keywords on WAMP Api call to the object
}
+extract prio:3
.. dml:behaviour:: Behaviour
:abstract: Base class for all behaviours, adding common properties and events. It cannot be used directly, only behaviours derived from it. It does add the possibility to add custom properties, events and functions. Children are not allowed. .. dml:property:: name :const: :type: string A property defining the name of the behaviour. The name can be used to access ut in the hirarchy, either in JavaScript code or as WAMP uri. It is mandatory to set the name of each behaviour. .. dml:property:: parent :const: :type: Data The parent object of the behaviour, the one which it extends. .. dml:property:: recursive :const: :type: bool Defines if the behaviour is applied recursively for all children and subobjects of the behaviours parent. For example, if a behaviour is added to a Map Object, it may watch for changes in that object. If recursive is true, it will also look for all changes in any children or value objects of that Map. :default: false .. dml:event:: onBeforePropertyChange Emitted bevore a property of the object changes. At time of emit the property still has its old value. :argument string Property: Name of the property thats about to be changed .. dml:event:: onPropertyChanged Emitted when a property was changed. The value of the property is already the new one when emitted. :argument string Property: Name of the property thats was changed
type BehaviourHandler ¶
type BehaviourHandler interface {
//management functions for behaviours:
//here general behaviour objects are handled, as a object has a defined set of behaviours.
//This does not provide any database access, only logic
HasBehaviour(string) bool
GetBehaviourObject(string) Behaviour
AddBehaviourObject(Behaviour) error
Behaviours() []string
//This function is used to retrieve a behaviour database access Identifier
GetBehaviourIdentifier(Identifier, string) (Identifier, error)
SetBehaviourIdentifier(Identifier, string, Identifier) error
HasBehaviourIdentifier(Identifier, string) (bool, error)
//convinience function for combined logic and db access
GetBehaviour(Identifier, string) (dmlSet, error)
//Forwards event to all behaviours given in list, and returns the ones not available
//Identifier, source object, eventname, arguments, behaviours to forward, recursive (true) or original object(false).
HandleBehaviourEvent(Identifier, Identifier, string, []interface{}, []string, bool) ([]string, error)
//Forwards WAMP keywords to all behaviours given in list, and returns the ones not available
//Identifier, keyword arguments, behaviours to forward, recursive (true) or original object(false).
HandleBehaviourKeywords(Identifier, map[string]interface{}, []string, bool) ([]string, error)
// contains filtered or unexported methods
}
* Handler for different behaviours within an object
type CreatorFunc ¶
Function prototype that can create new object types in DML
type DML ¶
type DML struct {
//next to imports only a single object is allowed: root must be unambigious
Imports []*astImport `{ @@ }`
Object *astObject `{ @@ }`
}
the file format
type Data ¶
type Data interface {
Object
BehaviourHandler
//Data hirarchy allows childs. Here we add the structure and logic by
//adding static objects. Database access by identifiers is handled seperatly
AddChildObject(Data)
GetChildObjects() []Data
//Data hirarchy allows childs
AddChildIdentifier(Identifier, Identifier) error
GetChildIdentifiers(Identifier) ([]Identifier, error)
GetChildIdentifierByName(Identifier, string) (Identifier, error)
//little convinience function for children hirarchy combining objects and IDs
GetChildren(Identifier) ([]dmlSet, error)
GetChildByName(Identifier, string) (dmlSet, error)
GetSubobjects(id Identifier) ([]dmlSet, error) //Convinience function to get all subobjects, including childs, behaviours any any created ones
Created(id Identifier) error
ProcessBehaviourKeywords(id Identifier, kwargs map[string]interface{}) error //handles the keyword arguments in the behaviours of this object //emits onCreated event for this and all subobjects (not behaviours)
// contains filtered or unexported methods
}
+extract prio:1
.. dml:object:: Data
The most basic implementation of a DML Object. It allows to add properties, events and functions and can hold other Objects and Behaviours as children. It has no other special functionality. It is intended as dml grouping object as well as base object for all other data types Data does allow for children. Note that children are static values, they cannot change at runtime. Hence they are different to dynamic objects as are possible with Maps etc. Children are used purely for the static DML hirarchy. .. dml:property:: name :const: :type: string A property defining the name of the object. The name can than be used to access in the hirarchy, either in JavaScript code or as WAMP uri. It is mandatory to set the name of each object. .. dml:property:: parent :const: :type: Data The parent object of the object. The value is null for the toplevel object. .. dml:property:: children :const: :type: [Data] A list of all children the Data object has. Note that this are only the children defined in the DML file itself, not the dynamic subobjects some types can add, like maps entries. .. dml:property behaviours :const: :type: [Behaviour] A list of all behaviours the Data object has attched to it. .. dml:event:: onBeforePropertyChange Emitted bevore a property of the object changes. At time of emit the property still has its old value. :argument string Property: Name of the property thats about to be changed .. dml:event:: onPropertyChanged Emitted when a property was changed. The value of the property is already the new one when emitted. :argument string Property: Name of the property thats was changed .. dml:event:: onCreated Emitted after the object was created and fully setup. It will be emitted only dynamically created objects, for example when used as value in Maps, and not the ones in the static DML hirarchy. .. dml:event:: onRemove Emitted after the object is about to be removed. At the time of emitting the object is still fully setup and accessible, the removing will happen after all handlers have been executed. As static hirarchy objects cannot be removed this event will be emitted only for dynamically created objects, for example when used as value in Maps etc. .. dml:event:: onBeforeChange This is a general event, emitted bevore the object itself changes, no matter what the changes are. This is not emitted for changed properties, there is a custom event for that, but if the objects content is manipulated. This means that for a Data object it will never be emitted, as it does not have any object content, but it may be emitted for derived object types like maps. .. note:: Most derived classes that emit this event will also have custom events that are more specialized for the eexact changes that happend. .. dml:event:: onChanged This is a general event, emitted after the object has changed, no matter what the changes are. This is not emitted for changed properties, there is a custom event for that, but if the objects content was manipulated. This means that for a Data object it will never be emitted, as it does not have any object content, but it may be emitted for derived object types like maps. .. note:: Most derived classes that emit this event will also have custom events that are more specialized for the eexact changes that happend.
type DataImpl ¶
type DataImpl struct {
// contains filtered or unexported fields
}
func NewDataBaseClass ¶
func (*DataImpl) AddBehaviourObject ¶
func (*DataImpl) AddChildIdentifier ¶
func (self *DataImpl) AddChildIdentifier(id Identifier, child Identifier) error
func (*DataImpl) AddChildObject ¶
func (DataImpl) BeforePropertyChange ¶
func (self DataImpl) BeforePropertyChange(id Identifier, name string) error
func (*DataImpl) Behaviours ¶
func (self *DataImpl) Behaviours() []string
func (DataImpl) BuildVersionedKey ¶
func (self DataImpl) BuildVersionedKey(id Identifier, storage datastore.StorageType, entries ...interface{}) datastore.Key
func (*DataImpl) Created ¶
func (self *DataImpl) Created(id Identifier) error
func (DataImpl) EraseFromDB ¶
func (self DataImpl) EraseFromDB(id Identifier) error
func (*DataImpl) EventEmitted ¶
func (self *DataImpl) EventEmitted(id Identifier, event string, args ...interface{}) error
Override event emitted, to forward them to the behaviour handler
func (DataImpl) FixStateAsVersion ¶
func (self DataImpl) FixStateAsVersion(id Identifier) (datastore.VersionID, error)
func (*DataImpl) GetBehaviour ¶
func (self *DataImpl) GetBehaviour(id Identifier, name string) (dmlSet, error)
func (*DataImpl) GetBehaviourIdentifier ¶
func (self *DataImpl) GetBehaviourIdentifier(id Identifier, name string) (Identifier, error)
func (*DataImpl) GetBehaviourObject ¶
func (*DataImpl) GetByKey ¶
func (self *DataImpl) GetByKey(id Identifier, key Key) (interface{}, error)
func (*DataImpl) GetChildByName ¶
func (self *DataImpl) GetChildByName(id Identifier, name string) (dmlSet, error)
func (*DataImpl) GetChildIdentifierByName ¶
func (self *DataImpl) GetChildIdentifierByName(id Identifier, name string) (Identifier, error)
func (*DataImpl) GetChildIdentifiers ¶
func (self *DataImpl) GetChildIdentifiers(id Identifier) ([]Identifier, error)
func (*DataImpl) GetChildObjects ¶
func (*DataImpl) GetChildren ¶
func (self *DataImpl) GetChildren(id Identifier) ([]dmlSet, error)
func (DataImpl) GetCurrentVersion ¶
func (self DataImpl) GetCurrentVersion(id Identifier) (datastore.VersionID, error)
func (DataImpl) GetDBList ¶
func (self DataImpl) GetDBList(id Identifier, key []byte) (datastore.List, error)
func (DataImpl) GetDBListVersioned ¶
func (self DataImpl) GetDBListVersioned(id Identifier, key []byte) (datastore.ListVersioned, error)
func (DataImpl) GetDBMap ¶
func (self DataImpl) GetDBMap(id Identifier, key []byte) (datastore.Map, error)
func (DataImpl) GetDBMapVersioned ¶
func (self DataImpl) GetDBMapVersioned(id Identifier, key []byte) (datastore.MapVersioned, error)
func (DataImpl) GetDBValue ¶
func (self DataImpl) GetDBValue(id Identifier, key []byte) (datastore.Value, error)
func (DataImpl) GetDBValueVersioned ¶
func (self DataImpl) GetDBValueVersioned(id Identifier, key []byte) (datastore.ValueVersioned, error)
func (DataImpl) GetDataType ¶
func (self DataImpl) GetDataType(id Identifier) (DataType, error)
func (DataImpl) GetJSObject ¶
func (self DataImpl) GetJSObject(id Identifier) *goja.Object
func (DataImpl) GetJSPrototype ¶
func (DataImpl) GetJSRuntime ¶
func (DataImpl) GetLatestVersion ¶
func (self DataImpl) GetLatestVersion(id Identifier) (datastore.VersionID, error)
func (DataImpl) GetObjectDataType ¶
func (self DataImpl) GetObjectDataType() DataType
func (DataImpl) GetObjectPath ¶
func (self DataImpl) GetObjectPath(id Identifier) (string, error)
func (DataImpl) GetParent ¶
func (self DataImpl) GetParent(id Identifier) (dmlSet, error)
func (DataImpl) GetParentIdentifier ¶
func (self DataImpl) GetParentIdentifier(id Identifier) (Identifier, error)
func (DataImpl) GetRuntime ¶
func (self DataImpl) GetRuntime() *Runtime
func (*DataImpl) GetSubobjects ¶
func (self *DataImpl) GetSubobjects(id Identifier) ([]dmlSet, error)
func (*DataImpl) HandleBehaviourEvent ¶
func (self *DataImpl) HandleBehaviourEvent(id Identifier, source Identifier, event string, args []interface{}, behaviours []string, isrecursive bool) ([]string, error)
func (*DataImpl) HandleBehaviourKeywords ¶
func (*DataImpl) HasBehaviour ¶
func (*DataImpl) HasBehaviourIdentifier ¶
func (self *DataImpl) HasBehaviourIdentifier(id Identifier, name string) (bool, error)
func (DataImpl) HasUpdates ¶
func (self DataImpl) HasUpdates(id Identifier) (bool, error)
Versioned Data Interface with identifiers for whole object
func (DataImpl) HasVersions ¶
func (self DataImpl) HasVersions(id Identifier) (bool, error)
func (DataImpl) InitializeDB ¶
func (self DataImpl) InitializeDB(id Identifier) error
func (DataImpl) KeysAllHaveVersions ¶
func (DataImpl) KeysAnyHasUpdates ¶
func (DataImpl) KeysFixStateAsVersion ¶
func (self DataImpl) KeysFixStateAsVersion(keys []datastore.Key) ([]datastore.VersionID, error)
func (DataImpl) KeysGetCurrentVersion ¶
func (self DataImpl) KeysGetCurrentVersion(keys []datastore.Key) ([]datastore.VersionID, error)
func (DataImpl) KeysGetLatestVersion ¶
func (self DataImpl) KeysGetLatestVersion(keys []datastore.Key) ([]datastore.VersionID, error)
func (DataImpl) KeysLoadVersion ¶
func (self DataImpl) KeysLoadVersion(keys []datastore.Key, versions []datastore.VersionID) error
func (DataImpl) KeysRemoveVersionsUpFrom ¶
func (self DataImpl) KeysRemoveVersionsUpFrom(keys []datastore.Key, versions []datastore.VersionID) error
func (DataImpl) KeysRemoveVersionsUpTo ¶
func (self DataImpl) KeysRemoveVersionsUpTo(keys []datastore.Key, versions []datastore.VersionID) error
func (DataImpl) KeysResetHead ¶
func (self DataImpl) KeysResetHead(keys []datastore.Key) error
func (DataImpl) LoadVersion ¶
func (self DataImpl) LoadVersion(id Identifier, vId datastore.VersionID) error
func (*DataImpl) ProcessBehaviourKeywords ¶
func (self *DataImpl) ProcessBehaviourKeywords(id Identifier, kwargs map[string]interface{}) error
func (DataImpl) PropertyChanged ¶
func (self DataImpl) PropertyChanged(id Identifier, name string) error
func (DataImpl) RemoveVersionsUpFrom ¶
func (self DataImpl) RemoveVersionsUpFrom(id Identifier, vId datastore.VersionID) error
func (DataImpl) RemoveVersionsUpTo ¶
func (self DataImpl) RemoveVersionsUpTo(id Identifier, vId datastore.VersionID) error
func (DataImpl) ResetHead ¶
func (self DataImpl) ResetHead(id Identifier) error
func (*DataImpl) SetBehaviourIdentifier ¶
func (self *DataImpl) SetBehaviourIdentifier(id Identifier, name string, behaviour Identifier) error
func (DataImpl) SetDataType ¶
func (self DataImpl) SetDataType(id Identifier, dt DataType) error
func (DataImpl) SetObjectDataType ¶
func (self DataImpl) SetObjectDataType(dt DataType)
func (*DataImpl) SetObjectPath ¶
func (self *DataImpl) SetObjectPath(id Identifier, path string) error
func (DataImpl) SetParentIdentifier ¶
func (self DataImpl) SetParentIdentifier(id Identifier, parent Identifier) error
type DataType ¶
type DataType struct {
Value string
}
a datatype can be either a pod type or any complex dml object
func MustNewDataType ¶
func MustNewDataType(val interface{}) DataType
func NewDataType ¶
func (DataType) GetDefaultValue ¶
func (self DataType) GetDefaultValue() interface{}
func (DataType) MustBeTypeOf ¶
type EmmitedEvent ¶
type EmmitedEvent struct {
Path string
Args []interface{}
}
Type to collect information about an emitted event and its arguments
type Event ¶
type Event interface {
JSObject
MethodHandler
GetName() string
SetNotifyer(EventEmitNotifyer)
Emit(Identifier, ...interface{}) error
Enabled(Identifier) (bool, error)
Enable(Identifier) error
Disable(Identifier) error
//DB individual, add to a certain Identifier a callback as function to call from annother identifier
RegisterCallback(Identifier, Identifier, string) error
//Object based, add callback functions to all identifiers of the object
//note: only allowed for callbacks in the same object the event lives in. The reason is the
//passed identifier: it is always the event parent object that emits the event. Hence if a function
//to annother object is passed the identifier may have different type than the object called
//Therefore any JS function registered is handled as it would be a object function.
RegisterObjectJSCallback(func(goja.FunctionCall) goja.Value) error
RegisterObjectGoCallback(EventCallback) error
}
type EventCallback ¶
type EventCallback func(Identifier, ...interface{}) error
type EventEmitNotifyer ¶
type EventEmitNotifyer interface {
EventEmitted(Identifier, string, ...interface{}) error
}
type EventHandler ¶
type EventObjectCallback ¶
type EventObjectCallback struct {
Id Identifier
Function string
}
type Identifier ¶
func IdentifierFromData ¶
func IdentifierFromData(data []byte) (Identifier, error)
func IdentifierFromEncoded ¶
func IdentifierFromEncoded(code string) (Identifier, error)
func (Identifier) Data ¶
func (self Identifier) Data() []byte
func (Identifier) Encode ¶
func (self Identifier) Encode() string
func (Identifier) Equals ¶
func (self Identifier) Equals(id Identifier) bool
func (Identifier) Hash ¶
func (self Identifier) Hash() [32]byte
func (Identifier) String ¶
func (self Identifier) String() string
func (Identifier) Valid ¶
func (self Identifier) Valid() bool
type JSObject ¶
type JSObject interface {
GetJSObject(Identifier) *goja.Object
GetJSPrototype() *goja.Object
GetJSRuntime() *goja.Runtime
}
should be implemented by everythign that is exposed to JS
type Key ¶
type Key struct {
Internal interface{}
}
func MustNewKey ¶
func MustNewKey(data interface{}) Key
func (Key) AsDataType ¶
type Method ¶
type Method interface {
Call(args ...interface{}) (interface{}, error)
CallBoolReturn(args ...interface{}) (bool, error)
IsConst() bool
IsIdMethod() bool
}
func MustNewIdMethod ¶
func MustNewMethod ¶
func NewIdMethod ¶
type MethodHandler ¶
type Object ¶
type Object interface {
PropertyHandler
PropertyChangeNotifyer
EventHandler
EventEmitNotifyer
MethodHandler
JSObject
//Object functions
GetParentIdentifier(Identifier) (Identifier, error)
SetParentIdentifier(Identifier, Identifier) error
GetParent(Identifier) (dmlSet, error)
//Object type handling (full type desciption of this object)
GetObjectDataType() DataType
SetObjectDataType(DataType)
//Identifier type handling. It could be, that a certain object is used to access
//the database for a object of different DataType
GetDataType(Identifier) (DataType, error)
SetDataType(Identifier, DataType) error
//Let the object know it's path in the dml runtime. This is important for event
//emitting, as it needs to know what exact uri to use. Note that the path cannot
//be determined at runtime from an object, as in maps or vectors it is not possible
//to get the key easily by value (only by iterating, but thats expensive for each
//event emit)
GetObjectPath(Identifier) (string, error)
SetObjectPath(Identifier, string) error //sets the full path including the object name
//Genertic
GetRuntime() *Runtime
//VersionedData interface based on Identifiers (For whole object)
HasUpdates(Identifier) (bool, error)
HasVersions(Identifier) (bool, error)
ResetHead(Identifier) error
FixStateAsVersion(Identifier) (datastore.VersionID, error)
LoadVersion(Identifier, datastore.VersionID) error
GetLatestVersion(Identifier) (datastore.VersionID, error)
GetCurrentVersion(Identifier) (datastore.VersionID, error)
RemoveVersionsUpTo(Identifier, datastore.VersionID) error
RemoveVersionsUpFrom(Identifier, datastore.VersionID) error
//VersionedData interface based on keys, and subkeys
BuildVersionedKey(Identifier, datastore.StorageType, ...interface{}) datastore.Key
KeysAnyHasUpdates([]datastore.Key) (bool, error) //true if any of the given keys has an update
KeysAllHaveVersions([]datastore.Key) (bool, error) //true if all of the given keys have updates
KeysResetHead([]datastore.Key) error
KeysFixStateAsVersion([]datastore.Key) ([]datastore.VersionID, error)
KeysLoadVersion([]datastore.Key, []datastore.VersionID) error
KeysGetLatestVersion([]datastore.Key) ([]datastore.VersionID, error)
KeysGetCurrentVersion([]datastore.Key) ([]datastore.VersionID, error)
KeysRemoveVersionsUpTo([]datastore.Key, []datastore.VersionID) error
KeysRemoveVersionsUpFrom([]datastore.Key, []datastore.VersionID) error
//Key handling for generic access to Data, events, properties, methods etc.
GetByKey(Identifier, Key) (interface{}, error) //Returns whatever the key represents in the Dataobject
HasKey(Identifier, Key) (bool, error) //Returns true if the provided key exists
GetKeys(Identifier) ([]Key, error) //returns all available keys
//helpers method for getting database access
GetDBValue(Identifier, []byte) (datastore.Value, error)
GetDBValueVersioned(Identifier, []byte) (datastore.ValueVersioned, error)
GetDBMap(Identifier, []byte) (datastore.Map, error)
GetDBMapVersioned(Identifier, []byte) (datastore.MapVersioned, error)
GetDBList(Identifier, []byte) (datastore.List, error)
GetDBListVersioned(Identifier, []byte) (datastore.ListVersioned, error)
EraseFromDB(Identifier) error
//initialization function
InitializeDB(Identifier) error
// contains filtered or unexported methods
}
Interface of an object: All objects, data and behaviour, must be able to handle
- Properties
- Events
- Methods
Furthermore must both be available in JS, Global by id an in the child hirarchy. It also implements the VersionedData interface, but on identifier basis
func NewContinuityBehaviour ¶
func NewVariant ¶
type PropGetter ¶
type PropGetter func(Identifier) (interface{}, error)
type PropSetter ¶
type PropSetter func(Identifier, interface{}) error
type Property ¶
type Property interface {
// EventHandler
Type() DataType
IsConst() bool
IsReadOnly() bool
SetValue(id Identifier, value interface{}) error
GetValue(id Identifier) (interface{}, error)
//required for startup, sets the initial value
SetDefaultValue(value interface{}) error
GetDefaultValue() interface{}
InitializeDB(id Identifier) error
}
Defines the default Property interface under which different data types can be stored. It uses a getter setter interface for better interactibility between dml, js and go
func NewFuncProperty ¶
func NewFuncProperty(name string, getter PropGetter, setter PropSetter, readonly bool) (Property, error)
func NewProperty ¶
func NewProperty(name string, dtype DataType, default_value interface{}, proptype PropertyType) (Property, error)
type PropertyChangeNotifyer ¶
type PropertyChangeNotifyer interface {
BeforePropertyChange(Identifier, string) error
PropertyChanged(Identifier, string) error
}
Defines a interface that is called by a Property on changes
type PropertyHandler ¶
type PropertyHandler interface {
HasProperty(string) bool
AddProperty(string, DataType, interface{}, PropertyType) error
AddFuncProperty(string, PropGetter, PropSetter, bool) error
GetProperty(string) Property
GetProperties() []string
SetupProperties(rntm *Runtime, jsobj *goja.Object, cb PropertyChangeNotifyer) error
InitializePropertyDB(Identifier) error
}
Property handler, which defines a interface for holding and using multiple properties
type PropertyType ¶
type PropertyType int
const ( ReadWrite PropertyType = iota //writable from go, JS and WAMP ReadOnly //writable from go, but not by users from JS and WAMP Constant //not writable )
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
builds a datastructure from a file - existing types must be registered to be recognized during parsing
func NewRuntime ¶
func NewRuntime() *Runtime
func (Runtime) GetMessages ¶
func (self Runtime) GetMessages() []string
func (*Runtime) InitializeDatastore ¶
Setups the database according to the parsed DML file
func (*Runtime) IsReadOnly ¶
func (self *Runtime) IsReadOnly(ds *datastore.Datastore, fullpath string, args []interface{}) (bool, error)
Check if the call isread only, hence does not change the data. True if: - path is a const method - path/args is reading a property - path is a value in an object, e.g. it reading the value
func (*Runtime) Parse ¶
Parses the dml code and setups the full structure. Note: Cannot handle local imports
func (*Runtime) ParseFolder ¶
func (*Runtime) RegisterObjectCreator ¶
func (self *Runtime) RegisterObjectCreator(name string, fnc CreatorFunc) error
Function to extend the available data and behaviour types for this runtime
func (*Runtime) RunJavaScript ¶
func (self *Runtime) RunJavaScript(ds *datastore.Datastore, user User, code string) (interface{}, []EmmitedEvent, error)
run arbitrary javascript code on the loaded structure
type System ¶
type System interface {
MethodHandler
ExposedToJS() bool
GetJSObject() *goja.Object
CanHandleEvent(string) bool //events to be handled by the behaviour type
CanHandleKeyword(string) bool //WAMP call keywords to be handled by the behaviour type
BeforeOperation() error //called before a WAMP operation is processed
AfterOperation() error //called after a WAMP operation is Processed
}
The general system, exposing Methods
func NewContinuitySystem ¶
func NewTransactionManager ¶
type SystemCreatorFunc ¶
type SystemHandler ¶
type SystemHandler struct {
// contains filtered or unexported fields
}
Type to handle multiple Systems. As we use this only in runtime, and not to define other interfaces, we do not a interface for this type
func (SystemHandler) GetEventBehaviours ¶
func (self SystemHandler) GetEventBehaviours(event string) []string
func (SystemHandler) GetKeywordBehaviours ¶
func (self SystemHandler) GetKeywordBehaviours(kws map[string]interface{}) []string
func (SystemHandler) GetSystem ¶
func (self SystemHandler) GetSystem(name string) System
func (SystemHandler) GetSystems ¶
func (self SystemHandler) GetSystems() []System
func (*SystemHandler) HasSystem ¶
func (self *SystemHandler) HasSystem(name string) bool
func (*SystemHandler) RegisterSystem ¶
func (self *SystemHandler) RegisterSystem(rntm *Runtime, name string, creator SystemCreatorFunc)
creates the system, panics if it fails
type TransactionManager ¶
type TransactionManager struct {
// contains filtered or unexported fields
}
implements BehaviourManager
func (*TransactionManager) Abort ¶
func (self *TransactionManager) Abort() error
+extract target:systems indent:1
.. dml:function:: Abort()
Aborts the current transaction and reverts all objects to the state they had when adding to the transaction
func (*TransactionManager) AfterOperation ¶
func (self *TransactionManager) AfterOperation() error
func (*TransactionManager) BeforeOperation ¶
func (self *TransactionManager) BeforeOperation() error
func (*TransactionManager) CanHandleEvent ¶
func (self *TransactionManager) CanHandleEvent(event string) bool
func (*TransactionManager) CanHandleKeyword ¶
func (self *TransactionManager) CanHandleKeyword(string) bool
func (*TransactionManager) Close ¶
func (self *TransactionManager) Close() error
+extract target:systems indent:1
.. dml:function:: Close()
Closes the currently open transaction.
func (*TransactionManager) ExposedToJS ¶
func (self *TransactionManager) ExposedToJS() bool
func (*TransactionManager) GetJSObject ¶
func (self *TransactionManager) GetJSObject() *goja.Object
func (*TransactionManager) GetJSRuntime ¶
func (self *TransactionManager) GetJSRuntime() *goja.Runtime
func (*TransactionManager) IsOpen ¶
func (self *TransactionManager) IsOpen() bool
+extract target:systems indent:1
.. dml:function:: IsOpen()
Checks if the user has currently a transaction open :return bool open: True if a transaction is open
func (*TransactionManager) Open ¶
func (self *TransactionManager) Open() error
+extract target:systems indent:1
.. dml:function:: Open()
Opens a transaction. If one is already open, it will be closed first.