Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save analytik/88115adad24ba7b0ab4e7a2f9d7dd3dc to your computer and use it in GitHub Desktop.

Select an option

Save analytik/88115adad24ba7b0ab4e7a2f9d7dd3dc to your computer and use it in GitHub Desktop.
r.db("rethinkdb").table("table_config")
.hasFields('db', 'name')
.concatMap(doc => [{
db: doc('db'),
table: doc('name'),
shards: doc('shards').count(),
replicas: doc('shards').nth(0)('replicas').count(),
}])
// this part is dumb - assuming you have 4 main servers,
// and that ONLY tables with 5 total replicas have 5 replicas
.filter(doc => doc('replicas').lt(5))
.forEach(doc => r.db(doc('db')).reconfigure({
shards: doc('shards'),
replicas: {'main': doc('replicas'), 'ro': 1},
primary_replica_tag: 'main'
}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment