Skip to content

Commit

Permalink
Split Initialize into two overloads with separate xmldoc
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Apr 8, 2022
1 parent 3bce1ef commit 1ede7c3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
6 changes: 3 additions & 3 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -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`)
Expand Down
26 changes: 19 additions & 7 deletions src/FSharp.AWS.DynamoDB/TableContext.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1113,18 +1113,30 @@ type TableContext internal () =
/// </summary>
module Scripting =

/// Factory method that allows one to include auto-initialization easily for scripting scenarios
/// Factory methods for scripting scenarios
type TableContext internal () =

/// <summary>Creates a DynamoDB client instance for the specified F# record type, client and table name.</summary>
/// <summary>
/// Creates a DynamoDB client instance for the specified F# record type, client and table name.<br/>
/// Validates the table exists, and has the correct schema as per <c>VerifyTableAsync</c>.<br/>
/// See other overload for <c>VerifyOrCreateTableAsync</c> semantics.
/// </summary>
/// <param name="client">DynamoDB client instance.</param>
/// <param name="tableName">Table name to target.</param>
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.<br/>
/// Either validates the table exists and has the correct schema, or creates a fresh one, as per <c>VerifyOrCreateTableAsync</c>.<br/>
/// See other overload for <c>VerifyTableAsync</c> semantics.
/// <param name="client">DynamoDB client instance.</param>
/// <param name="tableName">Table name to target.</param>
/// <param name="throughput">Optional throughput to configure if the Table does not yet exist.</param>
static member Initialize<'TRecord>(client : IAmazonDynamoDB, tableName : string, ?throughput) : TableContext<'TRecord> =
/// <param name="throughput">Throughput to configure if the Table does not yet exist.</param>
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
Expand Down

0 comments on commit 1ede7c3

Please sign in to comment.