FAQ
We have some high- availability PostgreSQL DBs which live on different
servers, and are sync'ed by PostgreSQL. I would normally write or read from
a primary server (S1). However, if the connection fails to S1, I'd like to
be able to retry the operation on S2, and if necessary S3, S4...
What would be a good way to handle this in Go? Create connections (at
startup) to all the servers and try them in order IF there's a failure? Or
just open a new connection (lather, rinse, repeat, ...) starting with S2,
then S3... and try it when S1 fails? If there's a nice Go-ish way to handle
this I'd love to know about it.
Thanks,
Ken

--
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

  • Tom Payne at May 2, 2014 at 9:51 pm
    A tried-and-tested solution is to use the pgpool middleware:
       http://www.pgpool.net/
    This requires no modification to your Go code :)

    On 2 May 2014 23:27, Ken GoNoob wrote:

    We have some high- availability PostgreSQL DBs which live on different
    servers, and are sync'ed by PostgreSQL. I would normally write or read from
    a primary server (S1). However, if the connection fails to S1, I'd like to
    be able to retry the operation on S2, and if necessary S3, S4...
    What would be a good way to handle this in Go? Create connections (at
    startup) to all the servers and try them in order IF there's a failure? Or
    just open a new connection (lather, rinse, repeat, ...) starting with S2,
    then S3... and try it when S1 fails? If there's a nice Go-ish way to handle
    this I'd love to know about it.
    Thanks,
    Ken

    --
    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.
  • Marko at May 3, 2014 at 4:29 pm

    On Friday, May 2, 2014 11:27:36 PM UTC+2, Ken GoNoob wrote:
    We have some high- availability PostgreSQL DBs which live on different
    servers, and are sync'ed by PostgreSQL. I would normally write or read from
    a primary server (S1). However, if the connection fails to S1, I'd like to
    be able to retry the operation on S2, and if necessary S3, S4...
    What would be a good way to handle this in Go? Create connections (at
    startup) to all the servers and try them in order IF there's a failure? Or
    just open a new connection (lather, rinse, repeat, ...) starting with S2,
    then S3... and try it when S1 fails?
    Yeah, I'd pass around a struct which contains an *sql.DB instance for every
    server you might want to try and run the query on. I don't think there's
    anything Go-specific to this question.


    .marko

    --
    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
postedMay 2, '14 at 9:27p
activeMay 3, '14 at 4:29p
posts3
users3
websitegolang.org

3 users in discussion

Ken GoNoob: 1 post Marko: 1 post Tom Payne: 1 post

People

Translate

site design / logo © 2021 Grokbase