Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Commit

Permalink
Tidy projects in an enricosada style
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Oct 10, 2018
1 parent b27b22b commit 9ba0e9f
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 43 deletions.
2 changes: 2 additions & 0 deletions CallPolly.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".project", ".project", "{6047ADD6-C48C-4583-A5C6-58FDF7A0DC10}"
ProjectSection(SolutionItems) = preProject
build.cmd = build.cmd
Directory.Build.props = Directory.Build.props
global.json = global.json
LICENSE = LICENSE
README.md = README.md
SECURITY.md = SECURITY.md
Expand Down
14 changes: 14 additions & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project ToolsVersion="15.0">
<PropertyGroup>
<VersionPrefix>0.0.2</VersionPrefix>
<Authors>@jet @bartelink and contributors</Authors>
<Company>Jet.com</Company>
<Description>Apply systemwide resilience strategies consistently across subsystems, standing on Polly's shoulders</Description>
<PackageProjectUrl>https://github.com/jet/CallPolly</PackageProjectUrl>
<RepositoryUrl>https://github.com/jet/CallPolly</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>polly bulkhead circuitbreaker timeout fsharp</PackageTags>
<PackageLicenseUrl>https://github.com/jet/CallPolly/blob/master/LICENSE</PackageLicenseUrl>
<Copyright>Copyright © 2018</Copyright>
</PropertyGroup>
</Project>
5 changes: 4 additions & 1 deletion build.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ dotnet pack src/CallPolly --configuration Release -o "%CD%\bin" --version-suffix
if ERRORLEVEL 1 (echo Error building CallPolly; exit /b 1)

dotnet test tests/CallPolly.Tests --configuration Release
if ERRORLEVEL 1 (echo Error testing CallPolly; exit /b 1)
if ERRORLEVEL 1 (echo Error testing CallPolly; exit /b 1)

dotnet test tests/CallPolly.Acceptance --configuration Release
if ERRORLEVEL 1 (echo Error acceptance testing CallPolly; exit /b 1)
5 changes: 5 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "2.1.402"
}
}
24 changes: 6 additions & 18 deletions src/CallPolly/CallPolly.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,10 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
<VersionPrefix>0.0.1</VersionPrefix>
<Authors>@jet @bartelink and contributors</Authors>
<Company>Jet.com</Company>
<Description>Apply systemwide resilience strategies consistently across subsystems, standing on Polly's shoulders</Description>
<PackageProjectUrl>https://github.com/jet/CallPolly</PackageProjectUrl>
<RepositoryUrl>https://github.com/jet/CallPolly</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>polly circuitbreaker fsharp</PackageTags>
<PackageLicenseUrl>https://github.com/jet/CallPolly/blob/master/LICENSE</PackageLicenseUrl>
<Copyright>Copyright © 2018</Copyright>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<WarningLevel>5</WarningLevel>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<WarningLevel>5</WarningLevel>
<IsTestProject>false</IsTestProject>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<DisableImplicitSystemValueTupleReference>true</DisableImplicitSystemValueTupleReference>
</PropertyGroup>

<ItemGroup>
Expand All @@ -31,7 +17,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Jet.JsonNet.Converters" Version="0.0.1-CI67733" />
<PackageReference Include="FSharp.Core" Version="3.1.2.5" Condition=" '$(TargetFramework)' == 'net461' " />
<PackageReference Include="FSharp.Core" Version="4.3.4" Condition=" '$(TargetFramework)' == 'netstandard2.0' " />
<PackageReference Include="Jet.JsonNet.Converters" Version="0.0.3-CI69140" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Polly" Version="6.1.0" />
<PackageReference Include="Serilog" Version="2.7.1" />
Expand Down
10 changes: 5 additions & 5 deletions src/CallPolly/Config.fs
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ module Policy =
minThroughput = x.minRequests
errorRateThreshold = x.failPct/100.
retryAfter = TimeSpan.FromSeconds x.breakS
dryRun = x.dryRun |> Option.defaultValue false }
dryRun = defaultArg x.dryRun false }
| Input.Value.Limit x ->
Rule.Limit {
dop = x.maxParallel
queue = x.maxQueue
dryRun = x.dryRun |> Option.defaultValue false }
dryRun = defaultArg x.dryRun false }
| Input.Value.Cutoff ({ timeoutMs=TimeSpanMs timeout } as x) ->
Rule.Cutoff {
timeout = timeout
sla = x.slaMs |> Option.map (|TimeSpanMs|)
dryRun = x.dryRun |> Option.defaultValue false }
dryRun = defaultArg x.dryRun false }

