Socket
Socket
Sign inDemoInstall

octopod

Package Overview
Dependencies
198
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    octopod

Classes and interfaces to help the making of services or the call of services for the 'octopod-core' npm package.


Version published
Weekly downloads
6
increased by200%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

octopod

Octopod is a npm package to ease the making of octopod services and octopod service calls in the octopod network.

The octopod network is a network working around one or many octopod cores. An octopod core is a webdav server which allow the management of octopod services and allow them to work together. An octopod service is a node in the octopod network linked directly to the octopod core. A client or another octopod service can command or call a method of a octopod service through the octopod core.

Here is a generic example of an octopod :

Services - Core - Clients

This module allow to :

  • Create a service
  • Call a service's method

Install

npm install octopod

Usage

Create a service

import { Service } from 'octopod'

class BlaBlaService extends Service
{
    constructor(coreUrl : string)
    {
        super('blabla', coreUrl);
    }

    start()
    {
        this.reference({
            inputs: {
                'methodName': {
                    isVolatile: true,
                    mainOutputMethod: 'outputMethodName', // The outputMethodName which will contain the returned data
                    outputs: {
                        'outputMethodName': 1 // Might pipe to another method
                    }
                }
            }
        }, (e) => {
            if(e)
                throw e;
            
            this.bindMethod('methodName', (data, info) => {
                this.putObject(info.mainOutput, {
                    value: data.value + ' blabla'
                }, (e) => {
                    this.log('Responded');
                    this.dispose(info);
                })
            })
        })
    }
}

const service = new BlaBlaService('http://...');

// Define a command "stop" for this service
service.commands['stop'] = (input, cb) => {
    cb();
    process.exit();
}

service.start();

Call a service's method

import { call } from 'octopod'

this.call('http://...', 'blabla', 'methodName', {
    value: 'so?'
}, (response, paths, cleanup) => {
    console.log(response.value); // Will display 'so? blabla'
    cleanup();
})

FAQs

Last updated on 06 Aug 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc