Compare commits
1 Commits
toward-1.0
...
test-in-do
| Author | SHA1 | Date | |
|---|---|---|---|
| 972a147fb9 |
@@ -41,15 +41,13 @@ let fetchPost (postId : string) =
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
### A standard way to translate JSON or a URI into a strongly-typed configuration
|
### A standard way to translate JSON into a strongly-typed configuration
|
||||||
|
|
||||||
```fsharp
|
```fsharp
|
||||||
/// type: DataConfig
|
/// type: DataConfig
|
||||||
let config = DataConfig.fromJsonFile "data-config.json"
|
let config = DataConfig.fromJsonFile "data-config.json"
|
||||||
// OR
|
// OR
|
||||||
let config = DataConfig.fromConfiguration (config.GetSection "RethinkDB")
|
let config = DataConfig.fromConfiguration (config.GetSection "RethinkDB")
|
||||||
// OR
|
|
||||||
let config = DataConfig.fromUri (config.GetConnectionString "RethinkDB")
|
|
||||||
|
|
||||||
/// type: IConnection
|
/// type: IConnection
|
||||||
let conn = config.Connect ()
|
let conn = config.Connect ()
|
||||||
|
|||||||
25
src/.dockerignore
Normal file
25
src/.dockerignore
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
**/.dockerignore
|
||||||
|
**/.env
|
||||||
|
**/.git
|
||||||
|
**/.gitignore
|
||||||
|
**/.project
|
||||||
|
**/.settings
|
||||||
|
**/.toolstarget
|
||||||
|
**/.vs
|
||||||
|
**/.vscode
|
||||||
|
**/.idea
|
||||||
|
**/*.*proj.user
|
||||||
|
**/*.dbmdl
|
||||||
|
**/*.jfm
|
||||||
|
**/azds.yaml
|
||||||
|
**/bin
|
||||||
|
**/charts
|
||||||
|
**/docker-compose*
|
||||||
|
**/Dockerfile*
|
||||||
|
**/node_modules
|
||||||
|
**/npm-debug.log
|
||||||
|
**/obj
|
||||||
|
**/secrets.dev.yaml
|
||||||
|
**/values.dev.yaml
|
||||||
|
LICENSE
|
||||||
|
README.md
|
||||||
23
src/Dockerfile
Normal file
23
src/Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
|
||||||
|
WORKDIR /src
|
||||||
|
COPY ["RethinkDb.Driver.FSharp.Tests/RethinkDb.Driver.FSharp.Tests.fsproj", "RethinkDb.Driver.FSharp.Tests/"]
|
||||||
|
RUN dotnet restore "RethinkDb.Driver.FSharp.Tests/RethinkDb.Driver.FSharp.Tests.fsproj"
|
||||||
|
COPY . .
|
||||||
|
WORKDIR "/src/RethinkDb.Driver.FSharp.Tests"
|
||||||
|
RUN dotnet build "RethinkDb.Driver.FSharp.Tests.fsproj" -c Release -o /app/build
|
||||||
|
|
||||||
|
FROM build AS publish
|
||||||
|
RUN dotnet publish "RethinkDb.Driver.FSharp.Tests.fsproj" -c Release -r linux-x64 --self-contained true -o /app/publish
|
||||||
|
|
||||||
|
FROM rethinkdb:latest AS test
|
||||||
|
WORKDIR /app
|
||||||
|
COPY --from=publish /app/publish .
|
||||||
|
ENTRYPOINT ["RethinkDb.Driver.FSharp.Tests"]
|
||||||
|
|
||||||
|
# FROM base AS final
|
||||||
|
# WORKDIR /app
|
||||||
|
# COPY --from=publish /app/publish .
|
||||||
|
# ENTRYPOINT ["dotnet", "RethinkDb.Driver.FSharp.Tests.dll"]
|
||||||
1
src/RethinkDb.Driver.FSharp.Tests/Program.fs
Normal file
1
src/RethinkDb.Driver.FSharp.Tests/Program.fs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
module Program = let [<EntryPoint>] main _ = 0
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
<GenerateProgramFile>false</GenerateProgramFile>
|
||||||
|
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Types.fs" />
|
||||||
|
<Compile Include="Tests.fs" />
|
||||||
|
<Compile Include="Program.fs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
|
||||||
|
<PackageReference Include="xunit" Version="2.4.1" />
|
||||||
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="coverlet.collector" Version="3.1.0">
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include=".dockerignore" />
|
||||||
|
<Content Include="Dockerfile" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\RethinkDb.Driver.FSharp\RethinkDb.Driver.FSharp.fsproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
17
src/RethinkDb.Driver.FSharp.Tests/Tests.fs
Normal file
17
src/RethinkDb.Driver.FSharp.Tests/Tests.fs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
module Tests
|
||||||
|
|
||||||
|
open System
|
||||||
|
open RethinkDb.Driver
|
||||||
|
open RethinkDb.Driver.FSharp.Functions
|
||||||
|
open Types
|
||||||
|
open Xunit
|
||||||
|
|
||||||
|
let private r = RethinkDB.R
|
||||||
|
|
||||||
|
[<Fact>]
|
||||||
|
let ``My test`` () =
|
||||||
|
Assert.True(true)
|
||||||
|
|
||||||
|
let ``dbCreate succeeds`` () =
|
||||||
|
dbCreate "fsharp_driver_test"
|
||||||
|
|> runWrite
|
||||||
16
src/RethinkDb.Driver.FSharp.Tests/Types.fs
Normal file
16
src/RethinkDb.Driver.FSharp.Tests/Types.fs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
module Types
|
||||||
|
|
||||||
|
/// A simple type to use for testing
|
||||||
|
type BasicType =
|
||||||
|
{ // The ID for this record
|
||||||
|
id : string
|
||||||
|
|
||||||
|
/// A field with a boolean value
|
||||||
|
boolField : bool
|
||||||
|
|
||||||
|
/// A field with an integer value
|
||||||
|
intField : int
|
||||||
|
|
||||||
|
/// A field with a string value
|
||||||
|
stringField : string
|
||||||
|
}
|
||||||
@@ -4,6 +4,8 @@ VisualStudioVersion = 17.1.32228.430
|
|||||||
MinimumVisualStudioVersion = 15.0.26124.0
|
MinimumVisualStudioVersion = 15.0.26124.0
|
||||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "RethinkDb.Driver.FSharp", "RethinkDb.Driver.FSharp\RethinkDb.Driver.FSharp.fsproj", "{9026E009-55DC-454E-87B7-39B9CBAD8BF8}"
|
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "RethinkDb.Driver.FSharp", "RethinkDb.Driver.FSharp\RethinkDb.Driver.FSharp.fsproj", "{9026E009-55DC-454E-87B7-39B9CBAD8BF8}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "RethinkDb.Driver.FSharp.Tests", "RethinkDb.Driver.FSharp.Tests\RethinkDb.Driver.FSharp.Tests.fsproj", "{FC062B8C-81D5-4E0A-B3BA-A84541298BDB}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -26,6 +28,18 @@ Global
|
|||||||
{9026E009-55DC-454E-87B7-39B9CBAD8BF8}.Release|x64.Build.0 = Release|Any CPU
|
{9026E009-55DC-454E-87B7-39B9CBAD8BF8}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{9026E009-55DC-454E-87B7-39B9CBAD8BF8}.Release|x86.ActiveCfg = Release|Any CPU
|
{9026E009-55DC-454E-87B7-39B9CBAD8BF8}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{9026E009-55DC-454E-87B7-39B9CBAD8BF8}.Release|x86.Build.0 = Release|Any CPU
|
{9026E009-55DC-454E-87B7-39B9CBAD8BF8}.Release|x86.Build.0 = Release|Any CPU
|
||||||
|
{FC062B8C-81D5-4E0A-B3BA-A84541298BDB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{FC062B8C-81D5-4E0A-B3BA-A84541298BDB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{FC062B8C-81D5-4E0A-B3BA-A84541298BDB}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
|
{FC062B8C-81D5-4E0A-B3BA-A84541298BDB}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
|
{FC062B8C-81D5-4E0A-B3BA-A84541298BDB}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
|
{FC062B8C-81D5-4E0A-B3BA-A84541298BDB}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
|
{FC062B8C-81D5-4E0A-B3BA-A84541298BDB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{FC062B8C-81D5-4E0A-B3BA-A84541298BDB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{FC062B8C-81D5-4E0A-B3BA-A84541298BDB}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
|
{FC062B8C-81D5-4E0A-B3BA-A84541298BDB}.Release|x64.Build.0 = Release|Any CPU
|
||||||
|
{FC062B8C-81D5-4E0A-B3BA-A84541298BDB}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
|
{FC062B8C-81D5-4E0A-B3BA-A84541298BDB}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,10 @@
|
|||||||
namespace RethinkDb.Driver.FSharp
|
namespace RethinkDb.Driver.FSharp
|
||||||
|
|
||||||
open System
|
|
||||||
open Microsoft.Extensions.Configuration
|
open Microsoft.Extensions.Configuration
|
||||||
open Microsoft.Extensions.Logging
|
|
||||||
open Newtonsoft.Json.Linq
|
open Newtonsoft.Json.Linq
|
||||||
open RethinkDb.Driver
|
open RethinkDb.Driver
|
||||||
open RethinkDb.Driver.Net
|
open RethinkDb.Driver.Net
|
||||||
|
open System.Threading.Tasks
|
||||||
|
|
||||||
/// Parameters for the RethinkDB configuration
|
/// Parameters for the RethinkDB configuration
|
||||||
type DataConfigParameter =
|
type DataConfigParameter =
|
||||||
@@ -37,42 +36,17 @@ type DataConfig =
|
|||||||
static member empty =
|
static member empty =
|
||||||
{ Parameters = [] }
|
{ Parameters = [] }
|
||||||
|
|
||||||
/// Build the connection from the given parameters
|
/// Create a RethinkDB connection
|
||||||
member private this.BuildConnection() =
|
member this.CreateConnection () : IConnection =
|
||||||
this.Parameters
|
this.Parameters
|
||||||
|> Seq.fold ConnectionBuilder.build (RethinkDB.R.Connection ())
|
|> Seq.fold ConnectionBuilder.build (RethinkDB.R.Connection ())
|
||||||
|
|> function builder -> builder.Connect ()
|
||||||
|
|
||||||
/// Create a RethinkDB connection (task async)
|
/// Create a RethinkDB connection
|
||||||
member this.CreateConnection() = backgroundTask {
|
member this.CreateConnectionAsync () : Task<Connection> =
|
||||||
let! conn = this.BuildConnection().ConnectAsync()
|
this.Parameters
|
||||||
return conn :> IConnection
|
|> Seq.fold ConnectionBuilder.build (RethinkDB.R.Connection ())
|
||||||
}
|
|> function builder -> builder.ConnectAsync ()
|
||||||
|
|
||||||
/// Create a RethinkDB connection, logging the connection settings (task async)
|
|
||||||
member this.CreateConnection(log: ILogger) = backgroundTask {
|
|
||||||
let builder = this.BuildConnection()
|
|
||||||
if not (isNull log) then log.LogInformation $"Connecting to {this.EffectiveUri}"
|
|
||||||
let! conn = builder.ConnectAsync()
|
|
||||||
return conn :> IConnection
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a RethinkDB connection (F# async)
|
|
||||||
member this.CreateAsyncConnection() =
|
|
||||||
this.CreateConnection() |> Async.AwaitTask
|
|
||||||
|
|
||||||
/// Create a RethinkDB connection, logging the connection settings (F# async)
|
|
||||||
member this.CreateAsyncConnection(log: ILogger) =
|
|
||||||
this.CreateConnection(log) |> Async.AwaitTask
|
|
||||||
|
|
||||||
/// Create a RethinkDB connection (sync)
|
|
||||||
member this.CreateSyncConnection() : IConnection =
|
|
||||||
this.BuildConnection().Connect()
|
|
||||||
|
|
||||||
/// Create a RethinkDB connection, logging the connection settings (sync)
|
|
||||||
member this.CreateSyncConnection(log: ILogger) : IConnection =
|
|
||||||
let builder = this.BuildConnection()
|
|
||||||
if not (isNull log) then log.LogInformation $"Connecting to {this.EffectiveUri}"
|
|
||||||
builder.Connect()
|
|
||||||
|
|
||||||
/// The effective hostname
|
/// The effective hostname
|
||||||
member this.Hostname =
|
member this.Hostname =
|
||||||
@@ -98,20 +72,6 @@ type DataConfig =
|
|||||||
| Some (Database x) -> x
|
| Some (Database x) -> x
|
||||||
| _ -> RethinkDBConstants.DefaultDbName
|
| _ -> RethinkDBConstants.DefaultDbName
|
||||||
|
|
||||||
/// The effective configuration URI (excludes password / auth key)
|
|
||||||
member this.EffectiveUri =
|
|
||||||
seq {
|
|
||||||
"rethinkdb://"
|
|
||||||
match this.Parameters |> List.tryPick (fun x -> match x with User _ -> Some x | _ -> None) with
|
|
||||||
| Some (User(username, _)) -> $"{username}:***pw***@"
|
|
||||||
| _ ->
|
|
||||||
match this.Parameters |> List.tryPick (fun x -> match x with AuthKey _ -> Some x | _ -> None) with
|
|
||||||
| Some (AuthKey _) -> "****key****@"
|
|
||||||
| _ -> ()
|
|
||||||
$"{this.Hostname}:{this.Port}/{this.Database}?timeout={this.Timeout}"
|
|
||||||
}
|
|
||||||
|> String.concat ""
|
|
||||||
|
|
||||||
/// Parse settings from JSON
|
/// Parse settings from JSON
|
||||||
///
|
///
|
||||||
/// A sample JSON object with all the possible properties filled in:
|
/// A sample JSON object with all the possible properties filled in:
|
||||||
@@ -156,26 +116,3 @@ type DataConfig =
|
|||||||
match cfg["username"], cfg["password"] with null, _ | _, null -> () | user -> User user
|
match cfg["username"], cfg["password"] with null, _ | _, null -> () | user -> User user
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parse settings from a URI
|
|
||||||
///
|
|
||||||
/// rethinkdb://user:password@host:port/database?timeout=##
|
|
||||||
/// OR
|
|
||||||
/// rethinkdb://authkey@host:port/database?timeout=##
|
|
||||||
///
|
|
||||||
/// Scheme and host are required; all other settings optional
|
|
||||||
static member FromUri(uri: string) =
|
|
||||||
let it = Uri uri
|
|
||||||
if it.Scheme <> "rethinkdb" then invalidArg "Scheme" $"""URI scheme must be "rethinkdb" (was {it.Scheme})"""
|
|
||||||
{ Parameters =
|
|
||||||
[ Hostname it.Host
|
|
||||||
if it.Port <> -1 then Port it.Port
|
|
||||||
if it.UserInfo <> "" then
|
|
||||||
if it.UserInfo.Contains ":" then
|
|
||||||
let parts = it.UserInfo.Split ':' |> Array.truncate 2
|
|
||||||
User(parts[0], parts[1])
|
|
||||||
else AuthKey it.UserInfo
|
|
||||||
if it.Segments.Length > 1 then Database it.Segments[1]
|
|
||||||
if it.Query.Contains "?timeout=" then Timeout(int it.Query[9..])
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -18,17 +18,15 @@ module private Helpers =
|
|||||||
// ~~ WRITES ~~
|
// ~~ WRITES ~~
|
||||||
|
|
||||||
/// Write a ReQL command with a cancellation token, always returning a result
|
/// Write a ReQL command with a cancellation token, always returning a result
|
||||||
let runWriteResultWithCancel cancelToken (expr: ReqlExpr) = fun conn -> backgroundTask {
|
let runWriteResultWithCancel cancelToken (expr : ReqlExpr) = fun conn ->
|
||||||
return! expr.RunWriteAsync(conn, cancelToken)
|
expr.RunWriteAsync (conn, cancelToken)
|
||||||
}
|
|
||||||
|
|
||||||
/// Write a ReQL command, always returning a result
|
/// Write a ReQL command, always returning a result
|
||||||
let runWriteResult expr = runWriteResultWithCancel CancellationToken.None expr
|
let runWriteResult expr = runWriteResultWithCancel CancellationToken.None expr
|
||||||
|
|
||||||
/// Write a ReQL command with optional arguments and a cancellation token, always returning a result
|
/// Write a ReQL command with optional arguments and a cancellation token, always returning a result
|
||||||
let runWriteResultWithOptArgsAndCancel args cancelToken (expr: ReqlExpr) = fun conn -> backgroundTask {
|
let runWriteResultWithOptArgsAndCancel args cancelToken (expr : ReqlExpr) = fun conn ->
|
||||||
return! expr.RunWriteAsync(conn, RunOptArg.create args, cancelToken)
|
expr.RunWriteAsync (conn, RunOptArg.create args, cancelToken)
|
||||||
}
|
|
||||||
|
|
||||||
/// Write a ReQL command with optional arguments, always returning a result
|
/// Write a ReQL command with optional arguments, always returning a result
|
||||||
let runWriteResultWithOptArgs args expr = runWriteResultWithOptArgsAndCancel args CancellationToken.None expr
|
let runWriteResultWithOptArgs args expr = runWriteResultWithOptArgsAndCancel args CancellationToken.None expr
|
||||||
@@ -110,14 +108,12 @@ let syncWriteWithOptArgs args expr = fun conn ->
|
|||||||
// ~~ Full results (atom / sequence) ~~
|
// ~~ Full results (atom / sequence) ~~
|
||||||
|
|
||||||
/// Run the ReQL command using a cancellation token, returning the result as the type specified
|
/// Run the ReQL command using a cancellation token, returning the result as the type specified
|
||||||
let runResultWithCancel<'T> cancelToken (expr: ReqlExpr) = fun conn -> backgroundTask {
|
let runResultWithCancel<'T> cancelToken (expr : ReqlExpr) = fun conn ->
|
||||||
return! expr.RunResultAsync<'T>(conn, cancelToken)
|
expr.RunResultAsync<'T> (conn, cancelToken)
|
||||||
}
|
|
||||||
|
|
||||||
/// Run the ReQL command using optional arguments and a cancellation token, returning the result as the type specified
|
/// Run the ReQL command using optional arguments and a cancellation token, returning the result as the type specified
|
||||||
let runResultWithOptArgsAndCancel<'T> args cancelToken (expr: ReqlExpr) = fun conn -> backgroundTask {
|
let runResultWithOptArgsAndCancel<'T> args cancelToken (expr : ReqlExpr) = fun conn ->
|
||||||
return! expr.RunResultAsync<'T>(conn, RunOptArg.create args, cancelToken)
|
expr.RunResultAsync<'T> (conn, RunOptArg.create args, cancelToken)
|
||||||
}
|
|
||||||
|
|
||||||
/// Run the ReQL command, returning the result as the type specified
|
/// Run the ReQL command, returning the result as the type specified
|
||||||
let runResult<'T> expr = runResultWithCancel<'T> CancellationToken.None expr
|
let runResult<'T> expr = runResultWithCancel<'T> CancellationToken.None expr
|
||||||
@@ -169,22 +165,20 @@ let asAsyncOption (f: IConnection -> Async<'T>) conn = async {
|
|||||||
let asSyncOption (f : IConnection -> 'T) conn = nullToOption (f conn)
|
let asSyncOption (f : IConnection -> 'T) conn = nullToOption (f conn)
|
||||||
|
|
||||||
/// Ignore the result of a task-based query
|
/// Ignore the result of a task-based query
|
||||||
let ignoreResult<'T> (f: IConnection -> Tasks.Task<'T>) conn = backgroundTask {
|
let ignoreResult<'T> (f : IConnection -> Tasks.Task<'T>) conn = task {
|
||||||
let! _ = f conn
|
let! _ = (f conn).ConfigureAwait false
|
||||||
()
|
()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ~~ Cursors / partial results (sequence / partial) ~~
|
// ~~ Cursors / partial results (sequence / partial) ~~
|
||||||
|
|
||||||
/// Run the ReQL command using a cancellation token, returning a cursor for the type specified
|
/// Run the ReQL command using a cancellation token, returning a cursor for the type specified
|
||||||
let runCursorWithCancel<'T> cancelToken (expr: ReqlExpr) = fun conn -> backgroundTask {
|
let runCursorWithCancel<'T> cancelToken (expr : ReqlExpr) = fun conn ->
|
||||||
return! expr.RunCursorAsync<'T>(conn, cancelToken)
|
expr.RunCursorAsync<'T> (conn, cancelToken)
|
||||||
}
|
|
||||||
|
|
||||||
/// Run the ReQL command using optional arguments and a cancellation token, returning a cursor for the type specified
|
/// Run the ReQL command using optional arguments and a cancellation token, returning a cursor for the type specified
|
||||||
let runCursorWithOptArgsAndCancel<'T> args cancelToken (expr: ReqlExpr) = fun conn -> backgroundTask {
|
let runCursorWithOptArgsAndCancel<'T> args cancelToken (expr : ReqlExpr) = fun conn ->
|
||||||
return! expr.RunCursorAsync<'T>(conn, RunOptArg.create args, cancelToken)
|
expr.RunCursorAsync<'T> (conn, RunOptArg.create args, cancelToken)
|
||||||
}
|
|
||||||
|
|
||||||
/// Run the ReQL command, returning a cursor for the type specified
|
/// Run the ReQL command, returning a cursor for the type specified
|
||||||
let runCursor<'T> expr = runCursorWithCancel<'T> CancellationToken.None expr
|
let runCursor<'T> expr = runCursorWithCancel<'T> CancellationToken.None expr
|
||||||
@@ -235,13 +229,13 @@ let toList<'T> (f: IConnection -> Task<Cursor<'T>>) = fun conn -> backgroundTask
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a cursor to a list of items
|
/// Convert a cursor to a list of items
|
||||||
let asyncToList<'T> (f: IConnection -> Async<Cursor<'T>>) = fun conn -> async {
|
let toListAsync<'T> (f : IConnection -> Async<Cursor<'T>>) = fun conn -> async {
|
||||||
use! cursor = f conn
|
use! cursor = f conn
|
||||||
return! cursorToList<'T> cursor |> Async.AwaitTask
|
return! cursorToList<'T> cursor |> Async.AwaitTask
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Convert a cursor to a list of items
|
/// Convert a cursor to a list of items
|
||||||
let syncToList<'T> (f: IConnection -> Cursor<'T>) = fun conn ->
|
let toListSync<'T> (f : IConnection -> Cursor<'T>) = fun conn ->
|
||||||
use cursor = f conn
|
use cursor = f conn
|
||||||
cursorToList cursor |> Async.AwaitTask |> Async.RunSynchronously
|
cursorToList cursor |> Async.AwaitTask |> Async.RunSynchronously
|
||||||
|
|
||||||
@@ -646,9 +640,7 @@ let withRetry<'T> intervals f =
|
|||||||
|
|
||||||
/// Convert an async function to a task function (Polly does not understand F# Async)
|
/// Convert an async function to a task function (Polly does not understand F# Async)
|
||||||
let private asyncFuncToTask<'T> (f : IConnection -> Async<'T>) =
|
let private asyncFuncToTask<'T> (f : IConnection -> Async<'T>) =
|
||||||
fun conn -> backgroundTask {
|
fun conn -> f conn |> Async.StartAsTask
|
||||||
return! f conn |> Async.StartAsTask
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Retry, delaying for each the seconds provided (if required)
|
/// Retry, delaying for each the seconds provided (if required)
|
||||||
let withAsyncRetry<'T> intervals f = fun conn ->
|
let withAsyncRetry<'T> intervals f = fun conn ->
|
||||||
|
|||||||
@@ -159,10 +159,10 @@ val syncCursorWithOptArgs<'T> : RunOptArg list -> ReqlExpr -> (IConnection -> Cu
|
|||||||
val toList<'T> : (IConnection -> Task<Cursor<'T>>) -> IConnection -> Task<'T list>
|
val toList<'T> : (IConnection -> Task<Cursor<'T>>) -> IConnection -> Task<'T list>
|
||||||
|
|
||||||
/// Convert a cursor to a list of items
|
/// Convert a cursor to a list of items
|
||||||
val asyncToList<'T> : (IConnection -> Async<Cursor<'T>>) -> IConnection -> Async<'T list>
|
val toListAsync<'T> : (IConnection -> Async<Cursor<'T>>) -> IConnection -> Async<'T list>
|
||||||
|
|
||||||
/// Convert a cursor to a list of items
|
/// Convert a cursor to a list of items
|
||||||
val syncToList<'T> : (IConnection -> Cursor<'T>) -> IConnection -> 'T list
|
val toListSync<'T> : (IConnection -> Cursor<'T>) -> IConnection -> 'T list
|
||||||
|
|
||||||
/// Apply a connection to the query pipeline (typically the final step)
|
/// Apply a connection to the query pipeline (typically the final step)
|
||||||
val withConn<'T> : IConnection -> (IConnection -> 'T) -> 'T
|
val withConn<'T> : IConnection -> (IConnection -> 'T) -> 'T
|
||||||
|
|||||||
@@ -374,3 +374,4 @@ module UpdateOptArg =
|
|||||||
| NonAtomic non -> upd.OptArg ("non_atomic", non)
|
| NonAtomic non -> upd.OptArg ("non_atomic", non)
|
||||||
| IgnoreWriteHook ign -> upd.OptArg ("ignore_write_hook", ign))
|
| IgnoreWriteHook ign -> upd.OptArg ("ignore_write_hook", ign))
|
||||||
u
|
u
|
||||||
|
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ open RethinkDb.Driver.FSharp
|
|||||||
let dataCfg = DataConfig.fromJson "rethink-config.json"
|
let dataCfg = DataConfig.fromJson "rethink-config.json"
|
||||||
// - or -
|
// - or -
|
||||||
let dataCfg = DataConfig.fromConfiguration [config-section]
|
let dataCfg = DataConfig.fromConfiguration [config-section]
|
||||||
// - or -
|
|
||||||
let dataCfg = DataConfig.fromUri [connection-string]
|
|
||||||
|
|
||||||
let conn = dataCfg.CreateConnection () // IConnection
|
let conn = dataCfg.CreateConnection () // IConnection
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
|
||||||
<Description>Idiomatic F# extensions on the official RethinkDB C# driver</Description>
|
<Description>Idiomatic F# extensions on the official RethinkDB C# driver</Description>
|
||||||
<Authors>Daniel J. Summers,Bit Badger Solutions</Authors>
|
<Authors>Daniel J. Summers,Bit Badger Solutions</Authors>
|
||||||
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
|
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
|
||||||
@@ -13,9 +13,10 @@
|
|||||||
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
|
||||||
<Copyright>See LICENSE</Copyright>
|
<Copyright>See LICENSE</Copyright>
|
||||||
<PackageTags>RethinkDB document F#</PackageTags>
|
<PackageTags>RethinkDB document F#</PackageTags>
|
||||||
<VersionPrefix>1.0.0</VersionPrefix>
|
<VersionPrefix>0.9.0</VersionPrefix>
|
||||||
|
<VersionSuffix>beta-06</VersionSuffix>
|
||||||
<PackageReleaseNotes>
|
<PackageReleaseNotes>
|
||||||
Add URI config option and logging CreateConnection overloads
|
Add optional arguments for tableCreate
|
||||||
</PackageReleaseNotes>
|
</PackageReleaseNotes>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
@@ -31,11 +32,11 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||||
<PackageReference Include="Polly" Version="8.5.0" />
|
<PackageReference Include="Polly" Version="7.2.3" />
|
||||||
<PackageReference Include="RethinkDb.Driver" Version="2.*" />
|
<PackageReference Include="RethinkDb.Driver" Version="2.*" />
|
||||||
<PackageReference Update="FSharp.Core" Version="9.0.100" />
|
<PackageReference Update="FSharp.Core" Version="6.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user