Skip to content

Commit

Permalink
fix plugin event wire warning
Browse files Browse the repository at this point in the history
  • Loading branch information
askmike committed Jul 26, 2018
1 parent 9681881 commit 2ed6c60
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
26 changes: 19 additions & 7 deletions core/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ var pipeline = (settings) => {
_.each(
pluginSubscriptions.filter(s => _.isArray(s.emitter)),
subscription => {
// cache full list
subscription.emitters = subscription.emitter;
var singleEventEmitters = subscription.emitter
.filter(
s => _.size(plugins.filter(p => p.meta.slug === s))
Expand All @@ -110,18 +112,28 @@ var pipeline = (settings) => {
_.each(pluginSubscriptions, function(sub) {

if(plugin[sub.handler]) {

// if a plugin wants to listen
// to something disabled
if(!emitters[sub.emitter]) {
if(!plugin.meta.greedy) {
log.warn([

let emitterMessage;
if(sub.emitters) {
emitterMessage = 'all of the emitting plugins [ ';
emitterMessage += sub.emitters.join(', ');
emitterMessage += ' ] are disabled.';
} else {
emitterMessage += 'the emitting plugin (' + sub.emitter;
emitterMessage += ')is disabled.'
}

log.error([
plugin.meta.name,
'wanted to listen to the',
sub.emitter + ',',
'however the',
sub.emitter,
'is disabled.'
'wanted to listen to event',
sub.event + ',',
'however',
emitterMessage,
plugin.meta.name + ' might malfunction because of it.'
].join(' '));
}
return;
Expand Down
3 changes: 2 additions & 1 deletion plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ var plugins = [
description: 'Logs all gekko events.',
slug: 'eventLogger',
async: false,
modes: ['realtime', 'backtest']
modes: ['realtime', 'backtest'],
greedy: true
},
{
name: 'Backtest result export',
Expand Down

0 comments on commit 2ed6c60

Please sign in to comment.