sugo-demo-module

4.0.9 • Public • Published

sugo-demo-module

Build Status npm Version JS Standard

Demo of SUGO-Module

Requirements

Node.js NPM

Installation

$ npm install sugo-demo-module --save

Usage

Register a module to actor.

#!/usr/bin/env node
 
/**
 * Example usage to register module on actor
 * @see https://github.com/realglobe-Inc/sugo-actor
 */
'use strict'
 
const sugoDemoModule = require('sugo-demo-module')
const sugoActor = require('sugo-actor')
const co = require('co')
 
co(function * () {
  let actor = sugoActor('http://my-sugo-cloud.example.com/actors', {
    key: 'my-actor-01',
    modules: {
      // Register the module
      module01: sugoDemoModule({})
    }
  })
  yield actor.connect()
}).catch((err) => console.error(err))
 

Then, call the module from a remote caller.

#!/usr/bin/env node
 
/**
 * Example to call from caller
 * @see https://github.com/realglobe-Inc/sugo-caller
 */
'use strict'
 
const co = require('co')
const assert = require('assert')
const sugoCaller = require('sugo-caller')
 
co(function * () {
  let caller = sugoCaller('http://my-sugo-cloud.example.com/callers', {})
  let actor = caller.connect('my-actor-01')
 
  // Access to the module
  let module01 = actor.get('module01')
 
  // Send ping
  let pong = yield module01.ping()
  assert.ok(pong)
}).catch((err) => console.error(err))
 

Methods

The following methods are available from remote callers for the module.

.ping(pong) -> string

Test the reachability of a module.

Param Type Description
pong string Pong message to return

.assert() -> boolean

Test if the actor fulfills system requirements

License

This software is released under the Apache-2.0 License.

Links

Readme

Keywords

Package Sidebar

Install

npm i sugo-demo-module

Weekly Downloads

1

Version

4.0.9

License

Apache-2.0

Last publish

Collaborators

  • realglobe