Module shards_group

This module provides a dynamic supervisor for creating and/or deleting tables dynamically in runtime and as part of an existing supervision tree; any application supervision tree using shards.

Description

This module provides a dynamic supervisor for creating and/or deleting tables dynamically in runtime and as part of an existing supervision tree; any application supervision tree using shards.

Usage

To use shards and make the creates tables part of your application supervision tree, you have to add to your main supervisor:

   % Supervisor init callback
   init(GroupName) ->
     Children = [
       shards_group:child_spec(GroupName)
     ],
  
     {ok, {{one_for_one, 10, 10}, Children}}.

After your application starts, you can create and delete tables like so:

   > {ok, Pid, Tab} = shards_group:new_table(GroupName, mytab, [named_table]).
   {ok,<0.194.0>,#Ref<0.3052443831.2753691659.260835>}
  
   > shards_group:del_table(GroupName, mytab).
   ok

Function Index

child_spec/1
del_table/2
new_table/3
start_link/0Equivalent to start_link(shards_group).
start_link/1
stop/1Equivalent to stop(Pid, 5000).
stop/2

Function Details

child_spec/1

child_spec(Name) -> ChildSpec

del_table/2

del_table(SupRef, Tab) -> ok | {error, Reason}

new_table/3

new_table(SupRef, TabName, Options) -> {ok, TabPid, Tab} | {error, Reason}

start_link/0

start_link() -> any()

Equivalent to start_link(shards_group).

start_link/1

start_link(Name) -> StartRet

stop/1

stop(Pid) -> any()

Equivalent to stop(Pid, 5000).

stop/2

stop(SupRef, Timeout) -> ok


Generated by EDoc