public void Add(string endpointName, ReceiveEndpoint endpoint) { if (endpoint == null) { throw new ArgumentNullException(nameof(endpoint)); } if (string.IsNullOrWhiteSpace(endpointName)) { throw new ArgumentException($"The {nameof(endpointName)} must not be null or empty", nameof(endpointName)); } endpoint.HealthResult = _started ? EndpointHealthResult.Healthy(endpoint, "starting") : EndpointHealthResult.Unhealthy(endpoint, "not ready", null); var added = _endpoints.TryAdd(endpointName, key => { endpoint.ConnectReceiveEndpointObserver(new ReceiveEndpointStateMachineObserver(_machine, endpoint)); return(endpoint); }); if (!added) { throw new ConfigurationException($"A receive endpoint with the same key was already added: {endpointName}"); } }
public static EventActivityBinder <ReceiveEndpoint, ReceiveEndpointFaulted> SetUnHealthy(this EventActivityBinder <ReceiveEndpoint, ReceiveEndpointFaulted> binder) { return(binder.Then(context => context.Instance.HealthResult = EndpointHealthResult.Unhealthy(context.Instance, context.Instance.Message, context.Data.Exception))); }
public static EventActivityBinder <ReceiveEndpoint, T> SetDegraded <T>(this EventActivityBinder <ReceiveEndpoint, T> binder) where T : class { return(binder.Then(context => context.Instance.HealthResult = EndpointHealthResult.Degraded(context.Instance, context.Instance.Message))); }