# Getting data from different services

I have a piece of code that tries to get some data from a different services, falling back to the next one if previous fails.

The code look a little bit ugly, though. Any suggestions on how to rewrite it in a more concise way?

(defn get-data [query]
(let [data-cached (get-data-from-cache query)
data-service-1 (if (nil? data-cached)
(get-data-service-1 query)
data-cached)
data-service-2 (if (nil? data-service-1)
(get-data-service-2 query)
data-service-1)
data (if (nil? data-service-2)
(get-data-service-3 query)
data-service-2)]
data))

• The title of your post should be the function/purpose of your code. – SirPython Feb 21 '15 at 3:08

Perhaps or macro could be used here:
(defn get-data [query]

or short-circuits, so the first match will return and the rest will not be evaluated