Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Final cleanup.

  • Loading branch information...
commit e544dd9fc19f0efe1e82019af45157a80dd315cb 1 parent f14fb2e
@Licenser Licenser authored
View
29 apps/snarl/src/snarl_group.erl
@@ -25,18 +25,32 @@ ping() ->
[{IndexNode, _Type}] = PrefList,
riak_core_vnode_master:sync_spawn_command(IndexNode, ping, snarl_group_vnode_master).
+
+-spec get(Group::fifo:group_id()) ->
+ {ok, fifo:group()} |
+ not_found |
+ {error, timeout}.
get(Group) ->
snarl_entity_read_fsm:start(
{snarl_group_vnode, snarl_group},
get, Group
).
+-spec list() -> {ok, [fifo:group_id()]} |
+ not_found |
+ {error, timeout}.
+
list() ->
snarl_entity_coverage_fsm:start(
{snarl_group_vnode, snarl_group},
list
).
+-spec add(Group::fifo:group_id()) ->
+ ok |
+ douplicate |
+ {error, timeout}.
+
add(Group) ->
case snarl_group:get(Group) of
{ok, not_found} ->
@@ -45,12 +59,27 @@ add(Group) ->
duplicate
end.
+-spec delete(Group::fifo:group_id()) ->
+ ok |
+ not_found|
+ {error, timeout}.
+
delete(Group) ->
do_update(Group, delete).
+-spec grant(Group::fifo:group_id(), fifo:permission()) ->
+ ok |
+ not_found|
+ {error, timeout}.
+
grant(Group, Permission) ->
do_update(Group, grant, Permission).
+-spec revoke(Group::fifo:group_id(), fifo:permission()) ->
+ ok |
+ not_found|
+ {error, timeout}.
+
revoke(Group, Permission) ->
do_update(Group, revoke, Permission).
View
6 apps/snarl/src/snarl_user_state.erl
@@ -84,7 +84,7 @@ free_resource(Resource, ID, User) ->
Resources0 = User#user.resources,
{_, R0, Resources1} = lists:keytake(Resource, 2, Resources0),
R1 = R0#resource{claims = lists:keydelete(ID, 2, R0#resource.claims)},
- User#user{resources = ordsets:add_element(R1, Resources1)}.
+ User#user{resources = ordsets:add_element(R1, Resources1)}.
add(User, Users) ->
ordsets:add_element(User, Users).
@@ -107,10 +107,10 @@ get_resource_stat(User) ->
Reserved}
end, User#user.resources).
-get_resource(Resource, User) ->
+get_resource(Resource, User) ->
lists:keyfind(Resource, 2, User#user.resources).
-get_free_resource(Resource, User) ->
+get_free_resource(Resource, User) ->
R = lists:keyfind(Resource, 2, User#user.resources),
Used = lists:foldl(fun(#resource_claim{ammount=In}, Acc) ->
Acc + In
View
16 apps/snarl/src/snarl_zmq_handler.erl
@@ -13,6 +13,8 @@ init([]) ->
%%% User Functions
%%%===================================================================
+-spec message(fifo:smarl_message(), term()) -> any().
+
message({user, list}, State) ->
{reply, snarl_user:list(), State};
@@ -114,19 +116,21 @@ message({group, list}, State) ->
{reply, snarl_group:list(), State};
message({group, get, Group}, State) ->
- {reply, snarl_group:get(ensure_binary(Group)), State};
+ {reply, snarl_group:get(Group), State};
message({group, add, Group}, State) ->
- {reply, snarl_group:add(ensure_binary(Group)), State};
+ {reply, snarl_group:add(Group), State};
message({group, delete, Group}, State) ->
- {reply, snarl_group:delete(ensure_binary(Group)), State};
+ {reply, snarl_group:delete(Group), State};
-message({group, grant, Group, Permission}, State) ->
- {reply, snarl_group:grant(ensure_binary(Group), Permission), State};
+message({group, grant, Group, Permission}, State) when
+ is_binary(Group),
+ is_list(Permission)->
+ {reply, snarl_group:grant(Group, Permission), State};
message({group, revoke, Group, Permission}, State) ->
- {reply, snarl_group:revoke(ensure_binary(Group), Permission), State};
+ {reply, snarl_group:revoke(Group, Permission), State};
message(Message, State) ->
io:format("Unsuppored 0MQ message: ~p", [Message]),
View
2  dialyzer.mittigate
@@ -89,3 +89,5 @@
^snarl_group_vnode.erl:2: Callback info about the riak_core_vnode behaviour is not available$
^snarl_token_vnode.erl:2: Callback info about the riak_core_vnode behaviour is not available$
^snarl_user_vnode.erl:2: Callback info about the riak_core_vnode behaviour is not available$
+^snarl_zmq_handler.erl:127: Matching of pattern
+^snarl_zmq_handler.erl:132: Matching of pattern
View
20 rebar.config
@@ -4,17 +4,11 @@
{erl_opts, [debug_info, warnings_as_errors, {parse_transform, lager_transform}]}.
{edoc_opts, [{dir, "../../doc"}]}.
{eunit_opts, [{report,{eunit_surefire,[{dir,"."}]}}]}.
-{deps, [{riak_core, "1.2.*",
- {git, "git://github.com/basho/riak_core", {tag, "1.2.1"}}},
- {fifo_spec, ".*", {git, "https://github.com/project-fifo/fifo_spec.git", {branch, master}}},
- {eleveldb, "1.2.*",
- {git, "https://github.com/basho/eleveldb.git", {tag, "1.2.2p5"}}},
- {libsnarlmatch, ".*",
- {git, "https://github.com/project-fifo/libsnarlmatch.git", {branch, master}}},
- {mdns_server_lib, ".*",
- {git, "https://github.com/Licenser/mdns_server_lib.git", {branch, master}}},
- {uuid, ".*",
- {git, "https://github.com/avtobiff/erlang-uuid.git", {tag, "0.2.1"}}},
- {statebox, ".*",
- {git, "https://github.com/unisontech/statebox.git", {branch, master}}}
+{deps, [{riak_core, "1.2.*", {git, "git://github.com/basho/riak_core", {tag, "1.2.1"}}},
+ {eleveldb, "1.2.*", {git, "https://github.com/basho/eleveldb.git", {tag, "1.2.2p5"}}},
+ {mdns_server_lib, ".*", {git, "https://github.com/Licenser/mdns_server_lib.git", {branch, master}}},
+ {uuid, ".*", {git, "https://github.com/avtobiff/erlang-uuid.git", {tag, "0.2.1"}}},
+ {statebox, ".*", {git, "https://github.com/unisontech/statebox.git", {branch, master}}},
+ {fifo_spec, ".*", {git, "https://github.com/project-fifo/fifo_spec.git", {branch, test}}},
+ {libsnarlmatch, ".*", {git, "https://github.com/project-fifo/libsnarlmatch.git", {branch, test}}}
]}.
Please sign in to comment.
Something went wrong with that request. Please try again.