Gorm: How to support master slave and multiple database?

Created on 3 Jun 2016  ·  3Comments  ·  Source: go-gorm/gorm

How to support master slave and multiple database?

@levinalex Can you add file config for database connection open with multi shard and master/slave?
like active_record sharding https://github.com/zendesk/active_record_shards

Most helpful comment

@d4l3k Could you please share an example with gorm and tsenart/nap ?

All 3 comments

you could have a load balancer, and make gorm connect the load balancer

Just for future reference in case anyone else stumbles upon this issue, for master slave topologies you can use https://github.com/tsenart/nap to add client side load balancing. For multi-master topologies like CockroachDB I wrote a library https://github.com/d4l3k/go-lbsql.

There's also https://github.com/benthor/clustersql but it seems to have some issues and not be thread safe.

@d4l3k Could you please share an example with gorm and tsenart/nap ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ganitzsh picture Ganitzsh  ·  3Comments

izouxv picture izouxv  ·  3Comments

koalacxr picture koalacxr  ·  3Comments

satb picture satb  ·  3Comments

leebrooks0 picture leebrooks0  ·  3Comments