@@ -918,7 +918,6 @@ type TableContext<'TRecord> internal
918
918
return ()
919
919
}
920
920
921
-
922
921
member internal _.InternalDescribe () : Async < TableDescription > =
923
922
let rec wait () = async {
924
923
let! ct = Async.CancellationToken
@@ -933,7 +932,7 @@ type TableContext<'TRecord> internal
933
932
}
934
933
wait ()
935
934
936
- member internal __.CreateOrValidateTableAsync ( createThroughput ) : Async < TableDescription > =
935
+ member internal __.InternalProvision (? makeCreateTableRequest ) : Async < TableDescription > =
937
936
let (| Conflict | _ |) ( e : exn ) =
938
937
match e with
939
938
| :? AmazonDynamoDBException as e when e.StatusCode = HttpStatusCode.Conflict -> Some()
@@ -950,11 +949,10 @@ type TableContext<'TRecord> internal
950
949
|> invalidOp
951
950
return desc
952
951
953
- | Choice2Of2 (: ? ResourceNotFoundException ) when Option .isSome createThroughput ->
952
+ | Choice2Of2 (: ? ResourceNotFoundException ) when Option .isSome makeCreateTableRequest ->
954
953
let! ct = Async.CancellationToken
955
- let ctr = template.Info.Schemata.CreateCreateTableRequest( tableName, Option.get createThroughput)
956
954
let! response =
957
- client.CreateTableAsync( ctr , ct)
955
+ client.CreateTableAsync( makeCreateTableRequest.Value () , ct)
958
956
|> Async.AwaitTaskCorrect
959
957
|> Async.Catch
960
958
@@ -975,48 +973,51 @@ type TableContext<'TRecord> internal
975
973
976
974
checkOrCreate 9 // up to 9 retries, i.e. 10 attempts before we let exception propagate
977
975
978
- /// <summary>
979
- /// Asynchronously verify that the table exists and is compatible with record key schema.
980
- /// </summary>
981
- /// <param name="createIfNotExists">Create the table instance now instance if it does not exist. Defaults to false.</param>
982
- /// <param name="provisionedThroughput">Provisioned throughput for the table if newly created. Defaults to (10,10).</param>
983
- [<System.Obsolete( " Please replace with either 1. VerifyTableAsync or 2. InitializeTableAsync" ) >]
984
- member __.VerifyTableAsync (? createIfNotExists : bool , ? provisionedThroughput : ProvisionedThroughput ) : Async < unit > =
985
- let throughputIfCreate =
986
- if createIfNotExists = Some true then
987
- let throughput = match provisionedThroughput with Some p -> p | None -> ProvisionedThroughput( 10 L, 10 L)
988
- Some throughput
989
- else None
990
- __. CreateOrValidateTableAsync( throughputIfCreate) |> Async.Ignore
976
+ member internal _.InternalCreateTableRequest ( throughput ) =
977
+ template.Info.Schemata.CreateCreateTableRequest( tableName, throughput)
978
+ member internal t.InternalCreateOrValidateTableAsync ( createThroughput ) =
979
+ t.InternalProvision( fun () -> t.InternalCreateTableRequest( createThroughput))
991
980
992
981
/// <summary>
993
982
/// Asynchronously verify that the table exists and is compatible with record key schema, or throw.<br/>
994
983
/// See also <c>InitializeTableAsync</c>, which performs the same check, but can create or re-provision the Table if required.
995
984
/// </summary>
996
985
member __.VerifyTableAsync () : Async < unit > =
997
- __. CreateOrValidateTableAsync ( None ) |> Async.Ignore
986
+ __. InternalProvision ( ) |> Async.Ignore
998
987
999
988
/// <summary>
1000
989
/// Asynchronously verifies that the table exists and is compatible with record key schema, throwing if it is incompatible.<br/>
1001
990
/// If the table is not present, it is provisioned, with the specified <c>throughput</c>.<br/>
1002
991
/// See also <c>VerifyTableAsync</c>, which only verifies the Table is present and correct.
1003
992
/// </summary>
1004
993
/// <param name="throughput">Provisioned throughput to use for the table.</param>
1005
- member __ .InitializeTableAsync( throughput : ProvisionedThroughput ) : Async < unit > =
1006
- __. CreateOrValidateTableAsync ( Some throughput) |> Async.Ignore
994
+ member t .InitializeTableAsync( throughput : ProvisionedThroughput ) : Async < unit > =
995
+ t.InternalCreateOrValidateTableAsync ( throughput) |> Async.Ignore
1007
996
1008
997
/// <summary>
1009
998
/// Asynchronously verifies that the table exists and is compatible with record key schema, throwing if it is incompatible.<br/>
1010
999
/// If the table is not present, it is provisioned, with the specified <c>throughput</c>.<br/>
1011
1000
/// If it is present, and the throughput is not as specified, uses <c>UpdateProvisionedThroughputAsync</c> to update it. <br/>
1012
1001
/// </summary>
1013
1002
/// <param name="throughput">Provisioned throughput to use for the table.</param>
1014
- member __.ProvisionTableAsync ( throughput : ProvisionedThroughput ) : Async < unit > = async {
1015
- let! desc = __. CreateOrValidateTableAsync( Some throughput)
1016
- let provisioned = desc.ProvisionedThroughput
1017
- if throughput.ReadCapacityUnits <> provisioned.ReadCapacityUnits
1018
- || throughput.WriteCapacityUnits <> provisioned.WriteCapacityUnits then
1019
- do ! __. UpdateProvisionedThroughputAsync( throughput) }
1003
+ member t.ProvisionTableAsync ( throughput : ProvisionedThroughput ) : Async < unit > = async {
1004
+ let! tableDescription = t.InternalCreateOrValidateTableAsync( throughput)
1005
+ let provisioned = tableDescription.ProvisionedThroughput
1006
+ if throughput.ReadCapacityUnits <> provisioned.ReadCapacityUnits || throughput.WriteCapacityUnits <> provisioned.WriteCapacityUnits then
1007
+ do ! t.UpdateProvisionedThroughputAsync( throughput) }
1008
+
1009
+ /// <summary>
1010
+ /// Asynchronously verify that the table exists and is compatible with record key schema.
1011
+ /// </summary>
1012
+ /// <param name="createIfNotExists">Create the table instance now instance if it does not exist. Defaults to false.</param>
1013
+ /// <param name="provisionedThroughput">Provisioned throughput for the table if newly created. Defaults to (10,10).</param>
1014
+ [<System.Obsolete( " Please replace with either 1. VerifyTableAsync or 2. InitializeTableAsync" ) >]
1015
+ member t.VerifyTableAsync (? createIfNotExists : bool , ? provisionedThroughput : ProvisionedThroughput ) : Async < unit > =
1016
+ if createIfNotExists = Some true then
1017
+ let throughput = match provisionedThroughput with Some p -> p | None -> ProvisionedThroughput( 10 L, 10 L)
1018
+ t.InitializeTableAsync( throughput)
1019
+ else
1020
+ t.VerifyTableAsync()
1020
1021
1021
1022
// Deprecated factory method, to be removed. Replaced with
1022
1023
// 1. TableContext<'T> ctor (synchronous)
0 commit comments