Skip to content

Broadcast to subscribe chans in separate goroutines  #2

Description

@jsimnz

When a Post is made for an event, a for-loop is used to broadcast the event to all the channel registered to that event.

But the send down the goroutine is a blocking call, and the channels are non-buffered, so it may block indefinately trying to send to the first channel, even though there are others also registered on that channel.

Basically all code that looks like this:

for _, outputChan := range outChans {
    outputChan <- data
}

Should look like this

for _, outputChan := range outChans {
    go outputChan <- data
}

PS. I know this repo hasnt been updated in 2 years, but this was a concern of mine while using it. I'm happy to submit a pull request if I know it'll get merged in.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions