Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use tasks from fsharpx #125

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion Build/Orleankka.FSharp.nuspec
Expand Up @@ -11,7 +11,8 @@
<description>F# api for Orleankka</description>
<tags>Orleans distributed messaging actor concurrency functional F#</tags>
<dependencies>
<dependency id="Orleankka" version="$core_version$" />
<dependency id="Orleankka" version="$core_version$" />
<dependency id="FSharpx.Extras" version="[2.2]" />
</dependencies>
</metadata>
<files>
Expand Down
8 changes: 7 additions & 1 deletion Source/FSharp.Demo.HelloWorld/App.config
Expand Up @@ -4,7 +4,13 @@
<gcServer enabled="true" />
<gcConcurrent enabled="false" />

</runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.4.0.0" />
</dependentAssembly>
</assemblyBinding></runtime>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
Expand Down
44 changes: 44 additions & 0 deletions Source/FSharp.Demo.HelloWorld/HelloWorld.fsproj
Expand Up @@ -107,6 +107,50 @@
<Target Name="AfterBuild">
</Target>
-->
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<ItemGroup>
<Reference Include="FSharp.Control.AsyncSeq">
<HintPath>..\..\packages\FSharp.Control.AsyncSeq\lib\net45\FSharp.Control.AsyncSeq.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<ItemGroup>
<Reference Include="FSharpx.Async">
<HintPath>..\..\packages\FSharpx.Async\lib\net45\FSharpx.Async.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<ItemGroup>
<Reference Include="FSharpx.Collections">
<HintPath>..\..\packages\FSharpx.Collections\lib\net40\FSharpx.Collections.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<ItemGroup>
<Reference Include="FSharpx.Extras">
<HintPath>..\..\packages\FSharpx.Extras\lib\net45\FSharpx.Extras.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<ItemGroup>
Expand Down
9 changes: 6 additions & 3 deletions Source/FSharp.Demo.HelloWorld/Program.fs
Expand Up @@ -6,6 +6,9 @@ open Orleankka.FSharp
open Orleankka.FSharp.Configuration
open Orleankka.FSharp.Runtime

open FSharpx
open FSharpx.Task

type Message =
| Greet of string
| Hi
Expand Down Expand Up @@ -34,9 +37,9 @@ let main argv =
let actor = ActorSystem.actorOf<Greeter>(system, "actor_id")

let job() = task {
do! actor <! Hi
do! actor <! Greet "Yevhen"
do! actor <! Greet "AntyaDev"
do! actor.Tell <| Hi
do! actor.Tell <| Greet "Yevhen"
do! actor.Tell <| Greet "AntyaDev"
}

Task.run(job) |> ignore
Expand Down
3 changes: 2 additions & 1 deletion Source/FSharp.Demo.HelloWorld/paket.references
Expand Up @@ -8,4 +8,5 @@ Microsoft.Orleans.OrleansCodeGenerator
Microsoft.Orleans.OrleansRuntime
Newtonsoft.Json
System.Collections.Immutable
System.Reflection.Metadata
System.Reflection.Metadata
FSharpx.Extras
2 changes: 2 additions & 0 deletions Source/FSharp.Demo.Shop/Account.fs
Expand Up @@ -4,6 +4,8 @@ open Orleankka
open Orleankka
open Orleankka.FSharp

open FSharpx.Task

type AccountMessage =
| Balance
| Deposit of int
Expand Down
8 changes: 7 additions & 1 deletion Source/FSharp.Demo.Shop/App.config
Expand Up @@ -4,7 +4,13 @@
<gcServer enabled="true" />
<gcConcurrent enabled="false" />

</runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.4.0.0" />
</dependentAssembly>
</assemblyBinding></runtime>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
Expand Down
21 changes: 12 additions & 9 deletions Source/FSharp.Demo.Shop/Program.fs
Expand Up @@ -8,6 +8,9 @@ open Orleankka.FSharp.Runtime
open Shop
open Account

open FSharpx
open FSharpx.Task

[<EntryPoint>]
let main argv =

Expand All @@ -21,33 +24,33 @@ let main argv =
let account = ActorSystem.actorOf<Account>(system, "antya")

let job() = task {
let! stock = shop <? Stock
let! stock = shop.Ask <|Stock
printfn "Shop has %i items in stock \n" stock

let! balance = account <? Balance
let! balance = account.Ask <|Balance
printfn "Account balance is %i \n" balance

printfn "Let's put 100$ on the account \n"
do! account <! Deposit(100)
do! account.Tell <|Deposit(100)

printfn "Let's put 5 items in stock \n"
do! shop <! CheckIn(5)
do! shop.Tell <|CheckIn(5)

let! stock = shop <? Stock
let! stock = shop.Ask <|Stock
printfn "Now shop has %i items in stock \n" stock

try
printfn "Let's sell 100 items to user \n"
do! shop <! Sell(account, 100)
do! shop.Tell <|Sell(account, 100)
with :? InvalidOperationException as e -> printf "[Exception]: %s \n" e.Message

printfn "Let's sell 2 items to user \n"
do! shop <! Sell(account, 2)
do! shop.Tell <|Sell(account, 2)

let! stock = shop <? Stock
let! stock = shop.Ask <|Stock
printfn "Now shop has %i items in stock \n" stock

let! balance = account <? Balance
let! balance = account.Ask <|Balance
printfn "And account balance is %i \n" balance
}

Expand Down
4 changes: 3 additions & 1 deletion Source/FSharp.Demo.Shop/Shop.fs
@@ -1,5 +1,7 @@
module Shop

