senecajs / seneca Goto Github PK
View Code? Open in Web Editor NEWA microservices toolkit for Node.js.
Home Page: http://senecajs.org
License: MIT License
A microservices toolkit for Node.js.
Home Page: http://senecajs.org
License: MIT License
provide an 'options' property on returned plugin meta data - this is an object that will be deepextended with user supplied options
removes the need to deepextend call inside plugin
var seneca = require('seneca')()
seneca.add( {cmd:'sales-tax'}, function(args,callback){
var rate = 0.23
var total = args.net * (1+rate)
callback(null,{total:total})
})
seneca.act( {cmd:'salestax', net:100}, function(err,result){
console.log( result.total )
})
command name doesn't match
sales-tax
and salestax
The 'ready' event is not emitted unless seneca.ready(function(){...}) is used.
I believe this is due to this:
https://github.com/rjrodger/seneca/blob/master/lib/seneca.js#L1022-L1024
I'm not sure about the reason(s) for that if condition and using a different API than the one EventEmitter provides. In any case I worked around it :)
I found that seneca.listen() can work with seneca.client(), but app.listen() can't work with seneca.client(), why?
Server.js
var app = connect()
app.use( connect.query() )
app.use( connect.json() )
app.use( seneca.export('web') )
app.listen(3000)
client.js
seneca.client(3000)
var shop = seneca.pin({role:'shop',cmd:'*'})
shop.salestax({net:100}, function(err,result){
console.log( result.total )
})
the real name is seneca.options.js
if options.seneca.js exists, complain and die, because nasty ambiguous
In a remote scenario, if an action callback does not fire for some reason, the rest of the same action responses do not get sent back to the requester, making the action side appear stuck. Once that program gets terminated, a lot of [Error: Seneca: connect ECONNREFUSED]
appear on the other program.
How about implement something like PUB/SUB mechanism to handle use cases that the ONE event producer and N event consumers needs to be connected?
The commands in seneca seems much more like ONE to ONE request/reply pattern.
I'm not sure if that is the same issue as seneca catching 'uncaught exceptions' but I have a test with 'asserts'. I'd expect the tests to fail with an error for which the stack top level line is where the assert line is, not in seneca's internals.
describe('archive', function() {
it('save', function(done) {
var foobarEntity = primarySeneca.make('foo/bar')
foobarEntity.save$({db: 'primary', archiveAttr: false}, function(err, result) {
assert.ok(!err, err ? err.message + err.stack : undefined)
foobarEntity.save$({db: 'secondary', archiveAttr: true}, function(err, secondaryResult) {
assert.ok(!err, err ? err.message + err.stack : undefined)
var foobarEntitySecondary = secondarySeneca.make('foo/bar')
foobarEntitySecondary.load$({id: secondaryResult.id}, function(err, archivedEntity) {
assert.ok(!err, err ? err.message + err.stack : undefined)
assert.ok(archivedEntity)
assert.equal(archivedEntity.id, secondaryResult.id)
done()
})
})
})
})
})
2014-05-13T15:34:23.120Z ERROR act err 0ptr7z callback Seneca/0.5.17/xauigd: {name=AssertionError,actual=,expected=true,operator===,message=null == true} botzgv at Seneca.<anonymous> (/Users/nherment/workspace/seneca-archive/node_modules/seneca/plugin/mem-store.js:133:9)
1) save
✓ list
12 passing (18ms)
1 failing
1) archive save:
Error: Seneca/0.5.17/xauigd: {name=AssertionError,actual=,expected=true,operator===,message=null == true}
at act_done (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1529:25)
at Seneca.<anonymous> (/Users/nherment/workspace/seneca-archive/node_modules/seneca/plugin/mem-store.js:133:9)
at list (/Users/nherment/workspace/seneca-archive/node_modules/seneca/plugin/mem-store.js:55:6)
at Seneca.store.load (/Users/nherment/workspace/seneca-archive/node_modules/seneca/plugin/mem-store.js:130:7)
at perform (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1551:22)
at do_act (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1422:17)
at Seneca.api_act [as act] (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1255:10)
at Entity.load$ (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/entity.js:192:6)
at Seneca.<anonymous> (/Users/nherment/workspace/seneca-archive/test/archive.test.js:37:31)
at act_done (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1516:16)
at Seneca.<anonymous> (/Users/nherment/workspace/seneca-archive/archive.js:119:9)
at act_done (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1516:16)
at do_save (/Users/nherment/workspace/seneca-archive/node_modules/seneca/plugin/mem-store.js:121:9)
at Seneca.<anonymous> (/Users/nherment/workspace/seneca-archive/node_modules/seneca/plugin/mem-store.js:100:13)
at act_done (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1516:16)
at Seneca.cmd_generate_id (/Users/nherment/workspace/seneca-archive/node_modules/seneca/plugin/util.js:85:5)
at perform (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1551:22)
at do_act (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1422:17)
at Seneca.api_act (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1255:10)
at Seneca.delegate.act (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1825:11)
at Seneca.delegate.act (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1825:11)
at Seneca.store.save (/Users/nherment/workspace/seneca-archive/node_modules/seneca/plugin/mem-store.js:98:16)
at perform (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1551:22)
at do_act (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1422:17)
at Seneca.delegate.prior.delegate.parent (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1458:13)
at Seneca.executePrimaryThenFallbackToSecondary (/Users/nherment/workspace/seneca-archive/archive.js:108:10)
at Seneca.saveOverride (/Users/nherment/workspace/seneca-archive/archive.js:42:45)
at perform (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1551:22)
at do_act (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1422:17)
at Seneca.api_act [as act] (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1255:10)
at Entity.save$ (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/entity.js:160:6)
at Seneca.<anonymous> (/Users/nherment/workspace/seneca-archive/test/archive.test.js:32:20)
at act_done (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1516:16)
at Seneca.<anonymous> (/Users/nherment/workspace/seneca-archive/archive.js:119:9)
at act_done (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1516:16)
at do_save (/Users/nherment/workspace/seneca-archive/node_modules/seneca/plugin/mem-store.js:121:9)
at Seneca.<anonymous> (/Users/nherment/workspace/seneca-archive/node_modules/seneca/plugin/mem-store.js:100:13)
at act_done (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1516:16)
at Seneca.cmd_generate_id (/Users/nherment/workspace/seneca-archive/node_modules/seneca/plugin/util.js:85:5)
at perform (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1551:22)
at do_act (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1422:17)
at Seneca.api_act (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1255:10)
at Seneca.delegate.act (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1825:11)
at Seneca.delegate.act (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1825:11)
at Seneca.store.save (/Users/nherment/workspace/seneca-archive/node_modules/seneca/plugin/mem-store.js:98:16)
at perform (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1551:22)
at do_act (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1422:17)
at Seneca.delegate.prior.delegate.parent (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1458:13)
at Seneca.executePrimaryThenFallbackToSecondary (/Users/nherment/workspace/seneca-archive/archive.js:108:10)
at Seneca.saveOverride (/Users/nherment/workspace/seneca-archive/archive.js:42:45)
at perform (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1551:22)
at do_act (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1422:17)
at Seneca.api_act [as act] (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/seneca.js:1255:10)
at Entity.save$ (/Users/nherment/workspace/seneca-archive/node_modules/seneca/lib/entity.js:160:6)
at Context.<anonymous> (/Users/nherment/workspace/seneca-archive/test/archive.test.js:28:18)
at Test.Runnable.run (/Users/nherment/workspace/seneca-archive/node_modules/mocha/lib/runnable.js:196:15)
at Runner.runTest (/Users/nherment/workspace/seneca-archive/node_modules/mocha/lib/runner.js:374:10)
at /Users/nherment/workspace/seneca-archive/node_modules/mocha/lib/runner.js:452:12
at next (/Users/nherment/workspace/seneca-archive/node_modules/mocha/lib/runner.js:299:14)
at /Users/nherment/workspace/seneca-archive/node_modules/mocha/lib/runner.js:309:7
at next (/Users/nherment/workspace/seneca-archive/node_modules/mocha/lib/runner.js:247:23)
at Object._onImmediate (/Users/nherment/workspace/seneca-archive/node_modules/mocha/lib/runner.js:276:5)
at processImmediate [as _immediateCallback] (timers.js:330:15)
this.prior is key functionality!
needs to be documented with examples etc
Did Something seems to have changed in the last month or so?
Our app is now getting.
Seneca Fatal Error
==================
Message: use-plugin: Could not load plugin ./lib/store-extend; require search list: ./lib/store-extend, seneca-./lib/store-extend, ././lib/store-extend, ./seneca-./lib/store-extend.
Code: plugin_not_found
Any ideas on how to best sort this out?
package.json
dependency is listed as
"seneca": "~0.5.15",
Did something big change in a patch release?
I noticed #50 but it didn't have a lot of detail.
Cheers
The problem is that seneca-data-editor uses the http api that was deprecated in version 0.5.17 (https://github.com/rjrodger/seneca/blob/master/lib/seneca.js#L935). Now that api has been removed so the plugins throws exception.
as an option
calls canon$() on them to get entity type
need to generate a die error in this case
Using the example on the website I created a file with the contents:
require('seneca')()
.add(
{ generate:'id'},
function( message, done ) {
done( null,
{id:''+Math.random()} )
})
.listen()
and then proceeded to curl this service using the command:
curl -d '{"generate":"id"}' http://localhost:10101/act
This works fine up until 0.5.17. From 0.5.18 onwards I receive a json parse error as follows:
node index.js
2014-08-24T16:23:55.864Z 8rq0ry08ze3b/1408897435856/- INFO hello Seneca/0.5.18/8rq0ry08ze3b/1408897435856/-
2014-08-24T16:23:56.505Z 8rq0ry08ze3b/1408897435856/- INFO plugin transport - mnr3okpkcd39 listen open {type=tcp,host=localhost,port=10101,timeout=32778,path=,role=transport,hook=listen} Seneca/0.5.18/8rq0ry08ze3b/1408897435856/-
2014-08-24T16:24:02.182Z 8rq0ry08ze3b/1408897435856/- INFO plugin transport - mnr3okpkcd39 listen connection {type=tcp,host=localhost,port=10101,timeout=32778,path=,role=transport,hook=listen} Seneca/0.5.18/8rq0ry08ze3b/1408897435856/- remote 127.0.0.1 54025
2014-08-24T16:24:02.191Z 8rq0ry08ze3b/1408897435856/- ERRO plugin transport - json-parse stream POST /act HTTP/1.1 SyntaxError: Unexpected token P
at Object.parse (native)
at parseJSON (/Users/digitalsadhu/src/map-engine/node_modules/seneca/node_modules/seneca-transport/transport.js:897:21)
at Duplex.json_parser._write (/Users/digitalsadhu/src/map-engine/node_modules/seneca/node_modules/seneca-transport/transport.js:297:20)
at doWrite (_stream_writable.js:226:10)
at writeOrBuffer (_stream_writable.js:216:5)
at Duplex.Writable.write (_stream_writable.js:183:11)
at write (_stream_readable.js:582:24)
at flow (_stream_readable.js:591:7)
at Socket.pipeOnReadable (_stream_readable.js:623:5)
at Socket.EventEmitter.emit (events.js:92:17)
2014-08-24T16:24:02.193Z 8rq0ry08ze3b/1408897435856/- ERRO plugin transport - json-parse stream User-Agent: curl/7.30SyntaxError: Unexpected token U
at Object.parse (native)
at parseJSON (/Users/digitalsadhu/src/map-engine/node_modules/seneca/node_modules/seneca-transport/transport.js:897:21)
at Duplex.json_parser._write (/Users/digitalsadhu/src/map-engine/node_modules/seneca/node_modules/seneca-transport/transport.js:297:20)
at doWrite (_stream_writable.js:226:10)
at writeOrBuffer (_stream_writable.js:216:5)
at Duplex.Writable.write (_stream_writable.js:183:11)
at write (_stream_readable.js:582:24)
at flow (_stream_readable.js:591:7)
at Socket.pipeOnReadable (_stream_readable.js:623:5)
at Socket.EventEmitter.emit (events.js:92:17)
2014-08-24T16:24:02.193Z 8rq0ry08ze3b/1408897435856/- ERRO plugin transport - json-parse stream Host: localhost:10101SyntaxError: Unexpected token H
at Object.parse (native)
at parseJSON (/Users/digitalsadhu/src/map-engine/node_modules/seneca/node_modules/seneca-transport/transport.js:897:21)
at Duplex.json_parser._write (/Users/digitalsadhu/src/map-engine/node_modules/seneca/node_modules/seneca-transport/transport.js:297:20)
at doWrite (_stream_writable.js:226:10)
at writeOrBuffer (_stream_writable.js:216:5)
at Duplex.Writable.write (_stream_writable.js:183:11)
at write (_stream_readable.js:582:24)
at flow (_stream_readable.js:591:7)
at Socket.pipeOnReadable (_stream_readable.js:623:5)
at Socket.EventEmitter.emit (events.js:92:17)
2014-08-24T16:24:02.195Z 8rq0ry08ze3b/1408897435856/- ERRO plugin SyntaxError: Unexpected token Arse stream Accept: */*
at Object.parse (native)
at parseJSON (/Users/digitalsadhu/src/map-engine/node_modules/seneca/node_modules/seneca-transport/transport.js:897:21)
at Duplex.json_parser._write (/Users/digitalsadhu/src/map-engine/node_modules/seneca/node_modules/seneca-transport/transport.js:297:20)
at doWrite (_stream_writable.js:226:10)
at writeOrBuffer (_stream_writable.js:216:5)
at Duplex.Writable.write (_stream_writable.js:183:11)
at write (_stream_readable.js:582:24)
at flow (_stream_readable.js:591:7)
at Socket.pipeOnReadable (_stream_readable.js:623:5)
at Socket.EventEmitter.emit (events.js:92:17)
2014-08-24T16:24:02.195Z 8rq0ry08ze3b/1408897435856/- ERRO plugin transport - json-parse stream Content-Length: 17 SyntaxError: Unexpected token C
at Object.parse (native)
at parseJSON (/Users/digitalsadhu/src/map-engine/node_modules/seneca/node_modules/seneca-transport/transport.js:897:21)
at Duplex.json_parser._write (/Users/digitalsadhu/src/map-engine/node_modules/seneca/node_modules/seneca-transport/transport.js:297:20)
at doWrite (_stream_writable.js:226:10)
at writeOrBuffer (_stream_writable.js:216:5)
at Duplex.Writable.write (_stream_writable.js:183:11)
at write (_stream_readable.js:582:24)
at flow (_stream_readable.js:591:7)
at Socket.pipeOnReadable (_stream_readable.js:623:5)
at Socket.EventEmitter.emit (events.js:92:17)
2014-08-24T16:24:02.196Z 8rq0ry08ze3b/1408897435856/- ERRO plugin transport - json-parse stream Content-Type: applicaSyntaxError: Unexpected token C
at Object.parse (native)
at parseJSON (/Users/digitalsadhu/src/map-engine/node_modules/seneca/node_modules/seneca-transport/transport.js:897:21)
at Duplex.json_parser._write (/Users/digitalsadhu/src/map-engine/node_modules/seneca/node_modules/seneca-transport/transport.js:297:20)
at doWrite (_stream_writable.js:226:10)
at writeOrBuffer (_stream_writable.js:216:5)
at Duplex.Writable.write (_stream_writable.js:183:11)
at write (_stream_readable.js:582:24)
at flow (_stream_readable.js:591:7)
at Socket.pipeOnReadable (_stream_readable.js:623:5)
at Socket.EventEmitter.emit (events.js:92:17)
2014-08-24T16:24:02.197Z 8rq0ry08ze3b/1408897435856/- ERRO plugin SyntaxError: Unexpected end of input stream
at Object.parse (native)
at parseJSON (/Users/digitalsadhu/src/map-engine/node_modules/seneca/node_modules/seneca-transport/transport.js:897:21)
at Duplex.json_parser._write (/Users/digitalsadhu/src/map-engine/node_modules/seneca/node_modules/seneca-transport/transport.js:297:20)
at doWrite (_stream_writable.js:226:10)
at writeOrBuffer (_stream_writable.js:216:5)
at Duplex.Writable.write (_stream_writable.js:183:11)
at write (_stream_readable.js:582:24)
at flow (_stream_readable.js:591:7)
at Socket.pipeOnReadable (_stream_readable.js:623:5)
at Socket.EventEmitter.emit (events.js:92:17)
Right now we don't document anything regarding plugins besides the very simplest case.
We should put more examples in docs including async initiation and document following options:
add
shorthandexportmap
tag
, service
, name
Hi,
I have the following pattern:
seneca.add({cmd: 'get-lists', type: 'mailchimp'}, getLists);
I want all the calls to seneca.act to be like:
seneca.act({cmd: 'get-lists', type: 'mailchimp', dc: 'us8', function() {...})
where 'dc' is required (but it's dynamic), if it's not supplied - throw an error without even reaching the getLists function. Is that possible ? I can check if the args are not complete and then throw an error, but that's boilerplate that I rather not duplicate.
I think it will be best if we can even use regular expressions inside 'dc', so we can just write a regexp that fits exactly what we consider as valid input.
Hi,
When I experiments with Seneca, I found two much callback needed especially about data entity.
Promise is a very good way to improve callback hell and provide robust error handling mechanism.
What about adding promise support for seneca.act and data entity api like save$/load$ and so on?
actions that fail should be tracked to avoid "piling up" requests on bad actions
especially important for micro-services!
seneca should therefore maintain internal health stats on actions, retrying periodically
really bad as can't be overridden for debugging tests
also unnecessary complexity in code base
use log:'silent' instead
Confused here... it looks like last test failed,
but mocha says it past.
2013-07-30T15:02:29.812Z INFO hello Seneca/0.5.9/n9zend
․2013-07-30T15:02:29.835Z INFO hello Seneca/0.5.9/3ddc1n
․2013-07-30T15:02:29.851Z INFO hello Seneca/0.5.9/fw8amg
․2013-07-30T15:02:30.519Z INFO hello Seneca/0.5.9/crkdsk
․2013-07-30T15:02:30.530Z INFO hello Seneca/0.5.9/3sl32a
․2013-07-30T15:02:30.542Z INFO hello Seneca/0.5.9/z8hqyy
․2013-07-30T15:02:30.558Z INFO hello Seneca/0.5.9/llnp3n
․2013-07-30T15:02:30.571Z INFO hello Seneca/0.5.9/mrqblm
2013-07-30T15:02:30.590Z INFO hello Seneca/0.5.9/7rzb26
․2013-07-30T15:02:30.597Z INFO hello Seneca/0.5.9/m3vloj
․2013-07-30T15:02:30.604Z INFO hello Seneca/0.5.9/wjppm9
․2013-07-30T15:02:30.612Z INFO hello Seneca/0.5.9/ofjy7d
․2013-07-30T15:02:30.624Z INFO hello Seneca/0.5.9/z3losu
2013-07-30T15:02:30.632Z INFO hello Seneca/0.5.9/fk77fc
2013-07-30T15:02:30.641Z INFO hello Seneca/0.5.9/7cewdr
2013-07-30T15:02:30.650Z INFO hello Seneca/0.5.9/7lgipc
2013-07-30T15:02:30.658Z INFO hello Seneca/0.5.9/3pbpcd
2013-07-30T15:02:30.665Z INFO hello Seneca/0.5.9/kkfa8g
․2013-07-30T15:02:30.674Z INFO hello Seneca/0.5.9/2yr7br
․2013-07-30T15:02:30.683Z INFO hello Seneca/0.5.9/m21dlb
․2013-07-30T15:02:30.692Z INFO hello Seneca/0.5.9/gh2cp9
2013-07-30T15:02:30.708Z ERROR fail seneca/string-args-syntax-error Seneca: seneca/string-args-syntax-error {code=seneca/string-args-syntax-error,argstr=a:,b:2,args={c=3}}
․
15 tests complete (908 ms)
dynamically register MemStore at runtime and Entity.init it
how to reference MemStore, MongoStore at runtime?
Hi Richard,
I upgraded to node 0.10.28 and did a npm install and it seems that express-session is missing from the dependencies.
"dependencies": {
"gex": "~0.1.3",
"parambulator": "~0.1.6",
"async": "~0.7.0",
"express-session": "^1.0.4",
"patrun": "~0.1.5",
"jsonic": "~0.1.1",
"seneca-web": "~0.1.3",
"seneca-transport": "~0.1.2",
"norma": "~0.2.3",
"underscore": "~1.5.2",
"rolling-stats": "~0.1.0",
"optimist": "~0.6.1",
"nid": "~0.3.2"
},
errors are a natural part of an application flow and seneca prints all errors with log level 'ERROR' even if they are catched and handled by the app. This makes the logs hard to read and fires false positives.
Seneca app using SENECA_LOG will not start.
as per https://gitter.im/pgte/nock
For example, on the API page, links like 'pin pattern format' and 'entity canon' are dead (404).
how to remove the callback using promises? I try,but always run
var seneca = require('seneca')()
seneca.add( {role:'math', cmd:'sum'}, function(args,callback) {
var sum = args.left + args.right
callback(null,{answer:sum})
})
seneca.act( {role:'math', cmd:'sum', left:1, right:2}, function(err,result) {
if( err ) return console.error( err )
console.log(result)
})
When you try to send an error to the callback function in "add" the server logs the error but it isn't sent to "act". The error variable in "act" is null and the response is {}.
.add(
{generate: 'error'},
function (args, done) {
try {
JSON.parse('!#%&');
} catch (error) {
done(error);
}
}
)
Output:
2014-09-10T08:40:14.114Z diyjrnxkxvzc/1410335482374/- ERROR act - - OUT oea0qj5hjv5h generate:error Unexpected token ! action-error {id=oea0qj5hjv5h,gate=false,ungate=true,pattern=generate:error,plugin={name=-,tag=-},time={start=1410338414113,end=1410338414113}} SyntaxError: Unexpected token !
at Object.parse (native)
at Seneca.<anonymous> (/Users/webdbdev3/Desktop/arbetslager/senecatest/geomService.js:55:14)
at Object.$.executor.execute.fn (/Users/webdbdev3/Desktop/arbetslager/senecatest/node_modules/seneca/lib/seneca.js:1334:24)
at Object._onImmediate (/Users/webdbdev3/Desktop/arbetslager/senecatest/node_modules/seneca/lib/executor.js:93:14)
at processImmediate [as _immediateCallback] (timers.js:345:15)
.act(
{generate: 'error'},
function (error, response) {
console.log('error is');
console.log(error);
console.log('response is');
console.log(response);
}
)
Output:
error is
null
response is
{}
I think it's a common scenario that a business transaction need call a series of micro services. And some of them needs to make some changes to the database. If one of the service call failed, we should roll back all the changes that are made by the previous call?
How can we do that in a distributed enviorment like seneca?
I found that seneca.client can work with seneca.act:
var seneca = require('seneca')()
seneca.client(3000)
seneca.act( { role:'foo',cmd:'bar',zoo:'a' },
function( err, result ) {
console.log(result.bar)
})
But seneca.client can't work with seneca.pin :
var seneca = require('seneca')()
seneca.client(3000)
var shop=seneca.pin({role:'foo',cmd:'*'})
shop.bar( { zoo:'a' },
function( err, result ) {
console.log(result.bar)
})
why?
I'm posting a question here as an issue because I couldn't think of/find another platform to seek a solution
I'm trying to run 2 services (2 node apps) and a client (another node app) which communicate via Redis pub/sub
The problem is whenever I post an act() matching one of the services, the other service crashes because it can't find a matching action pattern (which is expected)
what am I missing here?
avoids load$ then save$ nonsense
Plugins used like that don't seem to be actually required. Changing '..'
to require('..')
fixes the problem.
Hi,
I'm wondering how to implement such requirement in seneca framework, could you please provide some insight?
from https://blog.engineyard.com/page/2
The pin is just an action pattern that matches a subset the actions. In this case, a pin of {role:’well’,cmd:’*'} will pull out all the well plugin actions that have a cmd property in their pattern.
(italics mine)
file1
seneca.client({
pin: {
role: 'audit'
}
)
var audit = seneca.pin({role: 'audit', cmd:'log'})
audit.log(...) // Error thrown: audit has no method 'log'
file2
seneca.listen()
seneca.add({role: 'audit', cmd: 'log'} function(args, cb) {
[...]
cb()
})
On the page http://senecajs.org/plugins.html if you click on seneca-mail it sends you to the seneca-email repository, not seneca-mail.
When saving (update) an object with the memory-store microservice, the existing object is fully replaced by the new one. Postgres & Mongo stores only save the attributes set on the saved object, hence doing a 'merge' instead of a 'replace'.
That's unfortunate as some unit tests must be specifically implemented to pass with the in memory store.
The code is on master, too:
seneca.register({
name:'mem-store'
tag:'flash',
map:'/sys/flash':'*'
})
After the name
property is missing a comma.
map
looking strange.
I know, pull request, but I have no idea if JSONIC is used.
Also, in noop-store
is missing a comma after remove
function.
PS: I'm studying Seneca framework and I like the ideas behind.
I admit that my mindset is not there, yet, and I have some doubts on managing large projects, meaningful naming convention and logic flow.
Hi,
After reading the document, it's not clear to me that how a client know the http address and port of a micro service provider?
Does Seneca need a service registry like seaport? or Seneca has builtin support?
note: requires change to seneca-transport
option needed to turn /act off
seneca.add(pattern, command), if command doesn't call done then seneca times out.
How can I call a function when a timeout occurs?
check, for example, that errhandler is a function, etc
/node/app1/node_modules/seneca/lib/seneca.js:1309
if( error.seneca ) throw error;
^
Error: Seneca: Maximum call stack size exceeded
at Seneca.cmd_client (/node/app1/node_modules/seneca-transport/transport.js:122:12)
The app reads a file into an array, iterates it and sends each line as an argument to a remote command. It breaks at ~25.000 items. Is that to be expected?
Passing --stack-size=32000
(or more) causes a seg fault.
v0.10.22
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.