let private fold : Rule seq -> Rules.PolicyConfig =
let folder (s : Rules.PolicyConfig) = function
Expand Down Expand Up @@ -103,8 +103,8 @@ module Http =
let private interpret (x: Input.Value): Rule seq = seq {
match x with
| Input.Value.Uri { ``base``=b; path=p } ->
match Option.toObj b with null -> () | b -> yield Rule.BaseUri(Uri b)
match Option.toObj p with null -> () | p -> yield Rule.RelUri(Uri(p, UriKind.Relative))
match b with Some null | None -> () | Some b -> yield Rule.BaseUri(Uri b)
match p with Some null | None -> () | Some p -> yield Rule.RelUri(Uri(p, UriKind.Relative))
| Input.Value.Sla { slaMs=TimeSpanMs sla; timeoutMs=TimeSpanMs timeout } -> yield Rule.Sla(sla,timeout)
| Input.Value.Log { req=req; res=res } -> yield Rule.Log(toRuleLog req,toRuleLog res) }

Expand Down
11 changes: 6 additions & 5 deletions src/CallPolly/Parser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ open Newtonsoft.Json.Converters.FSharp
open System
open System.Collections.Generic

/// Wrappers for Newtonsoft.Json
// shims for F# < 4, can be removed if we stop supporting that
module private Option =
let ofObj = function null -> None | x -> Some x

/// Wrappers for Newtonsoft.Json - OptionConverter is required
type Newtonsoft() =
static let settings =
let tmp = Settings.CreateDefault()
tmp.Converters.Add(OptionConverter())
tmp
static let settings = Settings.CreateCorrect(OptionConverter())

/// <summary>Deserializes value of given type from json string.</summary>
/// <param name="json">Json string to deserialize.</param>
Expand Down
4 changes: 4 additions & 0 deletions src/CallPolly/Rules.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ open System.Diagnostics
open System.Threading
open System.Threading.Tasks

// shims for F# < 4, can be removed if we stop supporting that
module private Option =
let toNullable = function Some x -> Nullable x | None -> Nullable ()

type BreakerConfig = { window: TimeSpan; minThroughput: int; errorRateThreshold: float; retryAfter: TimeSpan; dryRun: bool }
type BulkheadConfig = { dop: int; queue: int; dryRun: bool }
type CutoffConfig = { timeout: TimeSpan; sla: TimeSpan option; dryRun: bool }
Expand Down
11 changes: 4 additions & 7 deletions tests/CallPolly.Acceptance/CallPolly.Acceptance.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<WarningLevel>5</WarningLevel>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<WarningLevel>5</WarningLevel>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<DisableImplicitSystemValueTupleReference>true</DisableImplicitSystemValueTupleReference>
</PropertyGroup>

<ItemGroup>
Expand All @@ -19,6 +14,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FSharp.Core" Version="3.1.2.5" Condition=" '$(TargetFramework)' == 'net461' " />
<PackageReference Include="FSharp.Core" Version="4.3.4" Condition=" '$(TargetFramework)' == 'netstandard2.0' " />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Serilog.Sinks.Seq" Version="4.0.0" />
Expand Down
4 changes: 4 additions & 0 deletions tests/CallPolly.Acceptance/Orchestration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ open Swensen.Unquote
open System
open Xunit

// shims for F# < 4, can be removed if we stop supporting that
module private Seq =
let replicate n x = seq { for i in 1..n do yield x }

[<AutoOpen>]
module Helpers =
let ms x = TimeSpan.FromMilliseconds (float x)
Expand Down
11 changes: 4 additions & 7 deletions tests/CallPolly.Tests/CallPolly.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<WarningLevel>5</WarningLevel>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<WarningLevel>5</WarningLevel>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<DisableImplicitSystemValueTupleReference>true</DisableImplicitSystemValueTupleReference>
</PropertyGroup>

<ItemGroup>
Expand All @@ -20,6 +15,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FSharp.Core" Version="3.1.2.5" Condition=" '$(TargetFramework)' == 'net461' " />
<PackageReference Include="FSharp.Core" Version="4.3.4" Condition=" '$(TargetFramework)' == 'netstandard2.0' " />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="4.0.0" />
<PackageReference Include="Unquote" Version="4.0.0" />
Expand Down
6 changes: 6 additions & 0 deletions tests/CallPolly.Tests/RulesTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ open System
open Swensen.Unquote
open Xunit

// shims for F# < 4, can be removed if we stop supporting that
module private List =
let contains x = List.exists ((=) x)
module private Seq =
let replicate n x = seq { for i in 1..n do yield x }

[<AutoOpen>]
module Helpers =
let ms x = TimeSpan.FromMilliseconds (float x)
Expand Down

0 comments on commit 9ba0e9f

Please sign in to comment.