public static async IAsyncEnumerable <Transaction> GetTransactions(
            this ITransactionsClient transactionsClient,
            string?currency         = null,
            Transaction_state?state = null,
            string?walletId         = null,
            Transaction_type?type   = null,
            DateTime?startTime      = null,
            DateTime?endTime        = null,
            string?humanId          = null,
            Pagination?pagination   = null,
            [EnumeratorCancellation] CancellationToken cancellationToken = default)
        {
            pagination ??= Pagination.Default;
            var fetchPage = new Func <Pagination, Task <IPagedResponse <Transaction> > >(async p =>
            {
                var page = await transactionsClient.GetTransactionsAsync(currency, state, type, walletId,
                                                                         startTime, endTime, humanId, p?.Limit, p?.Before, p?.After, cancellationToken);
                return(page.Result);
            });

            await foreach (var transaction in pagination.EnumerateAsynchronously(fetchPage)
                           .WithCancellation(cancellationToken))
            {
                yield return(transaction);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Increments the cache value within a transaction.
        /// </summary>
        private static void IncrementCacheValue(
            ICacheClient <int, int> cache,
            ITransactionsClient transactions,
            int threadId)
        {
            try
            {
                using (var tx = transactions.TxStart(TransactionConcurrency.Optimistic,
                                                     TransactionIsolation.Serializable))
                {
                    // Increment cache value.
                    cache[1]++;

                    // Introduce a delay to ensure lock conflict.
                    Thread.Sleep(TimeSpan.FromSeconds(2.5));

                    tx.Commit();
                }

                Console.WriteLine("\n>>> Thread {0} successfully incremented cached value.", threadId);
            }
            catch (IgniteClientException ex)
            {
                Console.WriteLine("\n>>> Thread {0} failed to increment cached value. " +
                                  "Caught an expected optimistic exception: {1}", threadId, ex.Message);
            }
        }
        public void Dispose()
        {
            _transactions = null;
            var localEnlistment = _enlistment;

            if (localEnlistment != null)
            {
                localEnlistment.Dispose();
                _enlistment = null;
            }
        }
Beispiel #4
0
 public StatefulBot(
     ITransactionsClient transactionsClient,
     ICommandClient commandClient,
     TState initial,
     Func <TState, Transaction, TState> update,
     Func <TState, Commands> handler)
 {
     _transactionsClient = transactionsClient;
     _commandClient      = commandClient;
     _state   = initial;
     _update  = update;
     _handler = handler;
 }
Beispiel #5
0
 public StatelessBot(string ledgerId, Channel channel, string accessToken, Func <Transaction, Commands> handler)
 {
     _transactionClient = new TransactionsClient(ledgerId, channel, accessToken);
     _commandClient     = new CommandClient(ledgerId, channel, accessToken);
     _handler           = handler;
 }
 /// <summary>
 /// Initializes a new instance of <see cref="ClientCacheTransactionManager"/> class.
 /// </summary>
 /// <param name="transactions">Transactions.</param>
 public ClientCacheTransactionManager(ITransactionsClient transactions)
 {
     _transactions = transactions;
 }
Beispiel #7
0
 public TransactionsClientTests(CoinbaseApiFixture apiFixture, ITestOutputHelper output) : base(apiFixture, output)
 {
     _transactionsClient = ServiceProvider.GetRequiredService <ITransactionsClient>();
 }
 public TransactionsClient(ITransactionsClient transactionsClient, IScheduler scheduler = null)
 {
     _transactionsClient = transactionsClient;
     _scheduler          = scheduler;
 }