Coder Social home page Coder Social logo

redgrid's Introduction

About

Redgrid performs automatic Erlang node discovery through a shared Redis pub/sub channel.

Build

$ make

Run

Start Redgrid with no arguments

$ erl -pa ebin deps/*/ebin
1> redgrid:start_link().
{ok,<0.33.0>}
2> whereis(redgrid).
<0.33.0>

Start Redgrid with custom Redis url

$ erl -pa ebin deps/*/ebin
1> redgrid:start_link([{redis_url, "redis://localhost:6379/"}]).
{ok,<0.33.0>}

Start Redgrid as a non-registered (anonymous) process

$ erl -pa ebin deps/*/ebin
1> redgrid:start_link([anonymous]).
{ok,<0.33.0>}

Start with arbitrary meta data

$ erl -pa ebin deps/*/ebin
1> redgrid:start_link([{<<"foo">>, <<"bar">>}]).
{ok,<0.33.0>}

Example

TAB 1

Start foo node

$ erl -pa ebin deps/*/ebin -name foo@`hostname`
([email protected])1> redgrid:start_link().
{ok,<0.39.0>}

TAB 2

Start bar node

$ erl -pa ebin deps/*/ebin -name bar@`hostname`
([email protected])1> redgrid:start_link().
{ok,<0.39.0>}

View registered nodes

([email protected])2> redgrid:nodes().
[{'[email protected]',[<<"ip">>, <<"localhost">>]},
 {'[email protected]',[{<<"ip">>, <<"localhost">>}]}]
([email protected])3> [node()|nodes()].
['[email protected]', '[email protected]']

Update meta data for bar node

([email protected])4> redgrid:update_meta([{weight, 50}]).
ok

TAB 1

View registered nodes (including updated meta data for bar)

([email protected])2> redgrid:nodes().
[{'[email protected]',[<<"ip">>, <<"localhost">>]},
 {'[email protected]',[{<<"ip">>,<<"localhost">>},
                                            {<<"weight">>, <<"50">>}]}]

Diagram

This diagram demonstrates what's happening underneath the covers when the foo node joins a cluster comprised of a single node (bar).

Redgrid

ENV VARS

LOCAL_IP: The IP written to Redis to which other nodes will attempt to connect
DOMAIN: Used to build Redis key and channel names
VERSION: Used to build Redis key and channel names

redgrid's People

Contributors

jkvor avatar

Watchers

James Cloos 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.