Skip to content

Instantly share code, notes, and snippets.

@yosukehara
Last active December 26, 2015 02:29
Show Gist options
  • Save yosukehara/7078664 to your computer and use it in GitHub Desktop.
Save yosukehara/7078664 to your computer and use it in GitHub Desktop.
Embedding leofs(leo-gateway) in an application
%% Embedding leo-gateway in an application
%%
ok = leofs:start(),
not_found = leofs:get(<<"key/1">>),
{ok, ETag} = leofs:put(<<"key/1">>, <<"value_1">>),
{ok, {ETag, Bin}} = leofs:get(<<"key/1">>),
ok = leofs:delete(<<"key/1">>),
not_found = leofs:get(<<"key/1">>),
ok = leofs:stop().
@yosukehara
Copy link
Author

rebar.config

  • You could add leo_gateway in the deps as the follows:
{require_otp_vsn, "R15B03|R16B02"}.
{deps, [
        {leo_gateway, ".*", {git, "https://github.com/leo-project/leo_gateway.git", {branch, "develop"}}}
        %% {leo_gateway, ".*", {git, "https://github.com/leo-project/leo_gateway.git", {tag, "0.16.0"}}}
       ]}.

configuration

  • You could modify parts of "leo_gateway/ebin/ leo_gateway.app" as the follows:
  {env, [

         %% Gateway Properties:
         {http, [
                 %% http-handler:
                 %%   [rest | s3 | embed]
                 {handler, embed},  %% To embed
                 ... 
                ]},

         %% Manager - leo-manager's nodes
         {managers, ["manager_0@127.0.0.1", "manager_1@127.0.0.1"] },
         ... 

launch

  • Start Managers and Storage(s)
$ leo_manager_0/bin/leo_manager start
$ leo_manager_1/bin/leo_manager start
$ leo_storage/bin/leo_storage start
  • Building a storage-cluster by leofs-manager's console
$ telnet 127.0.0.1 10010
> start
  • You could set cookie which is same as LeoFS and set -name property because an application communicates with _leo-storage(s)_ over _Erlang-RPC_.
$ erl -setcookie 401321b4 -name embed_gateway@127.0.0.1 -pa ebin deps/*/ebin

> leofs:start().
> application:start( ${YOUR-APPLICATION} ).


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment