示例#1
0
 //--- Constructors ---
 public DynamoTableQuery(DynamoTable table, QueryRequest request, ADynamoQueryClause <TRecord> queryClause)
 {
     _table       = table ?? throw new ArgumentNullException(nameof(table));
     _request     = request ?? throw new ArgumentNullException(nameof(request));
     _queryClause = queryClause ?? throw new ArgumentNullException(nameof(queryClause));
     _converter   = new DynamoRequestConverter(_request.ExpressionAttributeNames, _request.ExpressionAttributeValues, _table.SerializerOptions);
 }
示例#2
0
        /// <summary>
        /// Writes the given object to the DynamoDB table.  Property name are case sensitive.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="item"></param>
        /// <param name="tbl"></param>
        private Task <Document> WriteToTableAsync(EntType item)
        {
            var itemJson = JsonConvert.SerializeObject(item);
            var doc      = Document.FromJson(itemJson);

            return(DynamoTable.PutItemAsync(doc));
        }
示例#3
0
 public Task <Document> GetByKeyAsync(Dictionary <string, DynamoDBEntry> key)
 {
     if (key == null)
     {
         throw new ArgumentNullException(nameof(key));
     }
     return(DynamoTable.GetItemAsync(key));
 }
示例#4
0
 //--- Constructors ---
 public DynamoTableTransactGetItems(DynamoTable table, TransactGetItemsRequest request)
 {
     _table      = table ?? throw new ArgumentNullException(nameof(table));
     _request    = request ?? throw new ArgumentNullException(nameof(request));
     _converters = _request.TransactItems
                   .Select(transactItem => new DynamoRequestConverter(transactItem.Get.ExpressionAttributeNames, _table.SerializerOptions))
                   .ToList();
 }
        public void CreateDynamoDbIfDoesNotExist()
        {
            DynamoDbConfig config = GetDynamoDbConfig();
            DynamoTable    table  = new DynamoTable(config, _client);

            table.CreateIfNotExist();

            AssertDynamoDbExists(_tableName);
        }
示例#6
0
        /// <summary>
        /// Updates or Inserts the given item
        /// </summary>
        public Task <Document> UpdateAsync(EntType item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }
            var itemJson = JsonConvert.SerializeObject(item);
            var doc      = Document.FromJson(itemJson);

            return(DynamoTable.UpdateItemAsync(doc));
        }
示例#7
0
 //--- Methods ---
 public override async Task InitializeAsync(LambdaConfig config)
 {
     _table = new DynamoTable(
         config.ReadDynamoDBTableName("GameTable"),
         new AmazonDynamoDBClient()
         );
     _gameStateMachine    = config.ReadText("GameLoopStateMachine");
     _stepFunctionsClient = new AmazonStepFunctionsClient();
     _lambdaClient        = new AmazonLambdaClient();
     _gameTurnFunctionArn = config.ReadText("GameTurnFunction");
 }
        public void CanHandleConcurrentCalls()
        {
            DynamoDbConfig config = GetDynamoDbConfig();

            var table = new DynamoTable(config, _client);
            var tasks = Enumerable.Repeat(Task.Factory.StartNew(table.CreateIfNotExist), 10);

            Task.WaitAll(tasks.ToArray());

            AssertDynamoDbExists(_tableName);
        }
示例#9
0
 //--- Methods ---
 public override async Task InitializeAsync(LambdaConfig config)
 {
     // initialize Lambda function
     _lambdaClient = new AmazonLambdaClient();
     _amaClient    = new AmazonApiGatewayManagementApiClient(new AmazonApiGatewayManagementApiConfig {
         ServiceURL = config.ReadText("Module::WebSocket::Url")
     });
     _table = new DynamoTable(
         config.ReadDynamoDBTableName("GameTable"),
         new AmazonDynamoDBClient()
         );
     _gameApiUrl = config.ReadText("RestApiUrl");
 }
示例#10
0
        public void CanReadAndWriteData()
        {
            var          client   = new AmazonDynamoDBClient(RegionEndpoint.EUWest1);
            const string itemId   = "1";
            var          provider = new DynamoStore(new DynamoDBContext(client));
            var          config   = GetDynamoDbConfig();
            var          table    = new DynamoTable(config, client);

            table.CreateIfNotExist();

            provider.Save(new FakeDynamoItem {
                Id = itemId
            }, new DynamoDBOperationConfig());
            var result = provider.Read <FakeDynamoItem>(itemId, new DynamoDBOperationConfig());

            Assert.IsNotNull(result);
            Console.WriteLine(result.Id);
            Assert.AreEqual(result.Id, itemId);
        }
示例#11
0
 //--- Constructors ---
 public ThriftBooksDataAccessTests(DynamoDbFixture dynamoDbFixture, ITestOutputHelper output) : base(dynamoDbFixture, output)
 {
     DataAccessClient = new ThriftBooksDataAccessClient(dynamoDbFixture.TableName, dynamoDbFixture.DynamoClient);
     Table            = new DynamoTable(TableName, DynamoClient, ThriftBooksDataAccessClient.TableOptions);
 }
示例#12
0
 //--- Constructors ---
 public DynamoTableDeleteItem(DynamoTable table, DeleteItemRequest request)
 {
     _table     = table ?? throw new ArgumentNullException(nameof(table));
     _request   = request ?? throw new ArgumentNullException(nameof(request));
     _converter = new DynamoRequestConverter(_request.ExpressionAttributeNames, _request.ExpressionAttributeValues, _table.SerializerOptions);
 }
 //--- Constructors ---
 public DynamoTableTransactGetItems(DynamoTable table, TransactGetItemsRequest request)
 {
     _table      = table ?? throw new ArgumentNullException(nameof(table));
     _request    = request ?? throw new ArgumentNullException(nameof(request));
     _converters = new List <DynamoRequestConverter>();
 }
 //--- Constructors ---
 public DynamoTableBatchGetItems(DynamoTable table, BatchGetItemRequest request)
 {
     _table     = table ?? throw new ArgumentNullException(nameof(table));
     _request   = request ?? throw new ArgumentNullException(nameof(request));
     _converter = new DynamoRequestConverter(request.RequestItems.Single().Value.ExpressionAttributeNames, _table.SerializerOptions);
 }
示例#15
0
 //--- Constructors ---
 public DynamoTableTransactWriteItems(DynamoTable table, TransactWriteItemsRequest request)
 {
     _table   = table ?? throw new ArgumentNullException(nameof(table));
     _request = request ?? throw new ArgumentNullException(nameof(request));
 }