Skip to content

Instantly share code, notes, and snippets.

@ChadMoran
Created December 22, 2011 00:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChadMoran/56ca0ad073ed7f2be257 to your computer and use it in GitHub Desktop.
Save ChadMoran/56ca0ad073ed7f2be257 to your computer and use it in GitHub Desktop.
MongoDB Test
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