FAQ
Hi everyone,

Many of my programs have a component that's some variation of "aggregate
data from various sources". From go-metrics[1] I learned the pattern[2] of
having a goroutine take input data on one or more channels and provide a
channel for the summarized results. I've used it a bunch, but each time I
need it again I hesitate to do it again.

The trade-offs are roughly:

Good:
   - No mutexes. Very self-contained/safe API.

Bad:
   - It's sometimes a bunch of work to "sync" incoming data to the shared
data structure; either it ends up as a bunch of different channels for
different parts of the shared data structure; some overly verbose data
structures to pass enough data through, etc.
   - For example I often just end up with a "read the whole data structure"
channel (to get data out of the arbiter), where I didn't need a copy of
everything. Setting up a pair of channels to say "oh, just give me the
foobars" and get those is disproportionally much work.
   - Managing when the various channels are written and read sometimes ends
up being messier than it conceptually should be.

A semi-typical example of what I end up with is here (the use case is
"spawn a bunch of goroutines to monitor other servers"):

    https://github.com/devel/geodns-monitor/blob/master/statushub.go

The code that does the actual work is
at https://github.com/devel/geodns-monitor/blob/master/server.go

So, my question -- am I using a screwdriver on nails here?


Ask

[1] https://github.com/rcrowley/go-metrics
[2] Sorry about calling it that; it makes it sound like I put things in TeX
files all day and don't do any actual programming.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Atomly at Nov 6, 2013 at 10:20 pm
    off-topic, but is there a reason you're discarding the index and then
    bothering to create your own here?

    https://github.com/devel/geodns-monitor/blob/master/statushub.go#L187

    :: atomly ::

    [ atomly@atomly.com : www.atomly.com : http://blog.atomly.com/ ...
    [ atomiq records : new york city : +1.347.692.8661 ...
    [ e-mail atomly-news-subscribe@atomly.com for atomly info and updates ...

    On Wed, Nov 6, 2013 at 4:26 PM, Ask Bjørn Hansen wrote:

    Hi everyone,

    Many of my programs have a component that's some variation of "aggregate
    data from various sources". From go-metrics[1] I learned the pattern[2] of
    having a goroutine take input data on one or more channels and provide a
    channel for the summarized results. I've used it a bunch, but each time I
    need it again I hesitate to do it again.

    The trade-offs are roughly:

    Good:
    - No mutexes. Very self-contained/safe API.

    Bad:
    - It's sometimes a bunch of work to "sync" incoming data to the shared
    data structure; either it ends up as a bunch of different channels for
    different parts of the shared data structure; some overly verbose data
    structures to pass enough data through, etc.
    - For example I often just end up with a "read the whole data structure"
    channel (to get data out of the arbiter), where I didn't need a copy of
    everything. Setting up a pair of channels to say "oh, just give me the
    foobars" and get those is disproportionally much work.
    - Managing when the various channels are written and read sometimes ends
    up being messier than it conceptually should be.

    A semi-typical example of what I end up with is here (the use case is
    "spawn a bunch of goroutines to monitor other servers"):

    https://github.com/devel/geodns-monitor/blob/master/statushub.go

    The code that does the actual work is at
    https://github.com/devel/geodns-monitor/blob/master/server.go

    So, my question -- am I using a screwdriver on nails here?


    Ask

    [1] https://github.com/rcrowley/go-metrics
    [2] Sorry about calling it that; it makes it sound like I put things in
    TeX files all day and don't do any actual programming.

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Ask Bjørn Hansen at Nov 7, 2013 at 12:55 am

    On Nov 6, 2013, at 2:20 PM, atomly wrote:

    off-topic, but is there a reason you're discarding the index and then bothering to create your own here?

    https://github.com/devel/geodns-monitor/blob/master/statushub.go#L187
    No, I’d blame inertia. That just looks sloppy. :-)


    Ask

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 6, '13 at 9:26p
activeNov 7, '13 at 12:55a
posts3
users2
websitegolang.org

2 users in discussion

Ask Bjørn Hansen: 2 posts Atomly: 1 post

People

Translate

site design / logo © 2021 Grokbase