dml

package
v0.0.0-...-b1bb88e Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2021 License: LGPL-2.1 Imports: 30 Imported by: 0

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

View Source
const Error_Arguments_Wrong = "arguments_wrong"
View Source
const Error_Compiler = "compilation_failed"
View Source
const Error_Fatal = "fatal_problem"
View Source
const Error_Filesystem = "filesystem_not_accessible"
View Source
const Error_Key_Not_Available = "key_not_available"
View Source
const Error_Operation_Invalid = "operation_invalid"
View Source
const Error_Setup_Invalid = "setup_invalid"
View Source
const Error_Syntax = "syntax_error"
View Source
const Error_Type = "type"

Variables

This section is empty.

Functions

func DataTypeDecode

func DataTypeDecode(code string) (interface{}, error)

func NewBaseBehaviour

func NewBaseBehaviour(runtime *Runtime) (*behaviour, error)

func NewBehaviourHandler

func NewBehaviourHandler(runtime *Runtime) behaviourHandler

func NewEventHandler

func NewEventHandler() eventHandler

func NewMethodHandler

func NewMethodHandler() methodHandler

func NewObject

func NewObject(rntm *Runtime) (*object, error)

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 Boolean

type Boolean bool

special type to make bool handling easier

func (*Boolean) Capture

func (b *Boolean) Capture(v []string) error

type CreatorFunc

type CreatorFunc func(rntm *Runtime) (Object, error)

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 NewDataBaseClass(rntm *Runtime) (*DataImpl, error)

func (*DataImpl) AddBehaviourObject

func (self *DataImpl) AddBehaviourObject(behaviour Behaviour) error

func (*DataImpl) AddChildIdentifier

func (self *DataImpl) AddChildIdentifier(id Identifier, child Identifier) error

func (*DataImpl) AddChildObject

func (self *DataImpl) AddChildObject(child Data)

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 (self *DataImpl) GetBehaviourObject(name string) Behaviour

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 (self *DataImpl) GetChildObjects() []Data

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 (self DataImpl) GetJSPrototype() *goja.Object

func (DataImpl) GetJSRuntime

func (self DataImpl) GetJSRuntime() *goja.Runtime

func (*DataImpl) GetKeys

func (self *DataImpl) GetKeys(id Identifier) ([]Key, error)

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 (self *DataImpl) HandleBehaviourKeywords(id Identifier, kwargs map[string]interface{}, behaviours []string, isrecursive bool) ([]string, error)

func (*DataImpl) HasBehaviour

func (self *DataImpl) HasBehaviour(name string) bool

func (*DataImpl) HasBehaviourIdentifier

func (self *DataImpl) HasBehaviourIdentifier(id Identifier, name string) (bool, error)

func (*DataImpl) HasKey

func (self *DataImpl) HasKey(id Identifier, key Key) (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 (self DataImpl) KeysAllHaveVersions(keys []datastore.Key) (bool, error)

func (DataImpl) KeysAnyHasUpdates

func (self DataImpl) KeysAnyHasUpdates(keys []datastore.Key) (bool, error)

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 NewDataType(val interface{}) (DataType, error)

func (DataType) AsString

func (self DataType) AsString() string

func (DataType) Encode

func (self DataType) Encode() string

func (DataType) GetDefaultValue

func (self DataType) GetDefaultValue() interface{}

func (DataType) IsBool

func (self DataType) IsBool() bool

func (DataType) IsComplex

func (self DataType) IsComplex() bool

func (DataType) IsEqual

func (self DataType) IsEqual(dt DataType) bool

func (DataType) IsFloat

func (self DataType) IsFloat() bool

func (DataType) IsInt

func (self DataType) IsInt() bool

func (DataType) IsKey

func (self DataType) IsKey() bool

func (DataType) IsNone

func (self DataType) IsNone() bool

func (DataType) IsPOD

func (self DataType) IsPOD() bool

func (DataType) IsRaw

func (self DataType) IsRaw() bool

func (DataType) IsString

func (self DataType) IsString() bool

func (DataType) IsType

func (self DataType) IsType() bool

func (DataType) IsValid

func (self DataType) IsValid() bool

func (DataType) IsVar

func (self DataType) IsVar() bool

func (DataType) MustBeTypeOf

func (self DataType) MustBeTypeOf(val interface{}) error

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
}

