ztellman/lamina — Issue #23: async example from wiki seems incorrect
Author: jakemcc
Created: 2011-12-26 17:43:22+00:00
State: open

I've slightly modified the async example from the wiki to request the url http://yahoo.com. This results in a response code of 301, which should trigger a recur and a lookup of http://www.yahoo.com.

Below is the code I'm executing. It seems as though response is not being treated as a real value. When I execute the below code the result is a result-channel that eventually contains the 301 response from the http get on http://yahoo.com. I expected this to recur and request http://www.yahoo.com based an understanding that async allowed you to treat result channels as real values (so in this example, as a response from get on http://yahoo.com that results in a 301 response)

(async
(loop [response (http-request {:method :get, :url "http://yahoo.com"})]
(if (= 301 (:status response))
(recur (http-request {:method :get, :url (get-in response [:headers "location"])}))
response)))

Is this example behaving as you would expect? If so, could you attempt to explain how I'm misunderstanding the use of async in this example?

I'm using lamina-0.4.1-201111217.084700-9.jar with aleph-0.2.1-20111222.000016-7.jar. (aleph-0.2.1-SNAPSHOT and whatever version of lamina it pulls down)