[Question] Chaining channels together

blov · · 488 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I am looking for articles about chaining channels. I have done my own version based on the worker pattern, but I haven&#39;t found any information about chaining these workers into a processing chain that I can compare my impl to. </p> <p>My pattern:</p> <p>Producer gathers data and feeds to a producer channel. </p> <p>Consumer reads producer channel and performs logic. This can be run in multiple go routines for faster processing. Original data is fed to a new Producer channel so that another consumer can process the original data. </p> <p>This pattern can be applied over and over:</p> <p>Producer -&gt; Consumer / Producer -&gt; Consumer / Producer ...</p> <hr/>**评论:**<br/><br/>joshuaboelter: <pre><p>I built something like what you&#39;re describing a few years ago and use it for a variety of pipelines. It has some areas around logging and buffering that could be improved, but it works great.</p> <p><a href="https://godoc.org/github.com/jboelter/pipeline" rel="nofollow">https://godoc.org/github.com/jboelter/pipeline</a> <a href="https://github.com/jboelter/pipeline" rel="nofollow">https://github.com/jboelter/pipeline</a></p></pre>integrii: <pre><p>Are you looking for articles because you have a more specific problem that you didn&#39;t mention here?</p> <p>It seems like you have this figured out already You make a bunch of channels and as work is completed, its dropped into the next stage&#39;s channel. </p></pre>Seventh_Heaven: <pre><p>I don&#39;t have a problem. It&#39;s works, though I am wondering if there is better/go-to pattern. Or maybe something that is written better. I feel like my version has room for improvement...</p></pre>Frakturfreund: <pre><p>You have probably already read the entry on the go blog, but just in case: <a href="https://blog.golang.org/pipelines" rel="nofollow">Go Concurrency Patterns: Pipelines and cancellation</a></p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

488 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传