public Task Register(ProducerRegistrationDto producer) { if (!_stateOfTheWorld.ContainsKey(producer.Endpoint)) { var producerDescriptor = new ProducerDescriptor() { Endpoint = producer.Endpoint, LastActivated = DateTime.MinValue, State = ProducerState.Alive, Topic = producer.Topic, HeartbeatEndpoint = producer.HeartbeatEndpoint }; _stateOfTheWorld.AddOrUpdate(producer.Endpoint, producerDescriptor, (key, oldValue) => { return(oldValue); }); } return(Task.CompletedTask); }
private bool TryGetNextConsumer() { try { if (_cancel.IsCancellationRequested) { return(false); } _currentProducer = _directory.Next(typeof(TEvent).ToString()).Result; } catch (Exception ex) { //no producer found if (ex.InnerException.GetType() == typeof(ApiException)) { return(false); } ExceptionDispatchInfo.Capture(ex.InnerException).Throw(); } return(true); }
public async Task <IActionResult> Register([FromBody] ProducerRegistrationDto producer) { await _directory.Register(producer); return(StatusCode(201)); }