Dispatcher(string id, string iotHubName, IEnumerable <IEndpointExecutor> execs, IEndpointExecutorFactory endpointExecutorFactory, ICheckpointer checkpointer) { this.Id = Preconditions.CheckNotNull(id); this.iotHubName = Preconditions.CheckNotNull(iotHubName); this.endpointExecutorFactory = Preconditions.CheckNotNull(endpointExecutorFactory); this.closed = new AtomicBoolean(false); this.cts = new CancellationTokenSource(); this.checkpointer = Preconditions.CheckNotNull(checkpointer); ImmutableDictionary <string, IEndpointExecutor> execsDict = Preconditions.CheckNotNull(execs) .ToImmutableDictionary(key => key.Endpoint.Id, value => value); this.executors = new AtomicReference <ImmutableDictionary <string, IEndpointExecutor> >(execsDict); }
public ClosedEndpointExecutorFactory(IEndpointExecutorFactory factory) { this.underlying = factory; }
public static async Task <Dispatcher> CreateAsync(string id, string iotHubName, ISet <Endpoint> endpoints, IEndpointExecutorFactory factory, ICheckpointStore checkpointStore) { Preconditions.CheckNotNull(id); Preconditions.CheckNotNull(endpoints); Preconditions.CheckNotNull(factory); Preconditions.CheckNotNull(checkpointStore); MasterCheckpointer masterCheckpointer = await MasterCheckpointer.CreateAsync(id, checkpointStore); var executorFactory = new CheckpointerEndpointExecutorFactory(id, factory, masterCheckpointer); IEnumerable <Task <IEndpointExecutor> > tasks = endpoints.Select(endpoint => executorFactory.CreateAsync(endpoint)); IEndpointExecutor[] executors = await Task.WhenAll(tasks); return(new Dispatcher(id, iotHubName, executors, executorFactory, masterCheckpointer)); }
public static async Task <Dispatcher> CreateAsync(string id, string iotHubName, ISet <Endpoint> endpoints, IEndpointExecutorFactory factory) { Preconditions.CheckNotNull(id); Preconditions.CheckNotNull(endpoints); Preconditions.CheckNotNull(factory); IEnumerable <Task <IEndpointExecutor> > tasks = Preconditions.CheckNotNull(endpoints) .Select(endpoint => factory.CreateAsync(endpoint)); IEndpointExecutor[] executors = await Task.WhenAll(tasks); return(new Dispatcher(id, iotHubName, executors, factory, new NullCheckpointer())); }
public CheckpointerEndpointExecutorFactory(string idPrefix, IEndpointExecutorFactory executorFactory, ICheckpointerFactory checkpointerFactory) { this.idPrefix = Preconditions.CheckNotNull(idPrefix); this.executorFactory = Preconditions.CheckNotNull(executorFactory); this.checkpointerFactory = Preconditions.CheckNotNull(checkpointerFactory); }
public CheckpointerEndpointExecutorFactory(IEndpointExecutorFactory underlying, ICheckpointStore store) { this.underlying = underlying; this.store = store; }
public static async Task <Router> CreateAsync(string id, string iotHubName, RouterConfig config, IEndpointExecutorFactory executorFactory, ICheckpointStore checkpointStore) { Preconditions.CheckNotNull(id); Preconditions.CheckNotNull(config); Preconditions.CheckNotNull(executorFactory); Preconditions.CheckNotNull(checkpointStore); var evaluator = new Evaluator(config); Dispatcher dispatcher = await Dispatcher.CreateAsync(id, iotHubName, GetEndpoints(config), executorFactory, checkpointStore); return(new Router(id, iotHubName, evaluator, dispatcher)); }
public RouterFactory(IEndpointExecutorFactory endpointExecutorFactory) { this.endpointExecutorFactory = Preconditions.CheckNotNull(endpointExecutorFactory); }
public static async Task <Dispatcher> CreateAsync(string id, string iotHubName, IDictionary <Endpoint, IList <uint> > endpointsWithPriorities, IEndpointExecutorFactory factory) { Preconditions.CheckNotNull(id); Preconditions.CheckNotNull(endpointsWithPriorities); Preconditions.CheckNotNull(factory); IEnumerable <Task <IEndpointExecutor> > tasks = endpointsWithPriorities.Select(e => factory.CreateAsync(e.Key, e.Value)); IEndpointExecutor[] executors = await Task.WhenAll(tasks); return(new Dispatcher(id, iotHubName, executors, factory, new NullCheckpointer())); }