func NewEvent

func NewEvent(name string, owner Object) Event

type EventCallback

type EventCallback func(Identifier, ...interface{}) error

type EventEmitNotifyer

type EventEmitNotifyer interface {
	EventEmitted(Identifier, string, ...interface{}) error
}

type EventHandler

type EventHandler interface {
	HasEvent(name string) bool
	AddEvent(evt Event) error
	GetEvent(name string) Event
	Events() []string
	SetupJSEvents(*goja.Object) error
	SetupEventNotifyer(EventEmitNotifyer)
	InitializeEventDB(Identifier) error
}

type EventObjectCallback

type EventObjectCallback struct {
	Id       Identifier
	Function string
}

type Identifier

type Identifier struct {
	Parent [32]byte
	Type   string
	Name   string
	Uuid   string
}

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 NewKey

func NewKey(data interface{}) (Key, error)

func (Key) AsDataType

func (self Key) AsDataType(dt DataType) (interface{}, error)

func (Key) AsString

func (self Key) AsString() string

func (Key) Data

func (self Key) Data() interface{}

func (Key) Equal

func (self Key) Equal(second Key) bool

type Method

type Method interface {
	Call(args ...interface{}) (interface{}, error)
	CallBoolReturn(args ...interface{}) (bool, error)
	IsConst() bool
	IsIdMethod() bool
}

func MustNewIdMethod

func MustNewIdMethod(fnc interface{}, constant bool) Method

func MustNewMethod

func MustNewMethod(fnc interface{}, constant bool) Method

func NewIdMethod

func NewIdMethod(fnc interface{}, constant bool) (Method, error)

func NewMethod

func NewMethod(fnc interface{}, constant bool) (Method, error)

type MethodHandler

type MethodHandler interface {
	AddMethod(name string, method Method)
	HasMethod(name string) bool
	GetMethod(name string) Method
	Methods() []string

	SetupJSMethods(vm *Runtime, obj *goja.Object) error
}

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 NewContinuityBehaviour(rntm *Runtime) (Object, error)

func NewData

func NewData(rntm *Runtime) (Object, error)

func NewGraph

func NewGraph(rntm *Runtime) (Object, error)

func NewMap

func NewMap(rntm *Runtime) (Object, error)

func NewObjectTransactionBehaviour

func NewObjectTransactionBehaviour(rntm *Runtime) (Object, error)

func NewPartialTransactionBehaviour

func NewPartialTransactionBehaviour(rntm *Runtime) (Object, error)

func NewVariant

func NewVariant(rntm *Runtime) (Object, error)

func NewVector

func NewVector(rntm *Runtime) (Object, error)

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

func (self *Runtime) Call(ds *datastore.Datastore, user User, fullpath string, args []interface{}, kwargs map[string]interface{}) (interface{}, []EmmitedEvent, error)

func (Runtime) GetMessages

func (self Runtime) GetMessages() []string

func (*Runtime) InitializeDatastore

func (self *Runtime) InitializeDatastore(ds *datastore.Datastore) error

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

func (self *Runtime) Parse(reader io.Reader) error

Parses the dml code and setups the full structure. Note: Cannot handle local imports

func (*Runtime) ParseFolder

func (self *Runtime) ParseFolder(path string) error

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 NewContinuitySystem(rntm *Runtime) (System, error)

func NewTransactionManager

func NewTransactionManager(rntm *Runtime) (System, error)

type SystemCreatorFunc

type SystemCreatorFunc func(*Runtime) (System, error)

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

func (self *TransactionManager) AddMethod(name string, method Method)

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

func (self *TransactionManager) GetMethod(name string) Method

func (*TransactionManager) HasMethod

func (self *TransactionManager) HasMethod(name string) bool

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

func (self *TransactionManager) Methods() []string

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.

func (*TransactionManager) SetupJSMethods

func (self *TransactionManager) SetupJSMethods(rntm *Runtime, obj *goja.Object) error

type User

type User string

user type to store data about a user

func UserFromData

func UserFromData(data []byte) (User, error)

func (User) Data

func (self User) Data() []byte

Jump to

Keyboard shortcuts

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