public IDisposable AddPublishRouteRule <TPayload>(string[] topics, IRouteRule <TPayload> rule) { var token = _publishRouter.AddPublishRouteRule(topics, rule); _tokens.Add(token); return(token); }
public IDisposable AddScatterRouteRule <TRequest, TResponse>(string topic, IRouteRule <TRequest> rule) { Assert.ArgumentNotNull(rule, nameof(rule)); var key = GetKey <TRequest, TResponse>(topic ?? string.Empty); bool ok = _scatterRoutes.TryAdd(key, rule); return(ok ? new ScatterRouteToken <TRequest, TResponse>(this, key) : (IDisposable) new DoNothingDisposable()); }
public IDisposable AddPublishRouteRule <TPayload>(string[] topics, IRouteRule <TPayload> rule) { Assert.ArgumentNotNull(rule, nameof(rule)); var keys = Topics.Canonicalize(topics) .Select(t => GetKey <TPayload>(t ?? string.Empty)) .ToArray(); foreach (var key in keys) { if (!_publishRoutes.TryAdd(key, rule)) { throw new Exception($"Could not add route for Payload={typeof(TPayload).Name} Topic={key}. It may have already been added"); } } return(new PublishRouteToken <TPayload>(this, keys)); }
public IDisposable AddScatterRouteRule <TRequest, TResponse>(string topic, IRouteRule <TRequest> rule) { var token = _scatterRouter.AddScatterRouteRule <TRequest, TResponse>(topic, rule); _tokens.Add(token); return(token); }