【发布时间】:2018-03-17 15:49:05
【问题描述】:
我希望能够通过 Servant 作为响应主体流式传输 S3 存储桶对象内容。
我在获取 Handler 的 MonadResource 实例丢失时遇到问题:
src/Servant/Streaming/Example.hs:29:3: error:
* No instance for (MonadResource Handler)
arising from a use of `runAWS'
* In a stmt of a 'do' block: runAWS env conduits
In the expression:
do env <- newEnv Discover
runAWS env conduits
In an equation for `server':
server
= do env <- newEnv Discover
runAWS env conduits
|
29 | runAWS env conduits
| ^^^^^^^^^^^^^^^^^^^
我已经做了一个仓库来重现:https://github.com/domenkozar/servant-streaming-amazonka
servant-streaming-server 处理 ResourceT 为 Stream (Of BS.ByteString) (ResourceT IO) () https://github.com/plow-technologies/servant-streaming/blob/master/servant-streaming-server/src/Servant/Streaming/Server/Internal.hs#L77-L79
但由于我使用的是 Amazonka,因此我还需要确保将 MonadResource for Handler 纳入该括号。我不清楚该怎么做。
我的理解是,使用 enter/hoistServer 这将不起作用,因为资源会被过早清理(在流式传输之前)。
注意事项:
- 这是基于 2016 年提出的问题:Haskell Servant and streaming
- Servant 部分通过https://github.com/plow-technologies/servant-streaming/pull/2/files 实现
编辑
- 编辑:我已经将
$$替换为$$+- - EDIT2:我已经解决了特定于 Conduit 的错误,现在正在与 MonadResource 进行斗争
【问题讨论】: