{"id":18881356,"url":"https://github.com/leo-project/leo_ordning_reda","last_synced_at":"2025-04-14T20:10:45.470Z","repository":{"id":3997725,"uuid":"5094923","full_name":"leo-project/leo_ordning_reda","owner":"leo-project","description":"leo_ordning_reda is a library to stack objects and  send stacked objects with async.","archived":false,"fork":false,"pushed_at":"2020-05-31T09:47:54.000Z","size":779,"stargazers_count":6,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2024-04-23T14:10:04.828Z","etag":null,"topics":["erlang","leofs","library"],"latest_commit_sha":null,"homepage":"http://leo-project.net/leofs","language":"Erlang","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leo-project.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-07-18T10:47:48.000Z","updated_at":"2020-05-31T09:46:25.000Z","dependencies_parsed_at":"2022-09-02T23:30:43.120Z","dependency_job_id":null,"html_url":"https://github.com/leo-project/leo_ordning_reda","commit_stats":null,"previous_names":[],"tags_count":62,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leo-project%2Fleo_ordning_reda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leo-project%2Fleo_ordning_reda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leo-project%2Fleo_ordning_reda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leo-project%2Fleo_ordning_reda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leo-project","download_url":"https://codeload.github.com/leo-project/leo_ordning_reda/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223644796,"owners_count":17178765,"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","leofs","library"],"created_at":"2024-11-08T06:48:58.538Z","updated_at":"2024-11-08T06:48:59.143Z","avatar_url":"https://github.com/leo-project.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"leo_ordning_reda\n================\n\n[![Build Status](https://travis-ci.org/leo-project/leo_ordning_reda.svg?branch=develop)](https://travis-ci.org/leo-project/leo_ordning_reda)\n\n**leo_ordning_reda** is a library to handle large objects efficiently.\nWe can easily write programs that automatically stack and compress large objects to pass them other processes.\n\n## Build Information\n\n* \"leo_ordning_reda\" uses the [rebar](https://github.com/rebar/rebar) build system. Makefile so that simply running \"make\" at the top level should work.\n* \"leo_ordning_reda\" requires Erlang R16B03-1 or later.\n\n\n## Usage in Leo Project\n\n**leo_ordning_reda** is used in [**leo_storage**](https://github.com/leo-project/leo_storage).\nIt is used to replicate stored objects between remote data centers efficiently.\n\n## Usage\n\nWe prepare a server program and a client program to use **leo_ordning_reda**.\n\nFirst, a client program is as follow.\n\n```erlang\n-module(leo_ordning_reda_test_client).\n\n-include(\"leo_ordning_reda.hrl\").\n-include_lib(\"eunit/include/eunit.hrl\"). % for debug\n\n-define(BUFSIZE, 100). %% 100B\n-define(TIMEOUT, 100). %% 0.1sec\n\n-export([main/0, output/1]).\n\nmain() -\u003e\n    Node = node(),\n    ok = leo_ordning_reda_api:start(),\n    ok = leo_ordning_reda_test_server:start_link(Node, ?BUFSIZE, ?TIMEOUT),\n    ok = leo_ordning_reda_test_server:stack(Node, \"key1\", lists:seq(1,10)),\n    ok = leo_ordning_reda_test_server:stack(Node, \"key2\", lists:seq(11,20)),\n    ok = leo_ordning_reda_test_server:stack(Node, \"key3\", lists:seq(21,30)),\n    timer:sleep(2000),\n    ok = leo_ordning_reda_test_server:stop(Node),\n    ok = application:stop(leo_ordning_reda),\n    ok.\n\n-spec(output(binary()) -\u003e\n    ok).\noutput(CompressedBin) -\u003e\n    Fun = fun(Obj) -\u003e io:format(\"~p~n\",[Obj]) end,\n    ok = leo_ordning_reda_api:unpack(CompressedBin, Fun).\n```\n\nSecond, a server program is as follow.\nNote that, `handle_send` is called when objects are stacked more than `BufSize` or more than `Timeout` milliseconds passed.\n\n\n```erlang\n-module(leo_ordning_reda_test_server).\n\n-behaviour(leo_ordning_reda_behaviour).\n\n-include(\"leo_ordning_reda.hrl\").\n-include_lib(\"eunit/include/eunit.hrl\"). % for debug\n\n-export([start_link/3, stop/1, stack/3]).\n-export([handle_send/3,\n         handle_fail/2]).\n\n-spec start_link(atom(), integer(), integer()) -\u003e ok | {error, _}.\nstart_link(Node, BufSize, Timeout) -\u003e\n    leo_ordning_reda_api:add_container(Node, [{module,      ?MODULE},\n                                              {buffer_size, BufSize},\n                                              {timeout,     Timeout}]).\n\n-spec stop(atom()) -\u003e ok | {error, _}.\nstop(Node) -\u003e\n    leo_ordning_reda_api:remove_container(Node).\n\n-spec stack(atom(), _, _) -\u003e ok.\nstack(Node, Key, Object) -\u003e\n    {ok, Bin} = leo_ordning_reda_api:pack(Object),\n    ok = leo_ordning_reda_api:stack(Node, Key, Bin),\n    ok.\n\n-spec handle_send(atom(), _, binary()) -\u003e ok.\nhandle_send(Node, StackInfo, CompressedBin) -\u003e\n    ?debugVal({Node, length(StackInfo), byte_size(CompressedBin)}),\n    rpc:call(Node, leo_ordning_reda_test_client, output, [CompressedBin]).\n\n-spec handle_fail(atom(), _) -\u003e ok.\nhandle_fail(Node, StackInfo) -\u003e\n    ?debugVal({Node, length(StackInfo)}),\n    ok.\n```\n\n## License\n\nleo_ordning_reda's license is [Apache License Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html)\n\n## Sponsors\n\n* LeoProject/LeoFS was sponsored by [Rakuten, Inc.](https://global.rakuten.com/corp/) from 2012 to Dec of 2018.\n* LeoProject/LeoFS is sponsored by [Lions Data, Ltd.](https://lions-data.com/) from Jan of 2019.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleo-project%2Fleo_ordning_reda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleo-project%2Fleo_ordning_reda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleo-project%2Fleo_ordning_reda/lists"}