Skip to content

Commit cdd29cb

Browse files
committed
CSHARP-315: add support for reading tags from isMaster result.
1 parent 58df048 commit cdd29cb

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

Driver/Core/CommandResults/IsMasterResult.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,27 @@ public string ReplicaSetName
187187
}
188188
}
189189

190+
/// <summary>
191+
/// Gets the tags.
192+
/// </summary>
193+
public ReplicaSetTagSet Tags
194+
{
195+
get
196+
{
197+
var tagSet = new ReplicaSetTagSet();
198+
if (Response.Contains("tags"))
199+
{
200+
var tags = Response["tags"].AsBsonDocument;
201+
foreach (var tag in tags)
202+
{
203+
tagSet.Add(tag.Name, tag.Value.ToString());
204+
}
205+
}
206+
207+
return tagSet;
208+
}
209+
}
210+
190211
// private methods
191212
private IEnumerable<MongoServerAddress> GetInstanceAddressesFromNamedResponseElement(string elementName)
192213
{

Driver/Core/MongoServerInstance.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,8 @@ private void LookupServerInformation(MongoConnection connection)
521521
MongoServerInstanceType instanceType = MongoServerInstanceType.StandAlone;
522522
if (isMasterResult.ReplicaSetName != null)
523523
{
524-
var tagSet = new ReplicaSetTagSet();
525524
var peers = isMasterResult.Hosts.Concat(isMasterResult.Passives).Concat(isMasterResult.Arbiters).ToList();
526-
replicaSetInformation = new ReplicaSetInformation(isMasterResult.ReplicaSetName, isMasterResult.Primary, peers, tagSet);
525+
replicaSetInformation = new ReplicaSetInformation(isMasterResult.ReplicaSetName, isMasterResult.Primary, peers, isMasterResult.Tags);
527526
instanceType = MongoServerInstanceType.ReplicaSetMember;
528527
}
529528
else if (isMasterResult.Message != null && isMasterResult.Message == "isdbgrid")

0 commit comments

Comments
 (0)