From 1ede7c3b8a5104db4f07b7fa9cd698515b10a4f0 Mon Sep 17 00:00:00 2001 From: Ruben Bartelink Date: Fri, 8 Apr 2022 14:05:38 +0100 Subject: [PATCH] Split Initialize into two overloads with separate xmldoc --- RELEASE_NOTES.md | 6 +++--- src/FSharp.AWS.DynamoDB/TableContext.fs | 26 ++++++++++++++++++------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 5d0a91c..53a0807 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,10 +1,10 @@ ### 0.10.0-beta * Added `TableContext` constructor (replaces `TableContext.Create(verifyTable = false)`) -* Added `TableContext.Scripting.Initialize` (replaces `TableContext.Create()`) * Added `TableContext.VerifyOrCreateTableAsync` (replaces `TableContext.VerifyTableAsync(createIfNotExists = true)`) * Added `TableContext.UpdateTableIfRequiredAsync` (conditional `UpdateTableAsync` to establish specified `throughput` or `streaming` only if required. Replaces `UpdateProvisionedThroughputAsync`) -* Added `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 `VerifyOrCreateTableAsync` and `UpdateTableIfRequiredAsync` +* Added `TableContext.Scripting.Initialize` (two overloads, replacing `TableContext.Create()` and `TableContext.Create(createIfNotExists = true)`) +* Added `Throughput.OnDemand` mode (sets `BillingMode` to `PAY_PER_REQUEST`, to go with the existing support for configuring `PROVISIONED` and a `ProvisionedThroughput`) +* Added ability to configure DynamoDB streaming (via a `Streaming` DU) to `VerifyOrCreateTableAsync` and `UpdateTableIfRequiredAsync` * Obsoleted `TableContext.Create` (replace with `TableContext.Scripting.Initialize`, `TableContext.VerifyOrCreateTableAsync`, `TableContext.VerifyTableAsync`) * Obsoleted `TableContext.UpdateProvisionedThroughputAsync` (replace with `TableContext.UpdateTableIfRequiredAsync`) * (breaking) Obsoleted `TableContext.VerifyTableAsync` optional argument to create a Table (replace with `VerifyOrCreateTableAsync`) diff --git a/src/FSharp.AWS.DynamoDB/TableContext.fs b/src/FSharp.AWS.DynamoDB/TableContext.fs index 0a807c4..aa521f2 100644 --- a/src/FSharp.AWS.DynamoDB/TableContext.fs +++ b/src/FSharp.AWS.DynamoDB/TableContext.fs @@ -1113,18 +1113,30 @@ type TableContext internal () = /// module Scripting = - /// Factory method that allows one to include auto-initialization easily for scripting scenarios + /// Factory methods for scripting scenarios type TableContext internal () = - /// Creates a DynamoDB client instance for the specified F# record type, client and table name. + /// + /// Creates a DynamoDB client instance for the specified F# record type, client and table name.
+ /// Validates the table exists, and has the correct schema as per VerifyTableAsync.
+ /// See other overload for VerifyOrCreateTableAsync semantics. + ///
+ /// DynamoDB client instance. + /// Table name to target. + static member Initialize<'TRecord>(client : IAmazonDynamoDB, tableName : string) : TableContext<'TRecord> = + let context = TableContext<'TRecord>(client, tableName) + context.VerifyTableAsync() |> Async.RunSynchronously + context + + /// Creates a DynamoDB client instance for the specified F# record type, client and table name.
+ /// Either validates the table exists and has the correct schema, or creates a fresh one, as per VerifyOrCreateTableAsync.
+ /// See other overload for VerifyTableAsync semantics. /// DynamoDB client instance. /// Table name to target. - /// Optional throughput to configure if the Table does not yet exist. - static member Initialize<'TRecord>(client : IAmazonDynamoDB, tableName : string, ?throughput) : TableContext<'TRecord> = + /// Throughput to configure if the Table does not yet exist. + static member Initialize<'TRecord>(client : IAmazonDynamoDB, tableName : string, throughput) : TableContext<'TRecord> = let context = TableContext<'TRecord>(client, tableName) - match throughput with - | None -> context.VerifyTableAsync() |> Async.RunSynchronously - | Some t -> context.VerifyOrCreateTableAsync(t) |> Async.RunSynchronously + context.VerifyOrCreateTableAsync(throughput) |> Async.RunSynchronously context type TableContext<'TRecord> with