Documentation ¶
Index ¶
- func ConvertOttoToGo(value interface{}) interface{}
- func GetAuthorization(value otto.Value) (schema.Authorization, error)
- func GetBool(value otto.Value) (bool, error)
- func GetInt64(value otto.Value) (result int64, err error)
- func GetList(value otto.Value) ([]interface{}, error)
- func GetMap(value otto.Value) (map[string]interface{}, error)
- func GetString(value otto.Value) (string, error)
- func GetStringList(value otto.Value) ([]string, error)
- func GetTransaction(value otto.Value) (transaction.Transaction, error)
- func GohanDbCreate(transaction transaction.Transaction, needCommit bool, schemaID string, ...) (*schema.Resource, error)
- func GohanDbDelete(transaction transaction.Transaction, needCommit bool, schemaID, ID string) error
- func GohanDbFetch(tx transaction.Transaction, schemaID, ID, tenantID string) (*schema.Resource, error)
- func GohanDbLockFetch(tx transaction.Transaction, schemaID, ID, tenantID string, ...) (*schema.Resource, error)
- func GohanDbMakeColumns(schemaID string) ([]string, error)
- func GohanDbQuery(transaction transaction.Transaction, needCommit bool, ...) ([]map[string]interface{}, error)
- func GohanDbStateFetch(tx transaction.Transaction, schemaID, ID, tenantID string) (map[string]interface{}, error)
- func GohanDbStateUpdate(transaction transaction.Transaction, needCommit bool, schemaID string, ...) (*schema.Resource, error)
- func GohanDbUpdate(transaction transaction.Transaction, needCommit bool, schemaID string, ...) (*schema.Resource, error)
- func GohanHTTP(ctx context.Context, method, rawURL string, headers map[string]interface{}, ...) (int, http.Header, string, error)
- func GohanModelCreate(context map[string]interface{}, schemaID string, ...) (interface{}, error)
- func GohanModelDelete(context map[string]interface{}, schemaID string, resourceID string) error
- func GohanModelFetch(context map[string]interface{}, schemaID string, resourceID string, ...) (interface{}, error)
- func GohanModelList(context map[string]interface{}, schemaID string, ...) (interface{}, error)
- func GohanModelUpdate(context map[string]interface{}, schemaID string, resourceID string, ...) (interface{}, error)
- func GohanProcessGlobal(name string) map[string]interface{}
- func PushJSLogModule(env *Environment, newModule string) (restore func())
- func RegisterInit(init func(env *Environment))
- func RegisterModule(name string, module interface{})
- func RequireModule(name string) (interface{}, error)
- func ThrowIfHappened(call *otto.FunctionCall, err error)
- func ThrowOtto(call *otto.FunctionCall, exceptionName string, arguments ...interface{})
- func ThrowOttoException(call *otto.FunctionCall, format string, arguments ...interface{})
- func ThrowWithMessageIfHappened(call *otto.FunctionCall, err error, format string, arguments ...interface{})
- func VerifyCallArguments(call *otto.FunctionCall, functionName string, expectedArgumentsCount int)
- type Environment
- func (env *Environment) ClearEnvironment()
- func (env *Environment) Clone() ext.Environment
- func (env *Environment) GetOrCreateTransaction(value otto.Value) (transaction.Transaction, bool, error)
- func (env *Environment) GohanGlobal(name string) map[string]interface{}
- func (env *Environment) HandleEvent(event string, context map[string]interface{}) (err error)
- func (env *Environment) IsEventHandled(event string, context map[string]interface{}) bool
- func (env *Environment) Load(source, code string) error
- func (env *Environment) LoadExtensionsForPath(extensions []*schema.Extension, timeLimit time.Duration, ...) error
- func (env *Environment) RegisterObject(objectID string, object interface{})
- func (env *Environment) SetEventTimeLimit(eventRegex string, timeLimit time.Duration)
- func (env *Environment) SetUp()
- type GlobalStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetAuthorization ¶
func GetAuthorization(value otto.Value) (schema.Authorization, error)
GetAuthorization gets Transaction from otto value
func GetStringList ¶
GetStringList gets []string from otto value
func GetTransaction ¶
func GetTransaction(value otto.Value) (transaction.Transaction, error)
GetTransaction gets Transaction from otto value
func GohanDbCreate ¶
func GohanDbCreate(transaction transaction.Transaction, needCommit bool, schemaID string, dataMap map[string]interface{}) (*schema.Resource, error)
GohanDbCreate adds resource to database
func GohanDbDelete ¶
func GohanDbDelete(transaction transaction.Transaction, needCommit bool, schemaID, ID string) error
GohanDbDelete deletes resource from database
func GohanDbFetch ¶
func GohanDbFetch(tx transaction.Transaction, schemaID, ID, tenantID string) (*schema.Resource, error)
GohanDbFetch gets resource from database
func GohanDbLockFetch ¶
func GohanDbLockFetch(tx transaction.Transaction, schemaID, ID, tenantID string, policy schema.LockPolicy) (*schema.Resource, error)
GohanDbLockFetch gets resource from database
func GohanDbMakeColumns ¶
GohanDbMakeColumns creates columns for given resource in database
func GohanDbQuery ¶
func GohanDbQuery(transaction transaction.Transaction, needCommit bool, schemaID, sqlString string, arguments []interface{}) ([]map[string]interface{}, error)
GohanDbQuery get resources from database with query
func GohanDbStateFetch ¶
func GohanDbStateFetch(tx transaction.Transaction, schemaID, ID, tenantID string) (map[string]interface{}, error)
GohanDbStateFetch gets resource's state from database
func GohanDbStateUpdate ¶
func GohanDbStateUpdate(transaction transaction.Transaction, needCommit bool, schemaID string, dataMap map[string]interface{}) (*schema.Resource, error)
GohanDbStateUpdate updates resource's state in database
func GohanDbUpdate ¶
func GohanDbUpdate(transaction transaction.Transaction, needCommit bool, schemaID string, dataMap map[string]interface{}) (*schema.Resource, error)
GohanDbUpdate updates resource in database
func GohanHTTP ¶
func GohanHTTP(ctx context.Context, method, rawURL string, headers map[string]interface{}, postData interface{}, opaque bool) (int, http.Header, string, error)
GohanHTTP performs a HTTP request
func GohanModelCreate ¶
func GohanModelCreate(context map[string]interface{}, schemaID string, dataMap map[string]interface{}) (interface{}, error)
GohanModelCreate creates gohan resource and running extensions
func GohanModelDelete ¶
GohanModelDelete deletes gohan resources and running extensions
func GohanModelFetch ¶
func GohanModelFetch(context map[string]interface{}, schemaID string, resourceID string, tenantIDs []string) (interface{}, error)
GohanModelFetch fetch gohan resource and running extensions
func GohanModelList ¶
func GohanModelList(context map[string]interface{}, schemaID string, filterMap map[string]interface{}) (interface{}, error)
GohanModelList lists gohan resources and running extensions
func GohanModelUpdate ¶
func GohanModelUpdate(context map[string]interface{}, schemaID string, resourceID string, dataMap map[string]interface{}, tenantIDs []string) (interface{}, error)
GohanModelUpdate updates gohan resource and running extensions
func GohanProcessGlobal ¶
GohanProcessGlobal returns an object global for the whole Gohan process - changes to this object will be seen in all environments. Example:
(test_suite1.env1) var a = gohan_process_global("a"); (test_suite1.env2) var a = gohan_process_global("a"); (other_test_suite.env) var a = gohan_process_global("a"); (test_suite1.env1) a.test = 2; (test_suite1.env2) a.test; // => 2 (other_test_suite.env) a.test; // => 2
func PushJSLogModule ¶
func PushJSLogModule(env *Environment, newModule string) (restore func())
PushJSLogModule appends newModule to log module in env, returns a function that restores the original value
func RegisterModule ¶
func RegisterModule(name string, module interface{})
RegisterModule registers modules
func RequireModule ¶
RequireModule returns module
func ThrowIfHappened ¶
func ThrowIfHappened(call *otto.FunctionCall, err error)
ThrowIfHappened throws an exception with err's message if err happened
func ThrowOtto ¶
func ThrowOtto(call *otto.FunctionCall, exceptionName string, arguments ...interface{})
ThrowOtto throws custom JavaScript exception that will be passed to Otto
func ThrowOttoException ¶
func ThrowOttoException(call *otto.FunctionCall, format string, arguments ...interface{})
ThrowOttoException throws a JavaScript exception that will be passed to Otto
func ThrowWithMessageIfHappened ¶
func ThrowWithMessageIfHappened(call *otto.FunctionCall, err error, format string, arguments ...interface{})
ThrowWithMessageIfHappened throws an exception with the formatted message if err happened
func VerifyCallArguments ¶
func VerifyCallArguments(call *otto.FunctionCall, functionName string, expectedArgumentsCount int)
VerifyCallArguments verify number of calles
Types ¶
type Environment ¶
type Environment struct { Name string VM *motto.Motto DataStore db.DB Identity middleware.IdentityService Sync sync.Sync // contains filtered or unexported fields }
Environment javascript based environment for gohan extension
func NewEnvironment ¶
func NewEnvironment(name string, dataStore db.DB, identity middleware.IdentityService, sync sync.Sync) *Environment
NewEnvironment create new gohan extension environment based on context
func (*Environment) ClearEnvironment ¶
func (env *Environment) ClearEnvironment()
ClearEnvironment closes sync and db in env
func (*Environment) Clone ¶
func (env *Environment) Clone() ext.Environment
Clone makes clone of the environment
func (*Environment) GetOrCreateTransaction ¶
func (env *Environment) GetOrCreateTransaction(value otto.Value) (transaction.Transaction, bool, error)
GetOrCreateTransaction gets transaction from otto value or creates new is otto value is null
func (*Environment) GohanGlobal ¶
func (env *Environment) GohanGlobal(name string) map[string]interface{}
GohanGlobal returns an object global for the Core this environment was created for - changes to this object will be seen in other such environments (but not in environments for other Core's,
e.g. not for other test suites)
Example:
(test_suite1.env1) var a = gohan_global("a"); (test_suite1.env2) var a = gohan_global("a"); (other_test_suite.env) var a = gohan_global("a"); (test_suite1.env1) a.test = 2; (test_suite1.env2) a.test; // => 2 (other_test_suite.env) a.test; // => undefined
func (*Environment) HandleEvent ¶
func (env *Environment) HandleEvent(event string, context map[string]interface{}) (err error)
HandleEvent handles event
func (*Environment) IsEventHandled ¶
func (env *Environment) IsEventHandled(event string, context map[string]interface{}) bool
IsEventHandled returns whether a given event is handled by this environment
func (*Environment) Load ¶
func (env *Environment) Load(source, code string) error
Load loads script for environment
func (*Environment) LoadExtensionsForPath ¶
func (env *Environment) LoadExtensionsForPath(extensions []*schema.Extension, timeLimit time.Duration, timeLimits []*schema.PathEventTimeLimit, path string) error
LoadExtensionsForPath loads extensions for specific path
func (*Environment) RegisterObject ¶
func (env *Environment) RegisterObject(objectID string, object interface{})
RegisterObject register new object for VM
func (*Environment) SetEventTimeLimit ¶
func (env *Environment) SetEventTimeLimit(eventRegex string, timeLimit time.Duration)
SetEventTimeLimit overrides the default time limit for a given event for this environment
type GlobalStore ¶
type GlobalStore struct {
// contains filtered or unexported fields
}
GlobalStore for values living longer that a single extension environment
func (*GlobalStore) Get ¶
func (store *GlobalStore) Get(name string) map[string]interface{}
Get a value registered for name, or, if there is none, register an empty object.