{"id":16389582,"url":"https://github.com/macpie/elb","last_synced_at":"2025-09-12T02:11:27.488Z","repository":{"id":57494097,"uuid":"107468328","full_name":"macpie/elb","owner":"macpie","description":"Erlang Load Balancer","archived":false,"fork":false,"pushed_at":"2018-05-18T20:02:45.000Z","size":25,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2024-09-20T13:38:48.693Z","etag":null,"topics":["erlang","erlang-library","load-balancer","round-robin"],"latest_commit_sha":null,"homepage":null,"language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/macpie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-18T22:07:29.000Z","updated_at":"2023-04-12T12:20:36.000Z","dependencies_parsed_at":"2022-09-02T00:42:31.848Z","dependency_job_id":null,"html_url":"https://github.com/macpie/elb","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macpie%2Felb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macpie%2Felb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macpie%2Felb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/macpie%2Felb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/macpie","download_url":"https://codeload.github.com/macpie/elb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219862888,"owners_count":16555951,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["erlang","erlang-library","load-balancer","round-robin"],"created_at":"2024-10-11T04:33:42.457Z","updated_at":"2024-10-11T04:33:43.064Z","avatar_url":"https://github.com/macpie.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Erlang Load Balancer\n\n[![Build Status](https://travis-ci.org/macpie/elb.svg?branch=master)](https://travis-ci.org/macpie/elb)\n[![Hex.pm](https://img.shields.io/hexpm/l/elb.svg?label=License)](https://github.com/macpie/elb/blob/master/LICENSE) /\n[![Hex.pm](https://img.shields.io/hexpm/v/elb.svg)](https://hex.pm/packages/elb)\n[![Hex.pm](https://img.shields.io/hexpm/dt/elb.svg?label=Downloads)](https://hex.pm/packages/elb) /\n[![Website](https://img.shields.io/website-Up-Down-brightgreen-red/http/shields.io.svg?label=EDoc)](https://macpie.github.io/elb/)\n\nSimple message load balancer using round robin style.\n\n## Usage\n\nStart using `elb:start(Options)` or `elb:start_link(Options)`\n\n### Options\n\n```Erlang\n[\n    {'worker', {Module, Function}} % Or {worker, Module}. Default to start_link function\n    ,{'worker_args', []} % Arguments to pass to worker. Default to []\n    ,{'size', 10} % Number of worker to start. Default to 0\n    ,{'restart', true} % Auto restart dead worker. Default to false\n]\n```\n\n## Examples\n\n### Simple Subscribe\n\n```Erlang\n1\u003e l(elb).\n{module,elb}\n\n2\u003e {'ok', P} = elb:start_link([{'size', 0}]).\n{ok,\u003c0.666.0\u003e}\n\n3\u003e elb:subscribe(P).\nok\n\n4\u003e elb:cast(P, 'test').\nok\n\n5\u003e flush().\nShell got test\nok\n```\n\n### Simple Gen Server\n\n```Erlang\n{'ok',ELB} = elb:start([\n    {'worker', {'worker_test', 'start_link'}}\n    ,{'worker_args', []}\n    ,{'size', 10}\n    ,{'restart', 'true'}\n]),\n\n'ok' = elb:cast(ELB, \"ASYNC Message\"),\n'ok' = elb:broadcast(ELB, \"Broadcast Message to all workers\"),\n\"Sync Message\" = elb:call(ELB, \"Sync Message\"),\n```\n\n```Erlang\n-module(worker_test).\n\n%% ------------------------------------------------------------------\n%% API Function Exports\n%% ------------------------------------------------------------------\n-export([\n    start_link/0, start_link/1\n]).\n\n%% ------------------------------------------------------------------\n%% gen_server Function Exports\n%% ------------------------------------------------------------------\n-export([\n    init/1\n    ,handle_call/3\n    ,handle_cast/2\n    ,handle_info/2\n    ,terminate/2\n    ,code_change/3\n]).\n\n-define(SERVER, ?MODULE).\n\n-record(state, {}).\n\n%% ------------------------------------------------------------------\n%% API Function Definitions\n%% ------------------------------------------------------------------\nstart_link() -\u003e\n    start_link([]).\n\nstart_link(Args) -\u003e\n    gen_server:start_link(?SERVER, Args, []).\n\n%% ------------------------------------------------------------------\n%% gen_server Function Definitions\n%% ------------------------------------------------------------------\ninit(_Args) -\u003e\n    {'ok', #state{}}.\n\nhandle_call(_Msg, _From, State) -\u003e\n    {'reply', 'ok', State}.\n\nhandle_cast(_Msg, State) -\u003e\n    {'noreply', State}.\n\nhandle_info({Message, From}, State) -\u003e\n    elb:reply(From, Message),\n    {'noreply', State};\nhandle_info(_Msg, State) -\u003e\n    {'noreply', State}.\n\ncode_change(_OldVsn, State, _Extra) -\u003e\n    {'ok', State}.\n\nterminate(_Reason, _State) -\u003e\n    'ok'.\n\n%% ------------------------------------------------------------------\n%% Internal Function Definitions\n%% ------------------------------------------------------------------\n\n```\n\n## Build\n\n[Rebar3](http://www.rebar3.org)\n\n## Test\n\n`rebar3 ct -v`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmacpie%2Felb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmacpie%2Felb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmacpie%2Felb/lists"}