{"id":18881351,"url":"https://github.com/leo-project/leo_tran","last_synced_at":"2026-02-21T02:30:16.988Z","repository":{"id":33493520,"uuid":"37139355","full_name":"leo-project/leo_tran","owner":"leo-project","description":"leo_tran is a library to handle a data-transaction. We can easily write programs that manager a data-transaction to avoid a conflicts and reduce unnecessary requests between nodes.","archived":false,"fork":false,"pushed_at":"2020-05-31T06:18:51.000Z","size":218,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"develop","last_synced_at":"2024-12-31T03:27:28.273Z","etag":null,"topics":["erlang","leofs","library","transaction"],"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/leo-project.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":"2015-06-09T15:06:33.000Z","updated_at":"2020-05-31T06:14:32.000Z","dependencies_parsed_at":"2022-09-12T16:00:20.628Z","dependency_job_id":null,"html_url":"https://github.com/leo-project/leo_tran","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leo-project%2Fleo_tran","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leo-project%2Fleo_tran/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leo-project%2Fleo_tran/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leo-project%2Fleo_tran/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leo-project","download_url":"https://codeload.github.com/leo-project/leo_tran/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239850446,"owners_count":19707348,"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","transaction"],"created_at":"2024-11-08T06:48:50.632Z","updated_at":"2026-02-21T02:30:16.911Z","avatar_url":"https://github.com/leo-project.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"leo_tran\n========\n\n[![Build Status](https://secure.travis-ci.org/leo-project/leo_tran.png?branch=develop)](http://travis-ci.org/leo-project/leo_tran)\n\n**leo_tran** is a library to handle a data-transaction.\nWe can easily write programs that manager a data-transaction to avoid a conflicts.\n\n## Build Information\n\n* \"leo_tran\" uses the [rebar](https://github.com/rebar/rebar) build system. Makefile so that simply running \"make\" at the top level should work.\n* \"leo_tran\" requires Erlang R16B03-1 or later.\n\n\n## Usage in Leo Project\n\n**leo_tran** is used in [**leo_storage**](https://github.com/leo-project/leo_storage) and others.\nIt is used to reduce unnecessary request between remote-nodes.\n\n## Usage\n\nWe prepare a server program and a client program to use **leo_tran**.\n\nFirst, a callback program is as below:\n\n```erlang\n%% Launch leo_tran:\nok = application:start(leo_tran).\nMethod = get,\n{value, {ok, Ret_1}} = leo_tran:run(\u003c\u003c\"TABLE\"\u003e\u003e, \u003c\u003c\"ID\"\u003e\u003e, Method, leo_tran_handler_sample).\n\n%% Able to control a transaction by options:\n%%     - Default timeout: 5000 (ms)\n%%     - Default is_wait_for_tran: true\n%%     - Default is_lock_tran: true\n{value, {ok, Ret_2}} = leo_tran:run(\u003c\u003c\"TABLE\"\u003e\u003e, \u003c\u003c\"ID\"\u003e\u003e, Method, leo_tran_handler_sample,\n                                   [{?PROP_TIMEOUT, timer:seconds(1)},\n                                    {?PROP_IS_WAIT_FOR_TRAN, true},\n                                    {?PROP_IS_LOCK_TRAN, true}\n                                   ]).\n\n%% A Callback Module:\n-module(leo_tran_handler_sample).\n-behaviour(leo_tran_behaviour).\n-include(\"leo_tran.hrl\").\n-include_lib(\"eunit/include/eunit.hrl\").\n\n-export([run/4, wait/4, resume/4,\n         commit/4, rollback/5]).\n\n-define(MIN_DURATION, timer:seconds(1)).\n\n-spec(run(Table::atom(), Key::binary(), Method::atom(), State::#tran_state{}) -\u003e\n             ok | {error, any()}).\nrun(Table, Key, get, State) -\u003e\n    ?debugFmt(\"GET: ~w, ~p, ~w\",\n              [Table, Key, State#tran_state.started_at]),\n    ok;\nrun(Table, Key, put, State) -\u003e\n    ?debugFmt(\"PUT: ~w, ~p, ~w\",\n              [Table, Key, State#tran_state.started_at]),\n    ok;\nrun(Table, Key, delete, State) -\u003e\n    ?debugFmt(\"DELETE: ~w, ~p, ~w\",\n              [Table, Key, State#tran_state.started_at]),\n    ok;\nrun(_,_,_,_) -\u003e\n    ok.\n\n\n-spec(wait(Table::atom(), Key::binary(), Method::atom(), State::#tran_state{}) -\u003e\n             ok | {error, any()}).\nwait(Table, Key, Method, State) -\u003e\n    ?debugFmt(\"* WAIT: ~w, ~p, ~w, ~w\",\n              [Table, Key, Method, State#tran_state.started_at]),\n    ok.\n\n\n-spec(resume(Table::atom(), Key::binary(), Method::atom(), State::#tran_state{}) -\u003e\n             ok | {error, any()}).\nresume(Table, Key, Method,_State) -\u003e\n    ?debugFmt(\"=\u003e RESUME: ~w, ~p, ~w\", [Table, Key, Method]),\n    ok.\n\n\n-spec(commit(Table::atom(), Key::binary(), Method::atom(), State::#tran_state{}) -\u003e\n             ok | {error, any()}).\ncommit(Table, Key, Method,_State) -\u003e\n    ?debugFmt(\"===\u003e COMMIT: ~w, ~p, ~w\", [Table, Key, Method]),\n    ok.\n\n\n-spec(rollback(Table::atom(), Key::binary(), Method::atom(),\n               Reason::any(), State::#tran_state{}) -\u003e\n             ok | {error, any()}).\nrollback(Table, Key, Method, Reason,_State) -\u003e\n    ?debugFmt(\"===\u003e ROLLBACK: ~w, ~p, ~w, ~p\", [Table, Key, Method, Reason]),\n    ok.\n```\n\n\n## License\n\nleo_tran's license is [Apache License Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleo-project%2Fleo_tran","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleo-project%2Fleo_tran","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleo-project%2Fleo_tran/lists"}