Thespian


Thespian [draft]

A distributed actors library based on F# MailboxProcessor.

Thespian can be installed from NuGet:
PM> Install-Package Thespian -Pre

Example

This example demonstrates using a function defined in this sample library.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
open Nessos.Thespian

type Msg = Msg of IReplyChannel<int> * int

let behavior state (Msg (rc,v)) = async {
    printfn "Received %d" v
    rc.Reply <| Value state
    return (state + v)
}

let actor =
    behavior
    |> Behavior.stateful 0 
    |> Actor.bind
    |> Actor.start

let post v = actor.Ref <!= fun ch -> Msg(ch, v)

post 42

Samples & documentation

  • Tutorial contains a further explanation of this sample library.

  • API Reference contains automatically generated documentation for all types, modules and functions in the library. This includes additional brief samples on using most of the functions.

Contributing and copyright

The project is hosted on GitHub where you can report issues, fork the project and submit pull requests. If you're adding new public API, please also consider adding samples that can be turned into a documentation. You might also want to read library design notes to understand how it works.

The library is available under the Apache license. For more information see the License file in the GitHub repository.

namespace Nessos
namespace Nessos.Thespian
Multiple items
union case Msg.Msg: IReplyChannel<int> * int -> Msg

--------------------
type Msg = | Msg of IReplyChannel<int> * int

Full name: Index.Msg
Multiple items
type IReplyChannel =
  interface
    abstract member AsyncReplyUntyped : reply:Reply -> Async<unit>
    abstract member Protocol : string
    abstract member Timeout : int
    abstract member Timeout : int with set
  end

Full name: Nessos.Thespian.IReplyChannel

--------------------
type IReplyChannel<'T> =
  interface
    inherit IReplyChannel
    abstract member AsyncReply : reply:Reply<'T> -> Async<unit>
  end

Full name: Nessos.Thespian.IReplyChannel<_>
Multiple items
val int : value:'T -> int (requires member op_Explicit)

Full name: Microsoft.FSharp.Core.Operators.int

--------------------
type int = int32

Full name: Microsoft.FSharp.Core.int

--------------------
type int<'Measure> = int

Full name: Microsoft.FSharp.Core.int<_>
val behavior : state:int -> Msg -> Async<int>

Full name: Index.behavior
val state : int
val rc : IReplyChannel<int>
val v : int
val async : AsyncBuilder

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.async
val printfn : format:Printf.TextWriterFormat<'T> -> 'T

Full name: Microsoft.FSharp.Core.ExtraTopLevelOperators.printfn
member IReplyChannel.Reply : value:'T -> Async<unit>
union case Reply.Value: 'T -> Reply<'T>
val actor : Actor<Msg>

Full name: Index.actor
module Behavior

from Nessos.Thespian
val stateful : init:'State -> behavior:('State -> 'T -> Async<'State>) -> self:Actor<'T> -> Async<unit>

Full name: Nessos.Thespian.Behavior.stateful
Multiple items
module Actor

from Nessos.Thespian

--------------------
type Actor =
  new : unit -> Actor
  abstract member LogEvent : logLevel:LogLevel * event:'E -> unit
  abstract member Start : unit -> unit
  abstract member Stop : unit -> unit
  abstract member Log : IEvent<Log>
  static member DefaultPrimaryProtocolFactory : IPrimaryProtocolFactory
  static member DefaultPrimaryProtocolFactory : IPrimaryProtocolFactory with set

Full name: Nessos.Thespian.Actor

--------------------
type Actor<'T> =
  inherit Actor
  interface IDisposable
  new : otherActor:Actor<'T> -> Actor<'T>
  new : behavior:(Actor<'T> -> Async<unit>) * ?primaryProtocolFactory:IPrimaryProtocolFactory * ?linkedActors:seq<Actor> -> Actor<'T>
  new : name:string * behavior:(Actor<'T> -> Async<unit>) * ?primaryProtocolFactory:IPrimaryProtocolFactory * ?linkedActors:seq<Actor> -> Actor<'T>
  new : name:string * protocols:IProtocolServer<'T> [] * behavior:(Actor<'T> -> Async<unit>) * ?linkedActors:seq<Actor> -> Actor<'T>
  abstract member Publish : protocolFactories:#seq<'U> -> Actor<'T> (requires 'U :> IProtocolFactory)
  abstract member Publish : protocolServers:IProtocolServer<'T> [] -> Actor<'T>
  abstract member ReBind : (Actor<'T> -> Async<unit>) -> unit
  abstract member Receive : ?timeout:int -> Async<'T>
  ...

Full name: Nessos.Thespian.Actor<_>

--------------------
new : unit -> Actor

--------------------
new : otherActor:Actor<'T> -> Actor<'T>
new : behavior:(Actor<'T> -> Async<unit>) * ?primaryProtocolFactory:IPrimaryProtocolFactory * ?linkedActors:seq<Actor> -> Actor<'T>
new : name:string * protocols:IProtocolServer<'T> [] * behavior:(Actor<'T> -> Async<unit>) * ?linkedActors:seq<Actor> -> Actor<'T>
new : name:string * behavior:(Actor<'T> -> Async<unit>) * ?primaryProtocolFactory:IPrimaryProtocolFactory * ?linkedActors:seq<Actor> -> Actor<'T>
val bind : body:(Actor<'T> -> Async<unit>) -> Actor<'T>

Full name: Nessos.Thespian.Actor.bind
val start : actor:Actor<'T> -> Actor<'T>

Full name: Nessos.Thespian.Actor.start
val post : v:int -> int

Full name: Index.post
property Actor.Ref: ActorRef<Msg>
val ch : IReplyChannel<int>
Fork me on GitHub