Giter Site home page Giter Site logo

ferryman's Introduction

Ferryman

This is RPC realisation for ruby and erlang. It uses redis and JSON-RPC prothocol. It uses redis pub/sub to send reqests and redis list for responses

It supports only JSON-RPC 2.0 version

You should remember that all data serialized to json, so all symbols and atoms become strings and binary.

##Ruby

###Server

class RemoteProcedures
  def add(a, b)
    a + b
  end
end
server = Ferryman::Server.new(Redis.new, "channel")
server.receive(RemoteProcedures.new)

You can pass more than one channel.

###Client

timeout = 1.second
client = Ferryman::Client.new(Redis.new, "channel", timeout)
client.call(:sum, 1, 2) #3 or Ferryman::Client::NoSubscription exception
client.multicall(:sum, 1, 2) #[3] or []
client.cast(:sum, 1, 2) #1 - amount of subscribers

##Erlang

###Server

handler(<<"add">>, [A, B]) -> A + B;
handler(_, _) -> throw(method_not_found).

ferryman_server:start_link("127.0.0.1", 6379, 0, ["channel"], fun handler/2),

###Client

{ok, Redis} = eredis:start_link(),
ferryman_client:call(Redis, "channel", add, [1,2]), %3
ferryman_client:call(Redis, "channel", no_method, []). %{error, -32601, <<"Method not found.">>}

See more examples in tests

ferryman's People

Contributors

alexpetrov avatar dzjuck avatar hawk73 avatar netdalek avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.