rwynn / gtm

gtm (go tail mongo) is a MongoDB event listener
MIT License
147 stars 33 forks source link

Fixed shard retrieval #25

Closed antonsergeyev closed 3 years ago

antonsergeyev commented 3 years ago

This fixes 2 problems I've encountered when working with sharded mongodb cluster:

  1. GetShards function always returned empty results, because a filter query was incorrect (it used nil as a filter instead of bson.D{})
  2. If there are multiple comma-separated hostnames for different mongodb replicas in each shard, the GetUrl function returned invalid URLs. Now it returns a first URL from the comma-separated list, which is imperfect, but at least it works.
rwynn commented 3 years ago

@antonsergeyev thanks for your contribution!