Last active
November 30, 2015 11:01
-
-
Save aprooks/3f9cb68a3f17ac041362 to your computer and use it in GitHub Desktop.
testing orlenakka with f#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Learn more about F# at http://fsharp.org | |
// See the 'F# Tutorial' project for more help. | |
open System | |
open System.Reflection | |
open Orleankka | |
open Orleankka.FSharp | |
open Orleankka.Playground | |
[<Serializable>] | |
type TestContract = | |
| Hello | |
| Test of string | |
[<Serializable>] | |
type TestRecord = { | |
test:string | |
} | |
[<StreamSubscription(Source="sms:tests",Target="@")>] | |
type Test() as this= | |
inherit Actor<string>() | |
do | |
let stream = base.System.StreamOf("sms","tests") | |
stream.Subscribe(this :> Actor).Wait() | |
override this.OnReceive msg = | |
printfn "recieved ffff" | |
base.OnReceive msg | |
override this.Receive message reply = task { | |
printfn "recieved 123" | |
} | |
[<StreamSubscription(Source="sms:tests",Target="@")>] | |
type Test2() = | |
inherit Actor() | |
override this.OnReceive msg = | |
printfn "recieved aaaa" | |
base.OnReceive msg | |
member this.Handle (msg:TestContract) = | |
printfn "handled DU" | |
member this.Handle (msg:TestRecord) = | |
printfn "handled record" | |
member this.Handle (msg:string) = | |
printfn "handled" | |
[<EntryPoint>] | |
let main argv = | |
printfn "Starting" | |
use system = ActorSystem.Configure() | |
.Playground() | |
.UseInMemoryPubSubStore() | |
.TweakClient(fun c -> c.TraceToConsole <- true) | |
.TweakClient(fun c -> c.DefaultTraceLevel <- Orleans.Runtime.Logger.Severity.Info) | |
.TweakCluster(fun c -> c.Defaults.DefaultTraceLevel<- Orleans.Runtime.Logger.Severity.Info) | |
.Register(Assembly.GetExecutingAssembly()) | |
.Done() | |
printfn "Started system" | |
let actor = system.ActorOf<Test> "@" | |
let actor2 = system.ActorOf<Test2> "@" | |
actor2.Tell( "test2").Wait() | |
let stream = system.StreamOf ("sms","tests") | |
stream.Push("test").Wait() | |
stream.Push(Hello).Wait() | |
stream.Push({test="123"}).Wait() | |
Console.ReadLine() |> ignore | |
printfn "%A" argv | |
0 // return an integer exit code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment