Skip to content

Commit

Permalink
destroy worker before ending
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewhanson committed Apr 18, 2016
1 parent 1411939 commit ba287d9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
12 changes: 8 additions & 4 deletions examples/kinesis-consumer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ exports.handler = function (event, context) {
console.log('PAYLOAD:', payload);
return worker.addToDB(JSON.parse(payload));
}).then(function (result) {
console.log('SUCCESS:', result);
return context.succeed('Success');
return worker.destroy(function () {
console.log('SUCCESS:', result);
return context.succeed('Success');
});
}).catch(function (err) {
console.log('FAILURE:', err);
return context.fail(err);
return worker.destroy(function () {
console.log('FAILURE:', err);
return context.fail(err);
});
});
};
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ var Worker = function (loggingFn) {
this.logger = loggingFn;
};

//Worker.prototype.destroy = function () {
// return this.bookshelf.knex.destroy();
//};
Worker.prototype.destroy = function () {
return this.bookshelf.knex.destroy();
};

Worker.prototype.addToDB = function (changeset) {
this.changeset = changeset;
Expand Down

0 comments on commit ba287d9

Please sign in to comment.