Module shards_dist

This module implemnets Sharding but globally (on multiple distributed Erlang nodes).

Description

This module implemnets Sharding but globally (on multiple distributed Erlang nodes).

Example

First of all, we have to run our app in distributed way, setting a node name and maybe a cookie. Let's suppose we spawn a node a@127.0.0.1, and from that node:

   % when a tables is created with {scope, g}, the module
   % shards_dist is used internally by shards
   > shards:new(mytab, [{scope, g}]).
   mytab
  
   % from node `a` (local), join `b` and `c` nodes:
   > shards:join(mytab, ['b@127.0.0.1', 'c@127.0.0.1']).
   ['a@127.0.0.1','b@127.0.0.1','c@127.0.0.1']
  
   % let's check the list of joined nodes:
   > shards:get_nodes(mytab).
   ['a@127.0.0.1','b@127.0.0.1','c@127.0.0.1']

Other option is calling shards:new/3 but passing the option {nodes, Nodes}`, where `Nodes` is the list of nodes you want to join. ``` > Nodes = [b@127.0.0.1', 'c@127.0.0.1']}]. ['b@127.0.0.1','c@127.0.0.1']

> shards:new(mytab, [{scope, g}, {nodes, Nodes}]). mytab '''

Data Types

option()

option() = {nodes, [node()]} | shards_local:option()

rpc_res()

rpc_res(R) = R | {badrpc, Reason::term()}

Function Index

delete/1
delete/3
delete_all_objects/2
delete_object/3
file2tab/1Equivalent to file2tab(Filename, []).
file2tab/2
foldl/4
foldr/4
get_nodes/1
info/2
info/3
insert/3
insert_new/3
join/2
leave/2
lookup/3
lookup_element/4
match/3
match_delete/3
match_object/3
member/3
new/2
rename/3
select/3
select_count/3
select_delete/3
select_reverse/3
tab2file/3Equivalent to tab2file(Tab, Filename, [], State).
tab2file/4
tab2list/2
tabfile_info/1
take/3
update_counter/4
update_counter/5
update_element/4

Function Details

delete/1

delete(Tab::atom()) -> true

delete/3

delete(Tab::atom(), Key::term(), State::shards_state:state()) -> true

delete_all_objects/2

delete_all_objects(Tab::atom(), State::shards_state:state()) -> true

delete_object/3

delete_object(Tab::atom(), Object::tuple(), State::shards_state:state()) -> true

file2tab/1

file2tab(Filename) -> any()

Equivalent to file2tab(Filename, []).

file2tab/2

file2tab(Filename::shards_local:filename(), Options::[Option]) -> {ok, Tab::atom()} | {error, Reason::term()}

foldl/4

foldl(Fun::fun((Element::term(), Acc) -> Acc), Acc::term(), Tab::atom(), State::shards_state:state()) -> Acc

foldr/4

foldr(Fun::fun((Element::term(), Acc) -> Acc), Acc::term(), Tab::atom(), State::shards_state:state()) -> Acc

get_nodes/1

get_nodes(Tab::atom()) -> Nodes::[node()]

info/2

info(Tab::atom(), State::shards_state:state()) -> InfoList | undefined

info/3

info(Tab::atom(), Item::shards_local:info_item() | nodes, State::shards_state:state()) -> any() | undefined

insert/3

insert(Tab::atom(), ObjOrObjs::tuple() | [tuple()], State::shards_state:state()) -> true | no_return()

insert_new/3

insert_new(Tab::atom(), ObjOrObjs::tuple() | [tuple()], State::shards_state:state()) -> boolean()

join/2

join(Tab::atom(), Nodes::[node()]) -> CurrentNodes::[node()]

leave/2

leave(Tab::atom(), Nodes::[node()]) -> CurrentNodes::[node()]

lookup/3

lookup(Tab::atom(), Key::term(), State::shards_state:state()) -> Result::[tuple()]

lookup_element/4

lookup_element(Tab::atom(), Key::term(), Pos::pos_integer(), State::shards_state:state()) -> Elem::term() | [term()]

match/3

match(Tab::atom(), Pattern::ets:match_pattern(), State::shards_state:state()) -> [Match::[term()]]

match_delete/3

match_delete(Tab::atom(), Pattern::ets:match_pattern(), State::shards_state:state()) -> true

match_object/3

match_object(Tab::atom(), Pattern::ets:match_pattern(), State::shards_state:state()) -> [Object::tuple()]

member/3

member(Tab::atom(), Key::term(), State::shards_state:state()) -> boolean()

new/2

new(Name, Options::[option()]) -> Name

rename/3

rename(Tab::atom(), Name, State::shards_state:state()) -> Name | no_return()

select/3

select(Tab::atom(), MatchSpec::ets:match_spec(), State::shards_state:state()) -> [Match::term()]

select_count/3

select_count(Tab::atom(), MatchSpec::ets:match_spec(), State::shards_state:state()) -> NumMatched::non_neg_integer()

select_delete/3

select_delete(Tab::atom(), MatchSpec::ets:match_spec(), State::shards_state:state()) -> NumDeleted::non_neg_integer()

select_reverse/3

select_reverse(Tab::atom(), MatchSpec::ets:match_spec(), State::shards_state:state()) -> [Match::term()]

tab2file/3

tab2file(Tab, Filename, State) -> any()

Equivalent to tab2file(Tab, Filename, [], State).

tab2file/4

tab2file(Tab::atom(), Filename::shards_local:filename(), Options::[Option], State::shards_state:state()) -> ok | {error, Reason::term()}

tab2list/2

tab2list(Tab::atom(), State::shards_state:state()) -> [Object]

tabfile_info/1

tabfile_info(Filename::shards_local:filename()) -> {ok, TableInfo} | {error, Reason::term()}

take/3

take(Tab::atom(), Key::term(), State::shards_state:state()) -> [Object::tuple()]

update_counter/4

update_counter(Tab::atom(), Key::term(), UpdateOp::term(), State::shards_state:state()) -> rpc_res(integer() | [integer()])

update_counter/5

update_counter(Tab::atom(), Key::term(), UpdateOp::term(), Default::tuple(), State::shards_state:state()) -> Result::integer() | [integer()]

update_element/4

update_element(Tab::atom(), Key::term(), ElementSpec::{Pos, Value} | [{Pos, Value}], State::shards_state:state()) -> boolean()


Generated by EDoc