示例#1
0
        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;
 }
示例#3
0
        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));
        }
示例#4
0
        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()));
        }
示例#5
0
 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;
 }
示例#7
0
        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));
        }
示例#8
0
 public RouterFactory(IEndpointExecutorFactory endpointExecutorFactory)
 {
     this.endpointExecutorFactory = Preconditions.CheckNotNull(endpointExecutorFactory);
 }
示例#9
0
        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()));
        }