Exemplo n.º 1
0
		public static App Initialize(AppConfig config, Func<StartOptions, NancyOptions, IDisposable> hostFunc)
		{
			config.ThrowIfInvalid();
			var poller = new LeaderInfoPoller(config.StorageAccount);
			var startOptions = new StartOptions();
			startOptions.Urls.Add(config.InternalUri);
			startOptions.Urls.Add(config.PublicUri);

			var auth = LoadAuth.LoadFromStorageAccount(config.StorageAccount);
			AddSystemAccess(auth, config.StorageAccount.GetSysPassword());
			var api = ApiImplementation.Create(config.StorageAccount, poller, auth);
			var nancyOptions = new NancyOptions
			{
				Bootstrapper = new NancyBootstrapper(api, new UserValidator(auth))
			};
			var nodeInfo = new LeaderInfo(config.InternalUri);

			var selector = new LeaderLock(config.StorageAccount, nodeInfo, api);

			var cts = new CancellationTokenSource();
			// fire up leader and scheduler first
			var tasks = new List<Task> {
				selector.KeepTryingToAcquireLock(cts.Token),
				poller.KeepPollingForLeaderInfo(cts.Token),
			};
			// bind the API
			var host = hostFunc(startOptions, nancyOptions);

			return new App(host, cts, tasks);
		}
Exemplo n.º 2
0
		ApiImplementation(ICloudFactory client, LeaderInfoPoller poller) {
			_client = client;
			_poller = poller;
		}
Exemplo n.º 3
0
		public static ApiImplementation Create(ICloudFactory account, LeaderInfoPoller poller, AuthData auth) {
			return new ApiImplementation(account, poller);
		}
Exemplo n.º 4
0
 ApiImplementation(ICloudFactory client, LeaderInfoPoller poller)
 {
     _client = client;
     _poller = poller;
 }
Exemplo n.º 5
0
 public static ApiImplementation Create(ICloudFactory account, LeaderInfoPoller poller, AuthData auth)
 {
     return(new ApiImplementation(account, poller));
 }