我有一个闭包,其中 afuture
需要一个do
块。do 块中的每个函数都由闭包的参数提供:
(defn accept-order
[persist record track notify log]
(fn [sponsor order]
(let [datetime (to-timestamp (local-now))
order (merge order {:network_reviewed_at datetime
:workflow_state "unconfirmed"
:sponsor_id (:id sponsor)})]
(future
(do
(persist order
(select-keys order [:network_reviewed_at
:workflow_state
:sponsor_id]))
(record sponsor order true)
(track)
(notify sponsor order)
(log sponsor order)))
order)))
块中没有函数do
被触发。如果我取消未来,它会起作用。如果我删除未来它会起作用。如果我从 REPL 运行,它可以工作。但是,如果我运行lein test
,它将无法正常工作。
有任何想法吗?谢谢!