-
-
Save ChadMoran/56ca0ad073ed7f2be257 to your computer and use it in GitHub Desktop.
MongoDB Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using MongoDB.Driver; | |
using System.Threading; | |
using MongoDB.Bson; | |
namespace ConsoleApplication19 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var server = MongoServer.Create("mongodb://localhost:27019/?slaveOk=true&replicaSet=foo&connect=replicaset"); | |
var collection = server.GetDatabase("logger").GetCollection("messages"); | |
collection.FindOne(); | |
while (true) | |
{ | |
server.Reconnect(); | |
Console.WriteLine(string.Join(", ", collection.Database.Server.Secondaries.Select(x => x.Address + " : " + x.State.ToString()))); | |
Thread.Sleep(2500); | |
} | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment