View Source Ferryman.Server (FerrymanEx v0.1.0)

This module provides the Server API to start a JSONRPC 2.0 Server instance.

overview

Overview

First, let's define a JSONRPC2 handler, and define the functions we want to be handled by RPC calls.

defmodule ExampleHandler do
  use JSONRPC2.Server.Handler

  def handle_request("add", [x, y]) do
    x + y
  end
end

Now we can start our Ferryman Server.

iex> {:ok, pid} = Ferryman.Server.start_link(redis_config: [], channels: ["mychannel"], handler: ExampleHandler)

The default redis_config will look for a redis instance on "localhost:6379". For more configuration options, please check the Redix Docs.

You can define a list of channels, and pass the handler module.

Link to this section Summary

Functions

Returns a specification to start this module under a supervisor.

Starts a new Ferryman.Server, which takes the following keyword list as arguments

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

put_reply(pid, id, message)

View Source

Specs

start_link(redis_config: keyword(), channels: [String.t()], handler: module()) ::
  :ignore | {:error, any()} | {:ok, pid()}

Starts a new Ferryman.Server, which takes the following keyword list as arguments:

example

Example

iex> Ferryman.Server.start_link(redis_config: [], channels: ["mychannel"], handler: ExampleHandler)
{:ok, pid}