1

As the title says. What is the difference between sending response through a channel and just return a map.

(defn handler-one
  [request]
  (response "hello world")

(defn handler-two
  [request]
  (with-channel request channel
    (send! channel (response "hello world"))
Faris Nasution
  • 3,450
  • 5
  • 24
  • 29

2 Answers2

2

handler-one function uses synchronous approach. Request -> Response

handle-two is a way to achieve Request -> Response but asynchronously.

You can check with-channel macro definition for more implementation details (and documentation).

If you want more details about asynchronous approach in general, then I recommend learning about one of: Futures, Reactive Programming, Netty, Node.js or Vert.x

Chiron
  • 20,081
  • 17
  • 81
  • 133
1

Following the theory of core.async channels, if you use channels you will have non-blocking communication meaning that your thread will not be blocked until the http response. If you use the blocking communication waiting for the map http-response your thread will be blocked

tangrammer
  • 3,041
  • 17
  • 24