Code Monkey home page Code Monkey logo

fuse-lb's Introduction

Fuse-LB

Simple Erlang application for load balancing requests to a pool of resources. Handling retries in case of failures.

Building

Dependencies

Requires rebar in your path.

Building Fuse-LB

$ make

Running unit tests

$ make eunit

Example

> Probe = fun(X) -> {available, X} end.
#Fun<erl_eval.6.82930912>
> {ok, Lb} = fuse_lb:start_link([{user_data1, [3000], Probe},
                                 {user_data2, [3000], Probe},
                                 {user_data3, [3000], Probe}],
                                 round_robin).
{ok,<0.322.0>}
> fuse_lb:call(Lb, fun(Data) -> {available, Data} end).
{ok,user_data1}
> fuse_lb:call(Lb, fun(Data) -> {available, Data} end).
{ok,user_data2}
> fuse_lb:call(Lb, fun(Data) -> {available, Data} end).
{ok,user_data3}
> fuse_lb:call(Lb, fun(Data) -> {available, Data} end).
{ok,user_data1}
> fuse_lb:call(Lb, fun(Data) -> {available, Data} end).
{ok,user_data2}
> fuse_lb:call(Lb, fun(Data) -> {available, Data} end).
{ok,user_data3}
> fuse_lb:call(Lb, fun(Data) -> {unavailable, Data} end).  %% Make fuse 1 unavailable.
{ok,user_data1}
> fuse_lb:call(Lb, fun(Data) -> {available, Data} end).
{ok,user_data2}
> fuse_lb:call(Lb, fun(Data) -> {available, Data} end).
{ok,user_data3}
> fuse_lb:call(Lb, fun(Data) -> {available, Data} end).
{ok,user_data2}
>
> %% Wait 3s.
>
> fuse_lb:call(Lb, fun(Data) -> {available, Data} end).
{ok,user_data3}
> fuse_lb:call(Lb, fun(Data) -> {available, Data} end).
{ok,user_data1}
> fuse_lb:call(Lb, fun(Data) -> {available, Data} end).
{ok,user_data2}
> fuse_lb:call(Lb, fun(Data) -> {available, Data} end).
{ok,user_data3}

Fuse-LB: Copyright (c) 2014 Ulf Leopold.

fuse-lb's People

Contributors

ulfl avatar

Watchers

Daniel Abrahamsson avatar James Cloos 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.