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());
 }
Exemplo n.º 2
0
        public async Task <IEnumerable <Task <int[]> > > FindAccountsAsync(AccountQuery query)
        {
            var i = _counter++;

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

            try
            {
                return(await _searchServices.FindAccountsAsync(query));
            }
            finally
            {
                Console.WriteLine($"[{_sw.Elapsed}] [{i}] FindAccountsAsync invoked");
            }
        }
Exemplo n.º 3
0
        public async Task should_return_actions_by_account_and_contact_queries()
        {
            var query = new TrackActionQuery
            {
                AccountQuery = new AccountQuery(),
                ContactQuery = new ContactQuery()
            };

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

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

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

            searchServices.FindActionsByContactsAsync(Arg.Any <ActionQuery>(), Arg.Is <int[]>(contacts => contacts.Length == 11)).Returns(Task.FromResult(new[]
            {
                new Action(9, new DateTime(2001, 9, 2)),
                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))
            });
        }