使用core.async频道在clojure中使用http-kit的帖子结果是否合理?

 mobiledu2502859427 发布于 2023-02-11 13:03

我是clojure的新手,我正在编写一个库,将发布结果发送到服务器以获得响应.我通过将响应放在core.async通道上来消耗响应.这是理智还是有更好的方法?

以下是我正在做的事情的高级概述:

(defn my-post-request [channel options]
  (client/post http://www.example.com options
          (fn [{:keys [status headers body error]}] ;; asynchronous handle response
              (go (>! channel body)))))

(defn request-caller [options]
  (let [channel (chan)]
    (my-post-request channel options)
    (json/parse-string (

以下是我使用的实际代码:https://github.com/gilmaso/btc-trading/blob/master/src/btc_trading/btc_china.clj#L63

它有效,但我很难确认这是否是正确的方法.

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有