Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

seneca-transport

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

seneca-transport

Seneca transport

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.9K
increased by49.11%
Maintainers
1
Weekly downloads
 
Created
Source

seneca-transport

An action transport plugin for the Seneca framework

This plugin allows you to execute Seneca actions in separate Seneca processes. The default transport mechanism is HTTP. Redis publish-subscribe is also built-in.

This plugin provides the implementation for the listen, client, and proxy convenience methods on the Seneca object. It is included as a dependent module of the Seneca module.

You can provide your own transport mechanisms by overriding the transport action patterns (see below).

Support

If you're using this module, feel free to contact me on Twitter if you have any questions! :) @rjrodger

Current Version: 0.2.0

Tested on: Node 0.10.29, Seneca 0.5.18

Build Status

Quick example

First, define a service (this is just a Seneca plugin):

module.exports = function() {
  this.add( 'foo:1', function(args,done){done(null,{s:'1-'+args.bar})} )
  this.add( 'foo:2', function(args,done){done(null,{s:'2-'+args.bar})} )
}

Start the service:

require('seneca')()
  .use('foo')
  .listen()

And talk to it:

require('seneca')()
  .listen()
  .ready(function(){
    this.act('foo:1,bar:A',function(err,out){console.log(out)})
    this.act('foo:2,bar:B',function(err,out){console.log(out)})
  })

And this prints:

1-A
2-B

To run this example, try in one terminal

node test/service-foo.js

and in another:

node test/client-foo.js

Install

This module is included in the standard Seneca module, so install using that:

npm install seneca

Action Patterns

role:transport, cmd:listen

Starts listening for actions. The type argument specifies the transport mechanism. Current built-ins are direct (which is HTTP), and pubsub (which is Redis).

role:transport, cmd:client

Create a Seneca instance that sends actions to a remote service. The type argument specifies the transport mechanism.

Hook Patterns

These patterns are called by the primary action patterns. Add your own for additional transport mechanisms.

  • role:transport, hook:listen, type:direct
  • role:transport, hook:client, type:pubsub
  • role:transport, hook:listen, type:direct
  • role:transport, hook:client, type:pubsub

These all take additional configuration arguments, which are passed through from the primary actions:

  • host
  • port
  • path (not used by pubsub)

Pattern Selection

If you only want to transport certain action patterns, use the pin argument to pick these out. See the test/client-pubsub-foo.js and test/service-pubsub-foo.js files for an example.

Logging

To see what this plugin is doing, try:

node your-app.js --seneca.log=plugin:transport

To skip the action logs, use:

node your-app.js --seneca.log=type:plugin,plugin:transport

For more on logging, see the seneca logging example.

Test

This module itself does not contain any direct reference to seneca, as it is a seneca dependency. However, seneca is needed to test it, so the test script will perform an npm install seneca (if needed). This is not saved to package.json however.

npm test

Keywords

FAQs

Package last updated on 06 Jul 2014

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc