Vagabond


API Overview

The included implementation of ThunkServer is a straightforward distributed implementation that makes use of Vagabond. What follows is a brief overview of the basic API.

A Vagabond environment can be initialized as follows:

1: 
2: 
3: 
open MBrace.Vagabond

let vmanager = Vagabond.Initialize(cacheDirectory = "/tmp/vagabond")

Given an arbitrary object, dependencies are resolved like so:

1: 
2: 
3: 
let value = [ Some(fun x -> printfn "%d" x; x + 1) ; None ; Some id ]

let assemblies = vmanager.ComputeObjectDependencies(value, permitCompilation = true)

An assembly can be exported by generating Vagabond metadata

1: 
let vagabondAssembly = vmanager.GetVagabondAssembly assembly

An assembly package contains necessary data to load the specified assembly in a remote process.

Assemblies can be loaded in a remote process like so:

1: 
let response = vmanager.LoadVagabondAssembly vagabondAssembly

Communication

Once all required dependencies have been loaded, communication can be established by using the .Serializer property found in both the server and client instances. These give an FsPickler serializer instance that is capable of serializing and deserializing objects depending on dynamic assemblies.

1: 
2: 
3: 
let serializer = vmanager.Serializer

let bytes = serializer.Pickle(value)
namespace System
namespace System.Reflection
namespace MBrace
namespace MBrace.Vagabond
val assembly : AssemblyId
module Unchecked

from Microsoft.FSharp.Core.Operators
val defaultof<'T> : 'T
type AssemblyId =
  { FullName: string
    ImageHash: byte []
    Extension: string }
    member GetName : unit -> AssemblyName
    override ToString : unit -> string
val vmanager : VagabondManager
type Vagabond =
  static member ComputeAssemblyDependencies : assemblies:seq<Assembly> * ?isIgnoredAssembly:(Assembly -> bool) * ?policy:AssemblyLookupPolicy -> Assembly []
  static member ComputeAssemblyDependencies : assembly:Assembly * ?isIgnoredAssembly:(Assembly -> bool) * ?policy:AssemblyLookupPolicy -> Assembly []
  static member ComputeAssemblyDependencies : obj:obj * ?isIgnoredAssembly:(Assembly -> bool) * ?policy:AssemblyLookupPolicy -> Assembly []
  static member ComputeAssemblyId : assembly:Assembly -> AssemblyId
  static member ComputeAssemblyIds : assemblies:seq<Assembly> -> AssemblyId []
  static member GetUniqueFileName : id:AssemblyId -> string
  static member GetUniqueFileName : hash:HashResult * ?assemblyPrefix:AssemblyId -> string
  static member Initialize : config:VagabondConfiguration -> VagabondManager
  static member Initialize : ignoredAssemblies:seq<Assembly> * ?cacheDirectory:string * ?profiles:seq<IDynamicAssemblyProfile> * ?typeConverter:ITypeNameConverter * ?forceLocalFSharpCore:bool * ?forceSerializationCompilation:bool * ?lookupPolicy:AssemblyLookupPolicy * ?dataCompressionAlgorithm:ICompressionAlgorithm * ?dataPersistTreshold:int64 -> VagabondManager
  static member Initialize : ?cacheDirectory:string * ?profiles:seq<IDynamicAssemblyProfile> * ?typeConverter:ITypeNameConverter * ?forceLocalFSharpCore:bool * ?forceSerializationCompilation:bool * ?isIgnoredAssembly:(Assembly -> bool) * ?lookupPolicy:AssemblyLookupPolicy * ?dataCompressionAlgorithm:ICompressionAlgorithm * ?dataPersistTreshold:int64 -> VagabondManager
  ...
static member Vagabond.Initialize : config:VagabondConfiguration -> VagabondManager
static member Vagabond.Initialize : ignoredAssemblies:seq<Assembly> * ?cacheDirectory:string * ?profiles:seq<IDynamicAssemblyProfile> * ?typeConverter:MBrace.FsPickler.ITypeNameConverter * ?forceLocalFSharpCore:bool * ?forceSerializationCompilation:bool * ?lookupPolicy:AssemblyLookupPolicy * ?dataCompressionAlgorithm:ICompressionAlgorithm * ?dataPersistTreshold:int64 -> VagabondManager
static member Vagabond.Initialize : ?cacheDirectory:string * ?profiles:seq<IDynamicAssemblyProfile> * ?typeConverter:MBrace.FsPickler.ITypeNameConverter * ?forceLocalFSharpCore:bool * ?forceSerializationCompilation:bool * ?isIgnoredAssembly:(Assembly -> bool) * ?lookupPolicy:AssemblyLookupPolicy * ?dataCompressionAlgorithm:ICompressionAlgorithm * ?dataPersistTreshold:int64 -> VagabondManager
val value : (int -> int) option list
union case Option.Some: Value: 'T -> Option<'T>
val x : int
val printfn : format:Printf.TextWriterFormat<'T> -> 'T
union case Option.None: Option<'T>
val id : x:'T -> 'T
val assemblies : VagabondAssembly []
val vagabondAssembly : VagabondAssembly
val response : AssemblyLoadInfo
val serializer : MBrace.FsPickler.BinarySerializer
val bytes : byte []
Fork me on GitHub