FAQ
Hello everyone!

I'm writing messages server in go and can't recognize best way to send
response messages to clients.
Server is goroutine, which listens single channel of messages. Messages are
received by multiple connection pool (some of them receive protobuf encoded
messages over tcp socket, some - json encoded messages over web socket;
clients over different connections are equivalent). After processing
message i have to write an asnwer. I know 2 variants:
1) i can store multiple chanels for different connection pool and store a
map, which holds match clientId => chan. in this case i have to listen for
one more channel to receive new output channels and have to store the map
with matches.
2) i can pass chan for response in message. but in some situations i have
to send information not only for sender of message, but also to another
connections. so

Maybe there is a "ussual" way for this problem?

--
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/d/optout.

Search Discussions

  • Matt Harden at Sep 28, 2014 at 11:59 pm
    I think it's more idiomatic (usual) to pass channel(s) for response over
    the main channel.
    On Sun, Sep 28, 2014 at 1:01 PM, Михаил Вицен wrote:

    Hello everyone!

    I'm writing messages server in go and can't recognize best way to send
    response messages to clients.
    Server is goroutine, which listens single channel of messages. Messages
    are received by multiple connection pool (some of them receive protobuf
    encoded messages over tcp socket, some - json encoded messages over web
    socket; clients over different connections are equivalent). After
    processing message i have to write an asnwer. I know 2 variants:
    1) i can store multiple chanels for different connection pool and store a
    map, which holds match clientId => chan. in this case i have to listen for
    one more channel to receive new output channels and have to store the map
    with matches.
    2) i can pass chan for response in message. but in some situations i have
    to send information not only for sender of message, but also to another
    connections. so

    Maybe there is a "ussual" way for this problem?

    --
    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/d/optout.
    --
    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/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 28, '14 at 6:01p
activeSep 28, '14 at 11:59p
posts2
users2
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase