Created
February 21, 2016 23:48
-
-
Save reharik/e0cfad49d0d6661f851b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| co(function*() { | |
| while (true) { | |
| var value = yield this.queue.next(); | |
| var isIdempotent = yield this.workflow.checkIdempotency(value.event, this.handlerName); | |
| var eventHandled = isIdempotent === true ? yield this.workflow.wrapHandlerFunction(value.event,value.handlerFunction):''; | |
| var recordEventProcessed = isIdempotent === true ? yield this.workflow.recordEventProcessed(value.event, this.handlerName):''; | |
| } | |
| }.bind(this)).catch(function(err) { | |
| logger.error(this.handlerName + ' threw error ' + err); | |
| }.bind(this)); | |
| Then my wrapHandlerFunction essentially is this | |
| trainerArchived(event) { | |
| co(function*() { | |
| var trainer = yield readstorerepository.getById(event.id, 'trainer'); | |
| trainer.archived = true; | |
| trainer.archivedDate = new Date.now(); | |
| yield readstorerepository.save('trainer', trainer, event.id); | |
| return 'success'; | |
| }.bind(this)).catch(function(err) { | |
| console.log('==========err========='); | |
| console.log(err); | |
| console.log('==========ENDerr========='); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment