Ejemplo n.º 1
0
        protected override async Task ExecuteAsync(Row row, AsyncEnumerator <Row> .Yield @yield)
        {
            string name = (string)row["name"];

            row["FirstName"] = name.Split()[0];
            row["LastName"]  = name.Split()[1];
            await @yield.ReturnAsync(row);
        }
Ejemplo n.º 2
0
 protected override async Task ExecuteYield(IAsyncEnumerable <Row> rows, AsyncEnumerator <Row> .Yield yield,
                                            CancellationToken cancellationToken = default)
 {
     foreach (Row row in rowsToReturn)
     {
         await yield.ReturnAsync(row);
     }
 }
Ejemplo n.º 3
0
 protected override async Task ExecuteYield(IAsyncEnumerable <Row> rows,
                                            AsyncEnumerator <Row> .Yield yield,
                                            CancellationToken cancellationToken = default)
 {
     for (int i = 0; i < RowsAfterWhichToThrow; i++)
     {
         Row row = new Row();
         row["id"] = i;
         await yield.ReturnAsync(row);
     }
     throw new InvalidDataException("problem");
 }
        private static async Task EnumerateAndReturnFromCache <T>(IBlobStorage <T> cache, IEnumerable <string> itemsToReturn, AsyncEnumerator <T> .Yield yield)
        {
            using (GlobalTracer.Instance.BuildSpan(nameof(EnumerateAndReturnFromCache)).StartActive())
            {
                foreach (var id in itemsToReturn)
                {
                    T item = await cache.ReadItemAsync(id);

                    await yield.ReturnAsync(item);
                }
            }
        }
Ejemplo n.º 5
0
        protected override async Task ExecuteYield(
            IAsyncEnumerable <Row> rows,
            AsyncEnumerator <Row> .Yield yield,
            CancellationToken cancellationToken = default)
        {
            int a   = 0;
            int b   = 1;
            var row = new Row();

            row["id"] = 1;
            await yield.ReturnAsync(row);

            for (int i = 0; i < max - 1; i++)
            {
                int c = a + b;
                row       = new Row();
                row["id"] = c;
                await yield.ReturnAsync(row);

                a = b;
                b = c;
            }
        }
Ejemplo n.º 6
0
        protected override async Task ExecuteAsync(Row row, AsyncEnumerator <Row> .Yield yield)
        {
            var a = row["a"] as int?;
            var b = row["b"] as int?;

            row["operation"] = "subtract";
            row["result"]    = a - b;
            if (withErrors)
            {
                Error(new ApplicationException(), "Error in Subtract");
            }

            await yield.ReturnAsync(row);
        }
        private static async Task <HashSet <string> > EnumerateAndReturnFromRemote <T>(
            Func <T, string> getPersistentKey,
            IAsyncEnumerable <T> remoteQuerySendsToCache,
            AsyncEnumerator <T> .Yield yield)
        {
            HashSet <string> itemKeysEnumeratedFromRemote = new HashSet <string>();

            using (GlobalTracer.Instance.BuildSpan(nameof(EnumerateAndReturnFromRemote)).StartActive())
            {
                using (IAsyncEnumerator <T> enumerator = await remoteQuerySendsToCache.GetAsyncEnumeratorAsync())
                {
                    while (await enumerator.MoveNextAsync())
                    {
                        string key = getPersistentKey(enumerator.Current);
                        itemKeysEnumeratedFromRemote.Add(key);
                        await yield.ReturnAsync(enumerator.Current);
                    }
                }
            }

            return(itemKeysEnumeratedFromRemote);
        }
Ejemplo n.º 8
0
        protected override async Task ExecuteAsync(Row row, AsyncEnumerator <Row> .Yield yield)
        {
            Results.Add(row);

            await yield.ReturnAsync(row);
        }
Ejemplo n.º 9
0
 protected override async Task ExecuteAsync(Row row, AsyncEnumerator <Row> .Yield yield)
 {
     stringBuilder.Append(row["operation"] + " ");
     await yield.ReturnAsync(row);
 }