I am trying to write in a way similar to node.js. I would like to use async libraries like concurrent-ruby. The method DoTaskAsync returns a future and I could chain with a then function. The main thread of the calls the original post method could return quickly without being blocked.
class TasksController < ApplicationController
def post
DoTaskAsync
.then do |res|
respond_to do |format| # possible?
format.json { render json: res }
end
end
end
end
Aucun commentaire:
Enregistrer un commentaire