Exemplo n.º 1
0
 /// <summary>
 /// Creates the table referred by this reference.
 /// </summary>
 /// <param name="key">The definition of the key schema for this table. Must contain at least a primary key.</param>
 /// <param name="provisionType">Type of provisioning (number of read/write operations per second).</param>
 /// <param name="provisionLoad">Option of provision load (how the number of operations are divided between the read and write throughput).</param>
 /// <returns>This table reference.</returns>
 public UnityTask <StorageResponse <TableMetadata> > Create(TableKey key, ProvisionType provisionType, ProvisionLoad provisionLoad)
 {
     return(_repository.CreateTable(new TableMetadata
     {
         provisionLoad = provisionLoad,
         provisionType = provisionType,
         name = TableName,
         key = key,
     }));
 }
Exemplo n.º 2
0
        IEnumerator TestRestTableAsync()
        {
            Terminal.LogImportant("TestRestTableAsync (This is really slow)");

            // Make Table
            var tableName = Strings.RandomString(10);
            var meta1     = new TableMetadata
            {
                name          = tableName,
                provisionLoad = ProvisionLoad.Balanced,
                provisionType = ProvisionType.Custom,
                throughput    = new TableThroughput(1, 1),
                key           = new TableKey(new Key("ID1", Key.DataType.STRING), new Key("ID2", Key.DataType.NUMBER)),
            };


            //CREATE
            Terminal.Log("CREATE " + tableName);
            var result1 = Repository.CreateTable(meta1);

            yield return(StartCoroutine(result1.WaitRoutine()));

            result1.ThrowIfFaulted();
            if (result1.Result.hasError)
            {
                throw new Exception(result1.Result.error.message);
            }

            //wait...
            var meta2 = WaitForTable(Repository, tableName);

            yield return(StartCoroutine(meta2.WaitRoutine()));

            meta2.ThrowIfFaulted();

            //LIST
            Terminal.Log("LIST");
            var result4 = Repository.ListTables();

            yield return(StartCoroutine(result4.WaitRoutine()));

            result4.ThrowIfFaulted();
            if (result4.Result.hasError)
            {
                throw new Exception(result4.Result.error.message);
            }
            Assert.IsTrue(result4.Result.data.tables.Any(), "request returned no results");

            //UPDATE
            Terminal.Log("UPDATE");
            meta2.Result.throughput    = new TableThroughput(2, 2);
            meta2.Result.provisionType = ProvisionType.Custom;
            var result3 = Repository.UpdateTable(meta2.Result);

            yield return(StartCoroutine(result3.WaitRoutine()));

            result3.ThrowIfFaulted();
            if (result3.Result.hasError)
            {
                throw new Exception(result3.Result.error.message);
            }

            //wait...
            var meta3 = WaitForTable(Repository, tableName, 5000);

            yield return(StartCoroutine(meta3.WaitRoutine()));

            meta3.ThrowIfFaulted();

            //DELETE
            Terminal.Log("DELETE");
            var result5 = Repository.DeleteTable(tableName);

            yield return(StartCoroutine(result5.WaitRoutine()));

            result5.ThrowIfFaulted();
            if (result5.Result.hasError)
            {
                throw new Exception(result5.Result.error.message);
            }

            Terminal.LogSuccess("Test Success");
        }