lib/activity/task.js
function ActivityTask(task) {
  if (!(this instanceof ActivityTask)) {
    return new ActivityTask(task);
  }

  this.input = {};

  if (task.config.input) {
    this.input = JSON.parse(task.config.input);
  }

  // Depending on the language of the Decider impl, this can be an Array or Object
  // This is a big assumption, maybe make this configurable
  if (Array.isArray(this.input)) {
    this.input = this.input[0];
  }

  this.activityId = task.config.activityId;
  this.activityType = task.config.activityType;
  this.startedEventId = task.config.startedEventId;
  this.taskToken = task.config.taskToken;
  this.workflowExecution = task.config.workflowExecution;

  this._task = task;

  // Register a hearbeat callback every 10 seconds
  this.hearbeatCount = 0;
  this.heartbeatTimer = setInterval(function () {
    var self = this;
    self._task.recordHeartbeat(
      { activity: self.activityType.name, id: self.activityId, count: self.hearbeatCount++ },
      function (err) {
        if (err) {
          winston.log('debug', 'Heartbead failed for task: %s (%s) due to:', self.activityType.name, self.activityId, err);
        }
      });
  }.bind(this), 10000);
}
function ActivityTask(task) {
  if (!(this instanceof ActivityTask)) {
    return new ActivityTask(task);
  }

  this.input = {};

  if (task.config.input) {
    this.input = JSON.parse(task.config.input);
  }

  // Depending on the language of the Decider impl, this can be an Array or Object
  // This is a big assumption, maybe make this configurable
  if (Array.isArray(this.input)) {
    this.input = this.input[0];
  }

  this.activityId = task.config.activityId;
  this.activityType = task.config.activityType;
  this.startedEventId = task.config.startedEventId;
  this.taskToken = task.config.taskToken;
  this.workflowExecution = task.config.workflowExecution;

  this._task = task;

  // Register a hearbeat callback every 10 seconds
  this.hearbeatCount = 0;
  this.heartbeatTimer = setInterval(function () {
    var self = this;
    self._task.recordHeartbeat(
      { activity: self.activityType.name, id: self.activityId, count: self.hearbeatCount++ },
      function (err) {
        if (err) {
          winston.log('debug', 'Heartbead failed for task: %s (%s) due to:', self.activityType.name, self.activityId, err);
        }
      });
  }.bind(this), 10000);
}
function ActivityTask ( task ) { if ( ! ( this instanceof ActivityTask ) ) { return new ActivityTask ( task ) ; } this . input = { } ; if ( task . config . input ) { this . input = JSON . parse ( task . config . input ) ; } // Depending on the language of the Decider impl, this can be an Array or Object // This is a big assumption, maybe make this configurable if ( Array . isArray ( this . input ) ) { this . input = this . input [ 0 ] ; } this . activityId = task . config . activityId ; this . activityType = task . config . activityType ; this . startedEventId = task . config . startedEventId ; this . taskToken = task . config . taskToken ; this . workflowExecution = task . config . workflowExecution ; this . _task = task ; // Register a hearbeat callback every 10 seconds this . hearbeatCount = 0 ; this . heartbeatTimer = setInterval ( function ( ) { var self = this ; self . _task . recordHeartbeat ( { activity : self . activityType . name , id : self . activityId , count : self . hearbeatCount ++ } , function ( err ) { if ( err ) { winston . log ( 'debug' , 'Heartbead failed for task: %s (%s) due to:' , self . activityType . name , self . activityId , err ) ; } } ) ; } . bind ( this ) , 10000 ) ; }
The context for the execution of the activity
@constructor
@param {string} task - The raw `aws-swf` activity task
The context for the execution of the activity