Skip to content
This repository has been archived by the owner on Apr 28, 2021. It is now read-only.

Latest commit

 

History

History
204 lines (120 loc) · 5.5 KB

caller.md

File metadata and controls

204 lines (120 loc) · 5.5 KB

Caller component of SUGOS.

Functions

sugoCaller(config) -> SugoCaller

Create a caller instance. Just an alias of new SugoCaller(config)

Param Type Description
config Object Sugo caller configuration

Example:

co(function * () {
  let caller = sugoCaller({})
  let actor01 = yield caller.connect('my-actor-01')
  let foo = actor01.get('foo') // Get a module of actor
  yield foo.sayYeah() // Call the remote function
}).catch((err) => console.error(err))

SugoCaller Class

Hub client for caller side. When you connect to remote actor with a caller, it receives specification of the actor and dynamically define function to kick actor side function. With this way you can magically call functions declared on remote as if they were here.

Extends:

  • SugoClient

new SugoCaller(config)

Constructor of SugoCaller class

Param Type Description
config Object Caller configuration
config.protocol string Protocol to use ( "http" or "https" )
config.host string Hub host name. ( eg: "localhost:3000" )
config.pathname string Hub URL path name ( eg: "/callers" )
config.auth Object Auth data for hub

caller.connect(key, options) -> Promise.<ActorAccessBundle>

Connect to actor

Param Type Description
key string Key of actor
options Object Optional settings
options.messages Object Connect messages

caller.disconnect(key, options) -> Promise

Disconnect from cloud server

Param Type Description
key string Key of actor to connect
options Object Optional settings
options.messages Object Disconnect messages

caller.urlFromConfig()

ActorAccessBundle Class

Bundle for actor access. This class provides access for loaded modules on actor.

new ActorAccessBundle(specs)

Constructor of ActorAccessBundle class

Param Type Description
specs Object Actor module specs

bundle.get(moduleName, options) -> ActorAccessModule

Get a module

Param Type Description
moduleName string Name of module
options Object Optional settings

bundle.has(moduleName) -> Boolean

Check if module exists

Param Type Description
moduleName string Name of module

bundle.set(moduleName, module, options)

Set module

Param Type Description
moduleName string Name of module
module ActorAccessModule Module to set
options Object Optional settings

bundle.del(moduleName)

Delete module

Param Type Description
moduleName string Name of module

bundle.names() -> Array.<string>

Get names of modules

ActorAccessModule Class

Loaded module for an actor. This class provides pseudo interfaces for remote actor module

new ActorAccessModule(methods, connection)

Constructor of ActorAccessModule class

Param Type Description
methods Object Actor specifications for module methods
connection Object Actor connections