open FSharpx.Task

open Orleankka
open Orleankka.FSharp

Expand All @@ -26,7 +28,7 @@ type Shop() =

| Sell (account, count) ->
let amount = count * price
do! account <! Withdraw(amount)
do! account.Tell <| Withdraw(amount)
cash <- cash + amount
stock <- stock - count
return nothing
Expand Down
44 changes: 44 additions & 0 deletions Source/FSharp.Demo.Shop/Shop.fsproj
Expand Up @@ -109,6 +109,50 @@
<Target Name="AfterBuild">
</Target>
-->
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<ItemGroup>
<Reference Include="FSharp.Control.AsyncSeq">
<HintPath>..\..\packages\FSharp.Control.AsyncSeq\lib\net45\FSharp.Control.AsyncSeq.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<ItemGroup>
<Reference Include="FSharpx.Async">
<HintPath>..\..\packages\FSharpx.Async\lib\net45\FSharpx.Async.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<ItemGroup>
<Reference Include="FSharpx.Collections">
<HintPath>..\..\packages\FSharpx.Collections\lib\net40\FSharpx.Collections.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<ItemGroup>
<Reference Include="FSharpx.Extras">
<HintPath>..\..\packages\FSharpx.Extras\lib\net45\FSharpx.Extras.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion Source/FSharp.Demo.Shop/paket.references
Expand Up @@ -8,4 +8,5 @@ Microsoft.Orleans.OrleansCodeGenerator
Microsoft.Orleans.OrleansRuntime
Newtonsoft.Json
System.Collections.Immutable
System.Reflection.Metadata
System.Reflection.Metadata
FSharpx.Extras
8 changes: 7 additions & 1 deletion Source/FSharp.Example.Observers.Chat.Client/App.config
Expand Up @@ -4,4 +4,10 @@
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>

</configuration>
<runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.4.0.0" />
</dependentAssembly>
</assemblyBinding></runtime></configuration>
30 changes: 26 additions & 4 deletions Source/FSharp.Example.Observers.Chat.Client/Client.fsproj
Expand Up @@ -99,8 +99,8 @@
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<ItemGroup>
<Reference Include="Microsoft.CodeAnalysis">
<HintPath>..\..\packages\Microsoft.CodeAnalysis.Common\lib\net45\Microsoft.CodeAnalysis.dll</HintPath>
<Reference Include="FSharp.Control.AsyncSeq">
<HintPath>..\..\packages\FSharp.Control.AsyncSeq\lib\net45\FSharp.Control.AsyncSeq.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
Expand All @@ -110,8 +110,30 @@
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<ItemGroup>
<Reference Include="Microsoft.CodeAnalysis.CSharp">
<HintPath>..\..\packages\Microsoft.CodeAnalysis.CSharp\lib\net45\Microsoft.CodeAnalysis.CSharp.dll</HintPath>
<Reference Include="FSharpx.Async">
<HintPath>..\..\packages\FSharpx.Async\lib\net45\FSharpx.Async.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<ItemGroup>
<Reference Include="FSharpx.Collections">
<HintPath>..\..\packages\FSharpx.Collections\lib\net40\FSharpx.Collections.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.5.1'">
<ItemGroup>
<Reference Include="FSharpx.Extras">
<HintPath>..\..\packages\FSharpx.Extras\lib\net45\FSharpx.Extras.dll</HintPath>
<Private>True</Private>
<Paket>True</Paket>
</Reference>
Expand Down
11 changes: 7 additions & 4 deletions Source/FSharp.Example.Observers.Chat.Client/Program.fs
@@ -1,10 +1,13 @@
open System
open System.Reflection


open Orleankka
open Orleankka.FSharp
open Orleankka.FSharp.Configuration

open FSharpx.Task

open Messages

let mutable client = null
Expand Down Expand Up @@ -37,20 +40,20 @@ let main argv =

let job() = task {
printfn "Connecting.... \n"
let! response = server <? Join(userName, client.Ref)
let! response = server.Ask <|Join(userName, client.Ref)
printfn "Connected! \n"
printfn "%s\n" response

let textStream = Seq.initInfinite(fun _ -> Console.ReadLine())

textStream
|> Seq.find(function "quit" -> server <* Disconnect(userName, client.Ref)
|> Seq.find(function "quit" -> server.Notify <| Disconnect(userName, client.Ref)
true
| text -> server <* Say(userName, text)
| text -> server.Notify <| Say(userName, text)
false)
|> ignore
}

Task.run(job) |> ignore
run(job) |> ignore

0
3 changes: 2 additions & 1 deletion Source/FSharp.Example.Observers.Chat.Client/paket.references
Expand Up @@ -5,4 +5,5 @@ Microsoft.Orleans.Core
Microsoft.Orleans.OrleansCodeGenerator
Newtonsoft.Json
System.Collections.Immutable
System.Reflection.Metadata
System.Reflection.Metadata
FSharpx.Extras
8 changes: 7 additions & 1 deletion Source/FSharp.Example.Observers.Chat.Server/App.config
Expand Up @@ -4,4 +4,10 @@
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>

</configuration>
<runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.4.0.0" />
</dependentAssembly>
</assemblyBinding></runtime></configuration>
2 changes: 2 additions & 0 deletions Source/FSharp.Example.Observers.Chat.Server/ChatServer.fs
Expand Up @@ -3,6 +3,8 @@
open System.Linq
open System.Collections.Generic

open FSharpx.Task

open Orleankka
open Orleankka.FSharp
open Messages
Expand Down