lib/decider/version.js
function handleSuccess() {

    // If any activities failed, we need to fail the workflow
    if (context.failed()) {
      winston.log('warn', 'One of more activities failed in workflow: %s, marking workflow as failed', self.name);

      // Respond back to SWF failing the workflow
      decisionTask.response.fail('Activities failed', { failures: context.errorMessages }, function (err) {
        if (err) {
          winston.log('error', 'Unable to mark workflow: %s as failed due to: %s', self.name, JSON.stringify(err));
          return;
        }
      });

    } else {

      // Check to see if we are done with the workflow
      if (context.done()) {
        winston.log('info', 'Workflow: %s has completed successfuly', self.name);

        // Stop the workflow
        decisionTask.response.stop({
          result: JSON.stringify(context.results)
        });
      }

      // If no decisions made this round, skip
      if (!decisionTask.response.decisions) {
        winston.log('debug', 'No decision can be made this round for workflow: %s', self.name);
        // Record our state when we can't make a decision to help in debugging
        // decisionTask.response.add_marker('current-state', JSON.stringify(context.currentStatus()));
        decisionTask.response.wait();
      }

      // Respond back to SWF with all decisions
      decisionTask.response.respondCompleted(decisionTask.response.decisions, function (err) {
        if (err) {
          winston.log('error', 'Unable to respond to workflow: %s with decisions due to: %s', self.name, JSON.stringify(err));
          return;
        }
      });
    }
  }
function handleSuccess() {

    // If any activities failed, we need to fail the workflow
    if (context.failed()) {
      winston.log('warn', 'One of more activities failed in workflow: %s, marking workflow as failed', self.name);

      // Respond back to SWF failing the workflow
      decisionTask.response.fail('Activities failed', { failures: context.errorMessages }, function (err) {
        if (err) {
          winston.log('error', 'Unable to mark workflow: %s as failed due to: %s', self.name, JSON.stringify(err));
          return;
        }
      });

    } else {

      // Check to see if we are done with the workflow
      if (context.done()) {
        winston.log('info', 'Workflow: %s has completed successfuly', self.name);

        // Stop the workflow
        decisionTask.response.stop({
          result: JSON.stringify(context.results)
        });
      }

      // If no decisions made this round, skip
      if (!decisionTask.response.decisions) {
        winston.log('debug', 'No decision can be made this round for workflow: %s', self.name);
        // Record our state when we can't make a decision to help in debugging
        // decisionTask.response.add_marker('current-state', JSON.stringify(context.currentStatus()));
        decisionTask.response.wait();
      }

      // Respond back to SWF with all decisions
      decisionTask.response.respondCompleted(decisionTask.response.decisions, function (err) {
        if (err) {
          winston.log('error', 'Unable to respond to workflow: %s with decisions due to: %s', self.name, JSON.stringify(err));
          return;
        }
      });
    }
  }
function handleSuccess ( ) { // If any activities failed, we need to fail the workflow if ( context . failed ( ) ) { winston . log ( 'warn' , 'One of more activities failed in workflow: %s, marking workflow as failed' , self . name ) ; // Respond back to SWF failing the workflow decisionTask . response . fail ( 'Activities failed' , { failures : context . errorMessages } , function ( err ) { if ( err ) { winston . log ( 'error' , 'Unable to mark workflow: %s as failed due to: %s' , self . name , JSON . stringify ( err ) ) ; return ; } } ) ; } else { // Check to see if we are done with the workflow if ( context . done ( ) ) { winston . log ( 'info' , 'Workflow: %s has completed successfuly' , self . name ) ; // Stop the workflow decisionTask . response . stop ( { result : JSON . stringify ( context . results ) } ) ; } // If no decisions made this round, skip if ( ! decisionTask . response . decisions ) { winston . log ( 'debug' , 'No decision can be made this round for workflow: %s' , self . name ) ; // Record our state when we can't make a decision to help in debugging // decisionTask.response.add_marker('current-state', JSON.stringify(context.currentStatus())); decisionTask . response . wait ( ) ; } // Respond back to SWF with all decisions decisionTask . response . respondCompleted ( decisionTask . response . decisions , function ( err ) { if ( err ) { winston . log ( 'error' , 'Unable to respond to workflow: %s with decisions due to: %s' , self . name , JSON . stringify ( err ) ) ; return ; } } ) ; } }
When we have made a decision
When we have made a decision