Beta release prep

- Modify retry logic to always attempt a reconnect
This commit is contained in:
2022-05-18 12:13:32 -04:00
parent e8f203ab5f
commit 7be81e3e4b
5 changed files with 98 additions and 20 deletions

View File

@@ -0,0 +1,80 @@
## RethinkDb.Driver.FSharp
This package provides idiomatic F# extensions on the [official C# driver][csharp-pkg]. Within this package:
### Connection Configuration / Creation
```fsharp
open RethinkDb.Driver.FSharp
let dataCfg = DataConfig.fromJson "rethink-config.json"
// - or -
let dataCfg = DataConfig.fromConfiguration [config-section]
let conn = dataCfg.CreateConnection () // IConnection
```
### Domain-Specific Language (DSL) / Computation Expression (CE) Style
```fsharp
open RethinkDb.Driver.FSharp
// Remove the conn parameter and usage for point-free style
let getPost postId conn =
rethink<Post> {
fromTable "Post"
get postId
resultOption
withRetryOptionDefault conn
}
let updatePost post conn =
rethink {
fromTable "Post"
get post.id
update post
write
ignoreResult
withRetryDefault conn
}
```
### Function Style
```fsharp
open RethinkDb.Driver.FSharp.Functions
// NOTE: this returns Task<Post>; checking for null/option is not handled
// as it is with the CE version
let getPost postId conn =
fromTable "Post"
|> get postId
|> runResult<Post>
|> withRetryDefault conn
// NOTE: this returns Task<Result>; ignoring inline is not available as
// it is with the CE version
let updatePost post conn =
fromTable "Post"
|> get post.id
|> update post
|> runWrite
|> withRetryDefault conn
```
### Retry Logic
The driver does not reconnect automatically when the underlying connection has been interrupted. When specified, the retry logic attempts to reconnect; default retries wait 200ms, 500ms, and 1 second. There are also functions to retry once, and those that allow the intervals to be specified.
### Strongly-Typed Optional Arguments
Many RethinkDB commands support optional arguments to tweak the behavior of that command. A quick example using the `between` command (clause):
```fsharp
// ...
between 1 100 [ LowerBound Open; UpperBound Closed ]
// ...
```
[csharp-pkg]: https://www.nuget.org/packages/RethinkDb.Driver/

View File

@@ -6,13 +6,14 @@
<Authors>Daniel J. Summers</Authors>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<PackageProjectUrl>https://github.com/danieljsummers/RethinkDb.Driver.FSharp</PackageProjectUrl>
<!-- PackageIconUrl>https://github.com/danieljsummers/RethinkDb.Driver.FSharp/raw/master/icon/icon.png</PackageIconUrl -->
<PackageIconUrl>https://github.com/danieljsummers/RethinkDb.Driver.FSharp/raw/main/pkg/icon.png</PackageIconUrl>
<PackageIcon>icon.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
<Copyright>See LICENSE</Copyright>
<PackageTags>RethinkDB document F#</PackageTags>
<VersionPrefix>0.8.0</VersionPrefix>
<VersionSuffix>alpha-0009</VersionSuffix>
<PackageReleaseNotes>Alpha; use at your own risk</PackageReleaseNotes>
<VersionPrefix>0.9.0</VersionPrefix>
<VersionSuffix>beta-01</VersionSuffix>
</PropertyGroup>
<ItemGroup>
@@ -21,6 +22,8 @@
<Compile Include="Functions.fs" />
<Compile Include="Builder.fs" />
<Compile Include="Config.fs" />
<None Include="README.md" Pack="true" PackagePath="\" />
<None Include="icon.png" Pack="true" PackagePath="\" />
</ItemGroup>
<ItemGroup>

View File

@@ -13,12 +13,9 @@ let retryPolicy (intervals : float seq) (conn : IConnection) =
.WaitAndRetryAsync(
intervals |> Seq.map TimeSpan.FromSeconds,
System.Action<exn, TimeSpan, int, Context> (fun ex _ _ _ ->
printf $"Encountered RethinkDB exception: {ex.Message}"
match ex.Message.Contains "socket" with
| true ->
printf "Reconnecting to RethinkDB"
(conn :?> Connection).Reconnect false
| false -> ()))
printfn $"Encountered RethinkDB exception: {ex.Message}"
printfn "Reconnecting to RethinkDB..."
(conn :?> Connection).Reconnect false))
/// Create a retry policy that attempts to reconnect to RethinkDB when a synchronous operation encounters an error
let retryPolicySync (intervals : float seq) (conn : IConnection) =

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB