7979
8080-export ([
8181 state /1 ,
82- type /1 ,
82+ module /1 ,
83+ tab_type /1 ,
8384 n_shards /1 ,
8485 list /1
8586]).
@@ -992,34 +993,43 @@ pick_one(Key, Nodes) ->
992993-spec state (TabName ) -> State when
993994 TabName :: atom (),
994995 State :: state ().
995- state (TabName ) ->
996- shards_local :state (TabName ).
996+ state (TabName ) -> shards_local :state (TabName ).
997+
998+ % % @doc
999+ % % Returns the module used by the given table.
1000+ % % <ul>
1001+ % % <li>`TabNameOrState': Table name or State.</li>
1002+ % % </ul>
1003+ % % @end
1004+ -spec module (TabNameOrState ) -> Type when
1005+ TabNameOrState :: state () | atom (),
1006+ Type :: shards_local :type ().
1007+ module ({Module , _ , _ }) -> Module ;
1008+ module (TabName ) -> module (state (TabName )).
9971009
9981010% % @doc
9991011% % Returns the table type.
10001012% % <ul>
1001- % % <li>`TabName ': Table name.</li>
1013+ % % <li>`TabNameOrState ': Table name or State .</li>
10021014% % </ul>
10031015% % @end
1004- -spec type (TabName ) -> Type when
1005- TabName :: atom (),
1006- Type :: atom ().
1007- type (TabName ) ->
1008- {_ , Type , _ } = state (TabName ),
1009- Type .
1016+ -spec tab_type (TabNameOrState ) -> Type when
1017+ TabNameOrState :: state () | atom (),
1018+ Type :: shards_local :type ().
1019+ tab_type ({_ , Type , _ }) -> Type ;
1020+ tab_type (TabName ) -> tab_type (state (TabName )).
10101021
10111022% % @doc
10121023% % Returns the number of shards.
10131024% % <ul>
1014- % % <li>`TabName ': Table name.</li>
1025+ % % <li>`TabNameOrState ': Table name or State .</li>
10151026% % </ul>
10161027% % @end
1017- -spec n_shards (TabName ) -> NumShards when
1018- TabName :: atom (),
1019- NumShards :: pos_integer ().
1020- n_shards (TabName ) ->
1021- {_ , _ , NumShards } = state (TabName ),
1022- NumShards .
1028+ -spec n_shards (TabNameOrState ) -> NumShards when
1029+ TabNameOrState :: state () | atom (),
1030+ NumShards :: pos_integer ().
1031+ n_shards ({_ , _ , NumShards }) -> NumShards ;
1032+ n_shards (TabName ) -> n_shards (state (TabName )).
10231033
10241034% % @doc
10251035% % Returns the list of shard names associated to the given `TabName'.
@@ -1031,5 +1041,4 @@ n_shards(TabName) ->
10311041-spec list (TabName ) -> ShardTabNames when
10321042 TabName :: atom (),
10331043 ShardTabNames :: [atom ()].
1034- list (TabName ) ->
1035- shards_local :list (TabName , n_shards (TabName )).
1044+ list (TabName ) -> shards_local :list (TabName , n_shards (TabName )).
0 commit comments