public class Dog | |
{ | |
public string Id { get; set; } | |
public string Name { get; set; } | |
public string Breed { get; set; } | |
} | |
[Test] | |
public void BlindShardingDemo() | |
{ | |
var shards = new Dictionary<string, IDocumentStore> | |
{ | |
{ "One", new DocumentStore() { Url = "http://localhost:8080", DefaultDatabase = "ShardOne"}}, | |
{ "Two", new DocumentStore() { Url = "http://localhost:8081", DefaultDatabase = "ShardTwo"}}, | |
{ "Three", new DocumentStore() { Url = "http://localhost:8082", DefaultDatabase = "ShardThree"}} | |
}; | |
var strategy = new ShardStrategy(shards); | |
var store = new ShardedDocumentStore(strategy); | |
store.Initialize(); | |
using (var session = store.OpenSession()) | |
{ | |
} | |
// https://gist.github.com/robashton/6317678 | |
} |
using (var session = store.OpenSession()) | |
{ | |
session.Store(new Dog() { Name = "Bow wow", Breed = "Terrier"}); | |
session.Store(new Dog() { Name = "Fred", Breed = "Terrier"}); | |
session.Store(new Dog() { Name = "Avara", Breed = "Shepherd"}); | |
session.Store(new Dog() { Name = "Billy", Breed = "Mixed"}); | |
session.Store(new Dog() { Name = "George", Breed = "Mixed"}); | |
session.SaveChanges(); | |
} | |
[Test] | |
public void ReplicationFailover() | |
{ | |
var store = new DocumentStore() | |
{ | |
Url = "http://localhost:8080", | |
DefaultDatabase = "Master", | |
}; | |
store.Conventions.FailoverBehavior = FailoverBehavior.AllowReadsFromSecondariesAndWritesToSecondaries; | |
store.Initialize(); | |
using (var session = store.OpenSession()) | |
{ | |
session.Store(new Dog() { Name = "Bow wow", Breed ="Mixed"}); | |
session.Store(new Dog() { Name = "Bow wow", Breed ="Mixed"}); | |
session.Store(new Dog() { Name = "Bow wow", Breed ="Mixed"}); | |
session.Store(new Dog() { Name = "Bow wow", Breed ="Mixed"}); | |
session.SaveChanges(); | |
} | |
using (var session = store.OpenSession()) | |
{ | |
var dogs = session.Query<Dog>().ToArray(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment