예제 #1
0
        public MatchPipeline(RiotApi riotApi, RiotQuerySettings querySettings, IMatchDetailProcessor matchDetailProcessor)
        {
            api = riotApi;
            this.querySettings = querySettings;
            this.matchDetailProcessor = matchDetailProcessor;

            queryQueues.Add(querySettings.Queue);

            // Create match producer
            if (!querySettings.NoDownload)
            {
                playerMatchProducer = new PlayerMatchProducer(api, querySettings, queryQueues, testSynchronizer);

                // Create blocks
                ConsumeMatchBlock = new TransformBlock<MatchSummary, MatchDetail>(
                    async match => await ConsumeMatch(match),
                    new ExecutionDataflowBlockOptions() { MaxDegreeOfParallelism = 5 });
            }
            ConsumeMatchDetailBlock = new ActionBlock<MatchDetail>(
                async match => await matchDetailProcessor.ConsumeMatchDetail(match),
                new ExecutionDataflowBlockOptions() {
                    MaxDegreeOfParallelism = matchDetailProcessor.MaxDegreeOfParallelism
                });

            // Link blocks
            if (!querySettings.NoDownload)
            {
                playerMatchProducer.MatchProducerBlock.LinkTo(ConsumeMatchBlock, new DataflowLinkOptions() { PropagateCompletion = false });
                ConsumeMatchBlock.LinkTo(ConsumeMatchDetailBlock, new DataflowLinkOptions() { PropagateCompletion = false }, match => match != null);
                ConsumeMatchBlock.LinkTo(DataflowBlock.NullTarget<MatchDetail>(), new DataflowLinkOptions() { PropagateCompletion = false });
            }
        }
예제 #2
0
        public MatchPipeline(RiotApi riotApi, RiotQuerySettings querySettings, IMatchDetailProcessor matchDetailProcessor)
        {
            api = riotApi;
            this.querySettings        = querySettings;
            this.matchDetailProcessor = matchDetailProcessor;

            queryQueues.Add(querySettings.Queue);

            // Create match producer
            if (!querySettings.NoDownload)
            {
                playerMatchProducer = new PlayerMatchProducer(api, querySettings, queryQueues, testSynchronizer);

                // Create blocks
                ConsumeMatchBlock = new TransformBlock <MatchSummary, MatchDetail>(
                    async match => await ConsumeMatch(match),
                    new ExecutionDataflowBlockOptions()
                {
                    MaxDegreeOfParallelism = 5
                });
            }
            ConsumeMatchDetailBlock = new ActionBlock <MatchDetail>(
                async match => await matchDetailProcessor.ConsumeMatchDetail(match),
                new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = matchDetailProcessor.MaxDegreeOfParallelism
            });

            // Link blocks
            if (!querySettings.NoDownload)
            {
                playerMatchProducer.MatchProducerBlock.LinkTo(ConsumeMatchBlock, new DataflowLinkOptions()
                {
                    PropagateCompletion = false
                });
                ConsumeMatchBlock.LinkTo(ConsumeMatchDetailBlock, new DataflowLinkOptions()
                {
                    PropagateCompletion = false
                }, match => match != null);
                ConsumeMatchBlock.LinkTo(DataflowBlock.NullTarget <MatchDetail>(), new DataflowLinkOptions()
                {
                    PropagateCompletion = false
                });
            }
        }