コード例 #1
0
 private Task ProduceAccountActionsAsync(TrackActionQuery query, ITargetBlock <Action[]> actionQueue)
 {
     return(ProduceParticipantActionsAsync(
                () => _searchServices.FindAccountsAsync(query.AccountQuery),
                accounts => _searchServices.FindActionsByAccountsAsync(query.ActionQuery, accounts),
                actionQueue,
                _batchOptions.Value.AccountActionsDatabaseSearchMaxDegreeOfParallelism
                ).Unwrap());
 }
コード例 #2
0
        public async Task should_return_actions_by_account_query()
        {
            var query = new TrackActionQuery
            {
                AccountQuery = new AccountQuery()
            };

            ISearchServices searchServices = Substitute.For <ISearchServices>();

            searchServices.FindAccountsAsync(Arg.Any <AccountQuery>()).Returns(Task.FromResult(new[]
            {
                Task.FromResult(Enumerable.Range(0, 17).ToArray())
            }.AsEnumerable()));

            searchServices.FindActionsByAccountsAsync(Arg.Any <ActionQuery>(), Arg.Is <int[]>(accounts => accounts.Length == 15)).Returns(Task.FromResult(new[]
            {
                new Action(10, new DateTime(2001, 10, 2)),
                new Action(9, new DateTime(2001, 9, 2))
            }));

            searchServices.FindActionsByAccountsAsync(Arg.Any <ActionQuery>(), Arg.Is <int[]>(contacts => contacts.Length == 2)).Returns(Task.FromResult(new[]
            {
                new Action(1, new DateTime(2001, 1, 2))
            }));

            TrackActionSearchService sut = new TrackActionSearchService(searchServices, Options.Create(new BatchProcessingConfig {
                BatchSize = 15
            }));

            var actions = await sut.FindActionsAsync(query);

            actions.ShouldBeEqualTo(new[]
            {
                new Action(10, new DateTime(2001, 10, 2)),
                new Action(9, new DateTime(2001, 9, 2)),
                new Action(1, new DateTime(2001, 1, 2))
            });
        }
コード例 #3
0
        public async Task <Action[]> FindActionsByAccountsAsync(ActionQuery query, int[] accounts)
        {
            var i = _counter++;

            Console.WriteLine($"[{_sw.Elapsed}] [{i}] FindActionsByAccountsAsync invoking");

            try
            {
                return(await _searchServices.FindActionsByAccountsAsync(query, accounts));
            }
            finally
            {
                Console.WriteLine($"[{_sw.Elapsed}] [{i}] FindActionsByAccountsAsync invoked");
            }
        }