diff --git a/README.md b/README.md index 3416945..5552b0a 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ type Counter private (table : TableContext, key : TableKey) = static member Create(client : IAmazonDynamoDB, tableName : string) = async { let table = TableContext(client, tableName) let throughput = ProvisionedThroughput(readCapacityUnits = 10L, writeCapacityUnits = 10L) - do! table.InitializeTableAsync(Throughput.Provisioned throughput) + do! table.CreateTableIfNotExistsAsync(Throughput.Provisioned throughput) let initialEntry = { Id = Guid.NewGuid() ; Value = 0L } let! key = table.PutItemAsync(initialEntry) return Counter(table, key) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index b787e5c..9237554 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -5,15 +5,15 @@ * Added `TryGetItemAsync` (same as `GetItemAsync`, but returns `None`, instead of throwing, if an item is not present) * Switched test framework to Xunit, assertions to Unquote, runner to `dotnet test` * Clarified Creation/Verification APIs: - * Obsoleted `TableContext.Create` (replace with `TableContext.Scripting.Initialize` and/or `TableContext.InitializeTableAsync`) + * Obsoleted `TableContext.Create` (replace with `TableContext.Scripting.Initialize`, `TableContext.CreateTableIfNotExistsAsync`, `TableContext.VerifyTableAsync`) * Added `TableContext` constructor (replaces `TableContext.Create(verifyTable = false)`) * Added `TableContext.Scripting.Initialize` (replaces `TableContext.Create()`) * Added `TableContext.VerifyTableAsync` overload that only performs verification but never creates a Table - * Added `TableContext.InitializeTableAsync` (replaces `TableContext.VerifyTableAsync(createIfNotExists = true)`) - * Added `TableContext.ProvisionTableAsync` (as per `InitializeTableAsync` but does an `UpdateTableAsync` if `throughput` or `streaming` has changed) + * Added `TableContext.CreateTableIfNotExistsAsync` (replaces `TableContext.VerifyTableAsync(createIfNotExists = true)`) + * Added `TableContext.ProvisionTableAsync` (as per `CreateTableIfNotExistsAsync` but does an `UpdateTableAsync` if `throughput` or `streaming` has changed) * Added Support for `Throughput.OnDemand` mode (sets `BillingMode` to `PAY_PER_REQUEST` rather than attempting to configure a `ProvisionedThroughput`) - * Added ability to configure DynamoDB streaming (via `Streaming` DU) to `InitializeTableAsync` and `ProvisionTableAsync` - * Removed `TableContext.CreateAsync` (replace with `TableContext.VerifyTableAsync` or `InitializeTableAsync`) + * Added ability to configure DynamoDB streaming (via `Streaming` DU) to `CreateTableIfNotExistsAsync` and `ProvisionTableAsync` + * Removed `TableContext.CreateAsync` (replace with `TableContext.VerifyTableAsync` or `CreateTableIfNotExistsAsync`) * Replaced `TableKeySchemata.CreateCreateTableRequest` with `ApplyToCreateTableRequest` ### 0.9.3-beta diff --git a/src/FSharp.AWS.DynamoDB/Script.fsx b/src/FSharp.AWS.DynamoDB/Script.fsx index 7841757..5ac9325 100644 --- a/src/FSharp.AWS.DynamoDB/Script.fsx +++ b/src/FSharp.AWS.DynamoDB/Script.fsx @@ -128,7 +128,7 @@ type EasyCounters private (table : TableContext) = // Create the table if necessary. Verifies schema is correct if it has already been created // NOTE the hard coded initial throughput provisioning - arguably this belongs outside of your application logic let throughput = ProvisionedThroughput(readCapacityUnits = 10L, writeCapacityUnits = 10L) - do! table.InitializeTableAsync(Throughput.Provisioned throughput) + do! table.CreateTableIfNotExistsAsync(Throughput.Provisioned throughput) return EasyCounters(table) } @@ -141,7 +141,7 @@ type SimpleCounters private (table : TableContext) = static member Provision(client : IAmazonDynamoDB, tableName : string, readCapacityUnits, writeCapacityUnits) : Async = let table = TableContext(client, tableName) // normally, RCU/WCU provisioning only happens first time the Table is created and is then considered an external concern - // here we use `ProvisionTableAsync` instead of `InitializeTableAsync` to reset it each time we deploy the app + // here we use `ProvisionTableAsync` instead of `CreateTableIfNotExistsAsync` to reset it each time we deploy the app let provisionedThroughput = ProvisionedThroughput(readCapacityUnits, writeCapacityUnits) table.ProvisionTableAsync(Throughput.Provisioned provisionedThroughput) diff --git a/src/FSharp.AWS.DynamoDB/TableContext.fs b/src/FSharp.AWS.DynamoDB/TableContext.fs index ee75398..1a03eff 100644 --- a/src/FSharp.AWS.DynamoDB/TableContext.fs +++ b/src/FSharp.AWS.DynamoDB/TableContext.fs @@ -420,7 +420,7 @@ type TableContext<'TRecord> internal /// /// Creates a DynamoDB client instance for given F# record and table name.
- /// For creating, provisioning or verification, see InitializeTableAsync and VerifyTableAsync. + /// For creating, provisioning or verification, see CreateTableIfNotExistsAsync and VerifyTableAsync. ///
/// DynamoDB client instance. /// Table name to target. @@ -1017,7 +1017,7 @@ type TableContext<'TRecord> internal /// /// Asynchronously verify that the table exists and is compatible with record key schema, or throw.
- /// See also InitializeTableAsync, which performs the same check, but can create or re-provision the Table if required. + /// See also CreateTableIfNotExistsAsync, which performs the same check, but can create or re-provision the Table if required. ///
member _.VerifyTableAsync() : Async = Provisioning.validateOnly (client, tableName, template) @@ -1027,14 +1027,14 @@ type TableContext<'TRecord> internal /// /// Asynchronously verifies that the table exists and is compatible with record key schema, throwing if it is incompatible.
- /// If the table is not present, it is provisioned, with the specified throughput.
+ /// If the table is not present, it is created, with the specified throughput.
/// See also VerifyTableAsync, which only verifies the Table is present and correct.
/// See also ProvisionTableAsync, which will adjust throughput and streaming if they are not as specified. ///
/// Throughput configuration to use for the table. /// Optional streaming configuration to apply for the table. Default: Disabled.. /// Callback to post-process the CreateTableRequest. - member t.InitializeTableAsync(throughput : Throughput, ?streaming, ?customize) : Async = + member t.CreateTableIfNotExistsAsync(throughput : Throughput, ?streaming, ?customize) : Async = t.InternalCreateOrValidate(throughput, ?streaming = streaming, ?customize = customize) |> Async.Ignore /// @@ -1074,17 +1074,17 @@ type TableContext<'TRecord> internal /// Asynchronously verify that the table exists and is compatible with record key schema. /// Create the table instance now instance if it does not exist. Defaults to false. /// Provisioned throughput for the table if newly created. Defaults to (10,10). - [] + [] member t.VerifyTableAsync(?createIfNotExists : bool, ?provisionedThroughput : ProvisionedThroughput) : Async = if createIfNotExists = Some true then let throughput = match provisionedThroughput with Some p -> p | None -> ProvisionedThroughput(10L, 10L) - t.InitializeTableAsync(Throughput.Provisioned throughput) + t.CreateTableIfNotExistsAsync(Throughput.Provisioned throughput) else t.VerifyTableAsync() // Deprecated factory method, to be removed. Replaced with // 1. TableContext<'T> ctor (synchronous) -// 2. InitializeTableAsync OR VerifyTableAsync (explicitly async to signify that verification/creation is a costly and/or privileged operation) +// 2. CreateTableIfNotExistsAsync OR VerifyTableAsync (explicitly async to signify that verification/creation is a costly and/or privileged operation) type TableContext internal () = /// @@ -1097,7 +1097,7 @@ type TableContext internal () = /// Provisioned throughput for the table if newly created. Default: 10 RCU, 10 WCU /// Function to receive request metrics. [] static member Create<'TRecord> ( client : IAmazonDynamoDB, tableName : string, ?verifyTable : bool, @@ -1106,7 +1106,7 @@ type TableContext internal () = let context = TableContext<'TRecord>(client, tableName, ?metricsCollector = metricsCollector) if createIfNotExists = Some true then let throughput = match provisionedThroughput with Some p -> p | None -> ProvisionedThroughput(10L, 10L) - do! context.InitializeTableAsync(Throughput.Provisioned throughput) + do! context.CreateTableIfNotExistsAsync(Throughput.Provisioned throughput) elif verifyTable <> Some false then do! context.VerifyTableAsync() return context } @@ -1132,7 +1132,7 @@ module Scripting = let context = TableContext<'TRecord>(client, tableName, ?metricsCollector = metricsCollector) match throughput with | None -> context.VerifyTableAsync() |> Async.RunSynchronously - | Some t -> context.InitializeTableAsync(t) |> Async.RunSynchronously + | Some t -> context.CreateTableIfNotExistsAsync(t) |> Async.RunSynchronously context type TableContext<'TRecord> with