public override Task Init() { ConsulClient = _getConsulClient(Deployment); lock (_initLock) if (_resultChangedLink == null) { _resultChangedLink = ConsulClient.ResultChanged.LinkTo(new ActionBlock <EndPointsResult>(r => ConsulResultChanged(r))); } ConsulClient.Init(); return(_initialized.Task); }
public override Task Init() { ConsulClient = _getConsulClient(Deployment); lock (_initLock) if (_resultChangedLink == null) { _resultChangedLink = ConsulClient.ResultChanged.LinkTo(new ActionBlock <EndPointsResult>(r => ConsulResultChanged(r))); } ConsulClient.Init(); _initializationTimeout = TimeoutIfNotReceivedFirstResult(); return(Task.WhenAny(_firstResultInitialized.Task, _initializationTimeout)); }
private void SetupConsulClient() { SetConsulEndpoints(_endpointsBeforeChange); _resultChanged = new BroadcastBlock <EndPointsResult>(null); _consulClientMock = Substitute.For <IConsulClient>(); _consulClientMock.Result.Returns(_ => _getConsulEndPoints()); _consulClientMock.ResultChanged.Returns(_resultChanged); _consulClientMock.Init().Returns(_ => _consulClientInitTask()); Kernel.Rebind <Func <string, IConsulClient> >().ToMethod(c => s => { _requestedConsulServiceName = s; return(_consulClientMock); }); _consulClientInitTask = () => Task.Run(() => _resultChanged.SendAsync(_getConsulEndPoints())); }
private Task <EndPointsResult> Start(ConsulMethod consulMethod) { _consulConfig.LongPolling = (consulMethod == ConsulMethod.LongPolling); _consulClient = _testingKernel.Get <Func <string, IConsulClient> >()(_serviceName); return(GetResultAfter(() => _consulClient.Init())); }