コード例 #1
0
ファイル: App.cs プロジェクト: perokvist/messageVault
		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);
		}
コード例 #2
0
		ApiImplementation(ICloudFactory client, LeaderInfoPoller poller) {
			_client = client;
			_poller = poller;
		}
コード例 #3
0
		public static ApiImplementation Create(ICloudFactory account, LeaderInfoPoller poller, AuthData auth) {
			return new ApiImplementation(account, poller);
		}
コード例 #4
0
 ApiImplementation(ICloudFactory client, LeaderInfoPoller poller)
 {
     _client = client;
     _poller = poller;
 }
コード例 #5
0
 public static ApiImplementation Create(ICloudFactory account, LeaderInfoPoller poller, AuthData auth)
 {
     return(new ApiImplementation(account, poller));
 }