Esempio n. 1
0
        public async Task <GetItemResult> GetItemAsync(GetItemRequest request)
        {
            var httpRequest = Setup("GetItem", request.ToJson());

            var json = await SendAndReadJsonElementAsync(httpRequest).ConfigureAwait(false);

            return(GetItemResult.FromJsonElement(json));
        }
Esempio n. 2
0
        /*
         * public void DeleteTable()
         * {
         *  throw new NotImplementedException();
         * }
         *
         * public void DescribeTable()
         * {
         *  throw new NotImplementedException();
         * }
         */

        public async Task <GetItemResult> GetItemAsync(GetItemRequest request)
        {
            var httpRequest = Setup("GetItem", request.ToJson());

            var responseText = await SendAsync(httpRequest).ConfigureAwait(false);

            var responseJson = JsonObject.Parse(responseText);

            return(GetItemResult.FromJson(responseJson));
        }
Esempio n. 3
0
        internal async Task <T?> FindAsync(GetItemRequest request)
        {
            var       retryCount    = 0;
            Exception?lastException = null;

            do
            {
                if (retryCount > 0)
                {
                    await Task.Delay(retryPolicy.GetDelay(retryCount)).ConfigureAwait(false);
                }

                try
                {
                    var result = await client.GetItemAsync(request).ConfigureAwait(false);

                    // TODO: NotFound Handling

                    if (result.Item is null)
                    {
                        return(null);
                    }

                    return(result.Item.As <T>(metadata));
                }
                catch (DynamoDbException ex) when(ex.IsTransient)
                {
                    lastException = ex;
                }

                retryCount++;
            }while (retryPolicy.ShouldRetry(retryCount));

            var key = string.Join(",", request.Key.Select(k => k.Value));

            var errorMessage = $"Unrecoverable exception getting '{key}' from '{tableName}'";

            throw new Exception(errorMessage, lastException);
        }