GenServers API

Installation

GenServers.GenServersModule
GenServers

Implements a generic server Actors protocol.

It lets you write an implementation module with a user API for a server and callback functions which are called by the server if certain requests are issued.

It lets you write purely sequential code while the :genserver actor cares about the concurrency and distributed part. This simplifies greatly the development of servers.

The current stable, registered version is installed with

pkg> add GenServers

The development version is installed with:

pkg> add "https://github.com/JuliaActors/GenServers.jl"
source
julia> using GenServers

julia> GenServers.version
v"0.2.0"

Starting a Server

A :genserver actor usually is started with something it should serve, e.g. files, a printer, a dictionary ...

GenServers.genserverFunction
genserver(m::Module, args...; name=nothing, 
    pid=myid(), thrd=false, 
    sticky=false, taskref=nothing)

Create an actor in :genserver mode. It uses the callbacks in a user provided module m when processing messages.

Arguments

  • m::Module: a user provided module in current scope,
  • args...: arguments to the user provided init callback.

Keyword Arguments

  • name=nothing: if a name::Symbol is provided the server is registered and the name is returned,
  • pid=myid(): worker pid to create the actor on,
  • thrd=false: thread to create the actor on,
  • sticky=false: if true, the actor is created in the same thread,
  • taskref=nothing: if a Ref{Task} variable is provided, it gets the created Task.
source