Stability: 2 - Unstable
WARNING
This project is in active development and is not feature-complete yet, but is already mature enough.
The documentation of this specific implementation is not complete either.
FutoIn reference implementation
Reference implementation of:
FTN7: FutoIn Invoker Concept
Version: 1.3
FTN3: FutoIn Interface Definition
Version: 1.1
Spec FTN7: FTN7: Interface Invoker Concept v1.x
Spec FTN3: FTN3: FutoIn Interface Definition v1.x
Web Site
About
FutoIn Invoker is a peer which initiates a request - invokes a FutoIn interface method
as described in FTN3: FutoIn Interface Definition.
It is not necessary a client - e.g. server may initiate request for event delivery to client.
The method can be implemented locally or remotely - it is transparent to invoking code.
A similar concept can be found in CORBA and other more heavy request brokers.
Strict FutoIn interface (iface) definition and transport protocol is defined in FTN3 spec mentioned above.
As it is based on JSON, both client and server can be implemented in a few minutes almost in
any technology. However, Invoker and Executor concept provide significant benefits for
efficiency, reliability and error control.
The core of invoker is CCM - Connection and Credentials Manager.
It has the following advantages:
- A single place to configure & hold sensitive data (like credentials)
- Transparent connection management (no need for special connect/request/response/disconnect logic)
- Efficient use of communications (keep-alive, persistent WebSockets channels,
channel-based instead of message-based security, etc.)
- Inversion of Control / Dependency Injection - implementations are referenced by
static names like "mymodule.some.service" in code. The rest is hidden in CCM configuration.
The primary communication channel is WebSockets. Large raw data upload and download
is also supported through automatic fallback to HTTP(S).
SimpleCCM - a light version without heavy processing of iface definition (ideal for browser)
AdvancedCCM - full featured CCM (extends SimpleCCM)
Note: Invoker and Executor are platform/technology-neutral concepts. The implementation
is already available in JS and PHP. Hopefully, others are upcoming
Installation for Node.js
Command line:
$ npm install futoin-invoker --save
Installation for Browser
$ bower install futoin-invoker --save
Please note that browser build is available under in dist/ folder in sources generated
with pure-sjc. It depends on
lodash.
Note: there are the following globals available:
-
SimpleCCM - global reference to futoin-invoker.SimpleCCM class
-
AdvancedCCM - global reference to futoin-invoker.AdvancedCCM class
-
futoin.Invoker - global reference to futoin-invoker module
API documentation
The concept is described in FutoIn specification: FTN7: Interface Invoker Concept v1.x
#Index
Modules
Classes
- class: InterfaceInfo
- class: NativeIface
- class: spectools
- new spectools()
- spectools.loadIface(as, info, specdirs)
- spectools.parseIface(as, info, specdirs, raw_spec)
- spectools.checkConsistency(as, info)
- spectools.checkType(info, type, val)
- spectools.checkParameterType(as, info, funcname, varname, value)
- spectools.checkResultType(as, info, funcname, varname, value)
- const: spectools.standard_errors
Members
#futoin-invoker
Members
##class: futoin-invoker.SimpleCCM
Members
###new futoin-invoker.SimpleCCM([options])
Simple CCM - Reference Implementation
Params
- [options]
object
- map of OPT_* named variables
##class: futoin-invoker.AdvancedCCM
Members
###new futoin-invoker.AdvancedCCM()
Advanced CCM - Reference Implementation
##class: futoin-invoker.FutoInError
Members
###new futoin-invoker.FutoInError()
Easy access of futoin-asyncsteps.FutoInError errors, which may be extended in the future
##class: futoin-invoker.NativeIface
Members
###new futoin-invoker.NativeIface()
Useful base for custom implementation of NativeIface
##class: futoin-invoker.InterfaceInfo
Members
###new futoin-invoker.InterfaceInfo()
NativeInterface.ifaceInfo() class for custom implementations of NativeIface
#class: InterfaceInfo
Members
##new InterfaceInfo()
FutoIn interface info
##interfaceInfo.name()
Get FutoIn interface type
Returns: string
##interfaceInfo.version()
Get FutoIn interface version
Returns: string
##interfaceInfo.inherits()
Get list of inherited interfaces starting from the most derived, may be null
Returns: object
##interfaceInfo.funcs()
Get list of available functions, may be null
Returns: object
##interfaceInfo.constraints()
Get list of interface constraints, may be null
Returns: object
#class: NativeIface
Members
##new NativeIface()
Native Interface for FutoIn ifaces
##nativeIface.call(as, name, params, upload_data, [download_stream], [timeout])
Generic FutoIn function call interface
Result is passed through AsyncSteps.success() as a map.
Params
- as
AsyncSteps
- AsyncSteps object - name
string
- FutoIn iface function name - params
object
- map of func parameters - upload_data
string
| stream.Readable
- raw upload data or input stram - [download_stream]
stream.Writable
- output stream for raw download data - [timeout]
int
- if provided, overrides the default. <=0 - disables timeout
##nativeIface.ifaceInfo()
Get interface info
Returns: object
##nativeIface.burst()
Returns extended API interface as defined in [FTN10 Burst Calls][]
Returns: object
##nativeIface.bindDerivedKey()
Results with DerivedKeyAccessor through as.success()
#class: spectools
Members
- class: spectools
- new spectools()
- spectools.loadIface(as, info, specdirs)
- spectools.parseIface(as, info, specdirs, raw_spec)
- spectools.checkConsistency(as, info)
- spectools.checkType(info, type, val)
- spectools.checkParameterType(as, info, funcname, varname, value)
- spectools.checkResultType(as, info, funcname, varname, value)
- const: spectools.standard_errors
##new spectools()
SpecTools
##spectools.loadIface(as, info, specdirs)
Load FutoIn iface definition.
NOTE: Browser uses XHR to load specs, Node.js searches in local fs.
Params
- as
AsyncSteps
- info
Object
- destination object with "iface" and "version" fields already set - specdirs
Array
- each element - search path/url (string) or raw iface (object)
##spectools.parseIface(as, info, specdirs, raw_spec)
Parse raw futoin spec (preloaded)
Params
- as
AsyncSteps
- info
Object
- destination object with "iface" and "version" fields already set - specdirs
Array
- each element - search path/url (string) or raw iface (object) - raw_spec
Object
- iface definition object
##spectools.checkConsistency(as, info)
Deeply check consistency of loaded interface.
NOTE: not yet implemented
Params
- as
AsyncSteps
- info
Object
- previously loaded iface
##spectools.checkType(info, type, val)
Check if value matches required type
Params
- info
Object
- previously loaded iface - type
string
- standard or custom iface type - val
*
- value to check
Returns: Boolean
##spectools.checkParameterType(as, info, funcname, varname, value)
Check if parameter value matches required type
Params
- as
AsyncSteps
- info
Object
- previously loaded iface - funcname
string
- function name - varname
string
- parameter name - value
*
- value to check
##spectools.checkResultType(as, info, funcname, varname, value)
Check if result value matches required type
Params
- as
AsyncSteps
- info
Object
- previously loaded iface - funcname
string
- function name - varname
string
- result variable name - value
*
- value to check
##const: spectools.standard_errors
Enumeration of standard errors
#SimpleCCM
window.SimpleCCM - Browser-only reference to futoin-asyncsteps.SimpleCCM
#AdvancedCCM
window.AdvancedCCM - Browser-only reference to futoin-asyncsteps.AdvancedCCM
#Invoker
futoin.Invoker - Browser-only reference to futoin-invoker module
#FutoInInvoker
window.FutoInInvoker - Browser-only reference to futoin-invoker module
documented by jsdoc-to-markdown.