Skip to content

Commit

Permalink
outward_res_entity; announce does log
Browse files Browse the repository at this point in the history
  • Loading branch information
rjrodger committed Feb 13, 2018
1 parent 1c42f97 commit 5577397
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 48 deletions.
41 changes: 25 additions & 16 deletions lib/outward.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ module.exports = {
make_error: outward_make_error,
announce: outward_announce,
trace: outward_trace,
act_error: outward_act_error
act_error: outward_act_error,
res_entity: outward_res_entity
}

function outward_make_error(ctxt, data) {
Expand Down Expand Up @@ -112,20 +113,7 @@ function outward_res_object(ctxt, data) {
args: Util.inspect(Common.clean(msg)).replace(/\n/g, ''),
result: res
})
data.meta.error = true

/*
return {
kind: 'error',
code: 'result_not_objarr',
info: {
pattern: ctxt.actdef.pattern,
args: Util.inspect(Common.clean(msg)).replace(/\n/g, ''),
result: res
}
}
*/

data.meta.error = true
}
}

Expand All @@ -138,6 +126,15 @@ function outward_announce(ctxt, data) {
}

ctxt.seneca.emit('act-out', data.msg, data.res, data.meta)

ctxt.seneca.log.debug(
ctxt.actlog(ctxt.actdef, data.msg, data.meta, ctxt.origmsg, {
kind: 'act',
case: 'OUT',
duration: ctxt.duration,
result: data.res
})
)
}


Expand Down Expand Up @@ -191,6 +188,7 @@ function outward_act_error(ctxt, data) {
)

if (meta.fatal) {
// TODO: this should not happen here inside outward processing
return delegate.die(data.error_desc.err)
}

Expand All @@ -200,7 +198,9 @@ function outward_act_error(ctxt, data) {
delegate.on_act_err(actdef, data.res, meta)
}

} else {
}
/*
else {
delegate.log.debug(
ctxt.actlog(actdef, actmsg, meta, origmsg, {
kind: 'act',
Expand All @@ -210,4 +210,13 @@ function outward_act_error(ctxt, data) {
})
)
}
*/
}


function outward_res_entity(ctxt, data) {
var delegate = ctxt.seneca
if (data.res && data.res.entity$ && delegate.make$) {
data.res = delegate.make$(data.res)
}
}
58 changes: 29 additions & 29 deletions seneca.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ function make_seneca(initial_options) {
.add(Outward.act_stats)
.add(Outward.act_cache)
.add(Outward.res_object)
.add(Outward.res_entity)
.add(Outward.trace)
.add(Outward.announce)
.add(Outward.act_error)
Expand Down Expand Up @@ -1309,37 +1310,36 @@ intern.handle_reply = function(meta, actctxt, actmsg, err, out, reply_meta) {

intern.process_outward(actctxt, data)

try {
if (data.has_callback) {
var rout = data.res || null
var rerr = null

if (meta.error) {
rerr = data.error_desc.err
rout = null
meta = data.error_desc.err.meta$ || meta
delete rerr.meta$
} else if (rout && rout.entity$ && delegate.make$) {
rout = delegate.make$(rout)
}

if (data.has_callback) {
var rout = data.res || null
var rerr = null

// TODO: can outward_act_error handle this?
if (meta.error) {
rerr = data.error_desc.err
rout = null
meta = data.error_desc.err.meta$ || meta
delete rerr.meta$
}

try {
reply.call(delegate, rerr, rout, meta)
} catch (e) {
var ex = Util.isError(e) ? e : new Error(Util.inspect(e))

intern.callback_error(
delegate,
ex,
actdef,
meta,
[err, out],
reply,
actctxt.duration,
actmsg,
origmsg,
actctxt.callpoint
)
}
} catch (e) {
var ex = Util.isError(e) ? e : new Error(Util.inspect(e))

intern.callback_error(
delegate,
ex,
actdef,
meta,
[err, out],
reply,
actctxt.duration,
actmsg,
origmsg,
actctxt.callpoint
)
}
}

Expand Down
5 changes: 2 additions & 3 deletions test/transport.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
/* Copyright (c) 2014-2016 Richard Rodger, MIT License */
'use strict'

var tmx = parseInt(process.env.TIMEOUT_MULTIPLIER || 1, 10)
console.log('TEST transport tmx=' + tmx)

var _ = require('lodash')
var Code = require('code')
var Lab = require('lab')
Expand All @@ -19,6 +16,8 @@ var describe = lab.describe
var it = lab.it
var expect = Code.expect

var tmx = parseInt(process.env.TIMEOUT_MULTIPLIER || 1, 10)

var make_test_transport = TransportStubs.make_test_transport
var make_balance_transport = TransportStubs.make_balance_transport

Expand Down

0 comments on commit 5577397

Please sign in to comment.