-
Notifications
You must be signed in to change notification settings - Fork 113
Achieve simple async tasks like reading from DB or local file or some local long running process #245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
If your DB has async client API it will be easy because you can call channel.sendResponse after you get result from the DB. If your DB has HTTP or simple socket interface you can use async channel API from nginx-clojure, this is an example to read HTTP content from remote server (https://github.com/nginx-clojure/nginx-clojure/blob/master/test/java/nginx/clojure/net/SimpleHandler4TestNginxClojureAsynChannel.java) and the doc can be found at #37 Otherwise you need to use thread , e.g, use thread pool created by yourself or use thread pool mode from nginx-clojure.
It is quite simple because you can return a File object from you response, e.g. return new Object[] {200, ArrayMap.create("content-type", "text/html"), new File("myfile.txt") } or channel.sendResponse(new Object[] {200, ArrayMap.create("Content-Type", "text/plain"), new File("myfile.txt") }); Then nginx will send the static file by non-blocking way. |
Thanks. And if I had to run some local shell script as part of the incoming request and send back the response after few seconds, will the channel api be the way to go or thread pool? |
@mcaap |
Thank you for patiently answering my noob questions! |
Hi,
Thanks for the nice library. We use it in production!
I have read the literature multiple times, but not sure how to achieve a simple async task.
You have mentioned co-routine & async channel/socket as two options.
I dont want to get into co-routine with wave configuration etc.
How do I achieve the above using async channel/socket?
The text was updated successfully, but these errors were encountered: