Closed dilame closed 7 years ago
I am not sure what you mean exactly. Here’s a simple example acking after an async task:
app.use(function * () {
yield Promise.resolve()
this.ack = true
})
@tjmehta you understand me right. Thank you. But what if in the end i want to nack, depends on result of promise?
app.use(function * () {
const result = yield Promise.resolve(‘foo’)
if (result === ‘foo’) {
this.ack = true
} else {
this.nack = true
}
})
-or-
app.use(function * () {
try {
yield Promise.resolve(‘foo’)
this.ack = true
} catch (err) {
this.nack = false
}
})
I am going to close this issue, but please feel free to continue asking questions here and I will answer any you have :)
Thank you! Can i use https://github.com/nswbmw/koa-mongo for mongodb connection? If no, what is the best practice for this?
coworkers is not 100% compatible with koa plugins. But you could copy patterns you see in koa plugins. I typically just open up a single db connection on application start.
I have long async task, that i want to ack/nack only after it finish. How can i implement this with coworkers? As i see, i can ony do it with context properties, but in case with RabbitMQ and JS this is unusable almost always. Or did I understand something wrong?