<div dir="ltr">I'm not sure if it's exactly what you're looking for, but I've been using zeromq for this for a long timeĀ <a href="http://hackage.haskell.org/package/zeromq4-haskell">http://hackage.haskell.org/package/zeromq4-haskell</a>. It's bindings to a C++ library, but that means that you can communicate with other languages which also have bindings.</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jan 24, 2017 at 2:18 AM Merijn Verstraaten <<a href="mailto:merijn@inconsistent.nl">merijn@inconsistent.nl</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I don't know about split-channel, which seems to try and have a lot of functionality, but broadcast-chan is literally (and I mean the "copy+paste" kind of literally) the exact same implementation as Control.Concurrent.Chan.<br class="gmail_msg">
<br class="gmail_msg">
The only difference is that, with Control.Concurrent.Chan each Chan always has access to both the read and write end of the Chan. This read end will keep data inside that Chan alive (and thus in memory!) indefinitely, if no one reads from that Chan. If you use dupChan this will create a new read end that tracks data in the Chan separately from the original one.<br class="gmail_msg">
<br class="gmail_msg">
This means that if you have a worker that only ever writes into a Chan, this read end is basically keeping everything you write into the Chan alive forever.<br class="gmail_msg">
<br class="gmail_msg">
broadcast-chan does the exact same thing as 'newBroadcastTChan' from Control.Concurrent.STM.TChan, that is your original Chan contains a "write" end only, and not a read end, the end result of that is: If you create a new write channel any message you write into it will, if there are no listeners, be immediately dropped and GCed. If you create "read" ends, then each read end will receive every message written into the write end, as long as the read end is active. So if you create 5 workers with a new read end each, then every message written after those have been created will be seen by all workers.<br class="gmail_msg">
<br class="gmail_msg">
So, if your problem is "I want to broadcast messages, but messages that are sent when there are no listeners should be dropped and forgotten", then use broadcast-chan.<br class="gmail_msg">
<br class="gmail_msg">
The package itself isn't "battle-tested", but since it's basically a copy+paste of Control.Concurrent.Chan with a trivial wrapper, I feel fairly confident that it doesn't have any major problems.<br class="gmail_msg">
<br class="gmail_msg">
Cheers,<br class="gmail_msg">
Merijn<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
> On 23 Jan 2017, at 11:52, Saurabh Nanda <<a href="mailto:saurabhnanda@gmail.com" class="gmail_msg" target="_blank">saurabhnanda@gmail.com</a>> wrote:<br class="gmail_msg">
><br class="gmail_msg">
> (cross-posted from Reddit because I'm not sure of the audience overlap between haskell-cafe & reddit)<br class="gmail_msg">
><br class="gmail_msg">
> I want to broadcast some instrumentation data from deep within my Haskell app. This data will have listeners in some environments (say, debug), but not others (say, production). Which library should I be using? A little searching threw two possible candidates:<br class="gmail_msg">
><br class="gmail_msg">
> * <a href="http://hackage.haskell.org/package/split-channel" rel="noreferrer" class="gmail_msg" target="_blank">http://hackage.haskell.org/package/split-channel</a><br class="gmail_msg">
> * <a href="https://hackage.haskell.org/package/broadcast-chan" rel="noreferrer" class="gmail_msg" target="_blank">https://hackage.haskell.org/package/broadcast-chan</a><br class="gmail_msg">
><br class="gmail_msg">
> But, I'm not sure if these are battle-tested. Any help would be appreciated.<br class="gmail_msg">
><br class="gmail_msg">
> -- Saurabh.<br class="gmail_msg">
><br class="gmail_msg">
> _______________________________________________<br class="gmail_msg">
> Haskell-Cafe mailing list<br class="gmail_msg">
> To (un)subscribe, modify options or view archives go to:<br class="gmail_msg">
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" class="gmail_msg" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br class="gmail_msg">
> Only members subscribed via the mailman list are allowed to post.<br class="gmail_msg">
<br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
Haskell-Cafe mailing list<br class="gmail_msg">
To (un)subscribe, modify options or view archives go to:<br class="gmail_msg">
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" class="gmail_msg" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br class="gmail_msg">
Only members subscribed via the mailman list are allowed to post.</blockquote></div>