How to use seneca - 10 common examples

To help you get started, we’ve selected a few seneca examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github senecajs-attic / getting-started / math-pin-client.js View on Github external
require( 'seneca' )()

  // a local pattern
  .add( 'say:hello', function( msg, respond ){ respond( null, {text:"Hi!"} ) } )

  // send any role:math patterns out over the network
  // IMPORTANT: must match listening service
  .client( { type:'tcp', pin:'role:math' } )

  // executed remotely
  .act('role:math,cmd:sum,left:1,right:2',console.log)

  // executed locally
  .act('say:hello',console.log)
github BarnesFoundation / barnes-tms-extract / src / scripts / nightlyColorProcess.js View on Github external
const exec = require('child_process').exec;
const path = require('path');
const logger = require('../util/logger.js')(path.join(__dirname, "logs/cron_logs.txt"));

logger.info("Beginning color process nightly cron");

// Run the CSV processing script
logger.info("Processing Cooper-Hewitt color data");
const seneca = require('seneca')() // eslint-disable-line
	.client({ type: 'tcp', pin: 'role:color', port: 10205 })
	.act('role:color,cmd:process', () => {
		logger.info("Exiting");
		process.exit(0);
	});
github BarnesFoundation / barnes-tms-extract / src / scripts / tileImages.js View on Github external
const seneca = require('seneca')({ // eslint-disable-line
	transport: {
		tcp: {
			timeout: 60000,
		},
	},
})
  .client({ type: 'tcp', pin: 'role:images', port: 10204, timeout: 60000 })
  .act('role:images,cmd:tile', () => {
	process.exit(0);
});
github BarnesFoundation / barnes-tms-extract / src / scripts / nightlyRun.js View on Github external
const path = require('path');
const logger = require('../util/logger.js')(path.join(__dirname, "logs/cron_logs.txt"));

const argv = require('minimist')(process.argv.slice(2));

const source = argv.d || path.resolve(__dirname, '../dashboard/public/output');

logger.info("Beginning nightly cron");

// Cleanup old CSVs
logger.info("Cleaning up old CSVs");
exec(['node', path.resolve(__dirname, './oldCSVClean.js'), '-d', source].join(' '));

// Run the CSV processing script
logger.info("Pulling latest from TMS");
const seneca = require('seneca')() // eslint-disable-line
	.client({ type: 'tcp', pin: 'role:tmstocsv' })
	.act('role:tmstocsv,cmd:runNightly', () => {
		logger.info("Exiting");
		process.exit(0);
	});
github senecajs / seneca-mesh / trial / base.js View on Github external
// To run:
// $ node base.js

var HOST = process.env.HOST || process.argv[2]
var BASES = (process.env.BASES || process.argv[3] || '').split(',')
var PORT = process.env.PORT
var BROADCAST = process.env.BROADCAST
var REGISTRY = JSON.parse(process.env.REGISTRY || '{"active":false}')

require('seneca')({ tag: 'b0', legacy: {transport: false} })
  .test()
  .use('consul-registry', REGISTRY || {})
  .use('..', {
    monitor: true,
    isbase: true,
    host: HOST,
    port: PORT,
    bases: BASES,
    discover: {
      multicast: {
        address: BROADCAST
      },
      registry: REGISTRY
    },
    dumpnet: false,
    sneeze: {
github senecajs / seneca-mesh / trial / foo.js View on Github external
// To run:
// $ node service-foo.js

var HOST = process.env.HOST || process.argv[2]
var BASES = (process.env.BASES || process.argv[3] || '').split(',')
var BROADCAST = process.env.BROADCAST
var REGISTRY = JSON.parse(process.env.REGISTRY || '{"active":false}')

require('seneca')({ tag: 'foo', legacy: {transport: false} })
  .test()
  .add('foo:1', function(msg, done) {
    done(null, { x: 1, v: 100 + msg.v })
  })
  .add('zed:1', function(msg, done) {
    done(null, { z: 1, f: 1, v: 100 + msg.v })
  })
  .add('zed:1,q:1', function(msg, done) {
    done(null, { z: 1, f: 1, q:1, v: 100 + msg.v })
  })
  .use('consul-registry', REGISTRY || {})
  .use('..', {
    pin: 'foo:1',
    host: HOST,
    bases: BASES,
    override:true,
github senecajs / seneca-mesh / trial / bar.js View on Github external
// To run:
// $ node service-foo.js

var HOST = process.env.HOST || process.argv[2]
var BASES = (process.env.BASES || process.argv[3] || '').split(',')
var BROADCAST = process.env.BROADCAST
var REGISTRY = JSON.parse(process.env.REGISTRY || '{"active":false}')

require('seneca')({ tag: 'bar', legacy: {transport: false} })
  .test()
  .add('bar:1', function(msg, done) {
    done(null, { y: 1, v: 100 + msg.v })
  })
  .add('zed:1', function(msg, done) {
    done(null, { z: 2, v: 100 + msg.v })
  })
  .use('consul-registry', REGISTRY || {})
  .use('..', {
    listen:[
      {pin: 'bar:1'},
      {pin: 'zed:1'},
    ],
    host: HOST,
    bases: BASES,
    discover: {
github sfast / zeronode / benchmarks / seneca / seneca-server.js View on Github external
import Seneca from 'seneca'

let seneca = Seneca({timeout: 1000000});

seneca.add('foo:*', (msg, reply) => {
  // console.log('received request:', msg)
  reply(new Buffer(1000))
})

seneca.listen({port: 9000, type: 'tcp'})
github BarnesFoundation / barnes-tms-extract / src / csv_viewer / src / csv-pin-service.js View on Github external
const argv = require('minimist')(process.argv.slice(2));

const d = argv.d;

require('seneca')()

  .use('csv', { d })

  // listen for role:math messages
  // IMPORTANT: must match client
  .listen({ type: 'tcp', pin: 'role:csv', port: 10202 });
github senecajs / seneca-transport / test / stubs / service-foo.js View on Github external
'use strict'

var type = process.argv[2]
console.log('TYPE:' + type)

require('seneca')()
  .use('../transport.js')
  .use('foo')
  .listen({type: type})

seneca

A Microservices Framework for Node.js

MIT
Latest version published 4 months ago

Package Health Score

70 / 100
Full package analysis