Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
33 lines (28 sloc) 858 Bytes
using System.Collections.Generic;
namespace FluentCassandra.Connections
{
public static class ServerManagerFactory
{
private static readonly object Lock = new object();
private static volatile IDictionary<string, IServerManager> Managers = new Dictionary<string, IServerManager>();
public static IServerManager Get(IConnectionBuilder connectionBuilder)
{
lock (Lock) {
IServerManager manager;
if (!Managers.TryGetValue(connectionBuilder.Uuid, out manager)) {
manager = CreateManager(connectionBuilder);
Managers.Add(connectionBuilder.Uuid, manager);
}
return manager;
}
}
private static IServerManager CreateManager(IConnectionBuilder builder)
{
if (builder.Servers.Count == 1) {
return new SingleServerManager(builder);
} else {
return new RoundRobinServerManager(builder);
}
}
}
}
Something went wrong with that request. Please try again.