Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions dialyzer.ignore-warnings
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ riak_kv_vnode.erl:1886: Function delete_from_hashtree/3 has no local return
riak_kv_vnode.erl:1890: The call riak_kv_index_hashtree:async_delete(Items::[{'object',{_,_}},...],Trees::'undefined' | pid()) breaks the contract ({binary(),binary()} | [{binary(),binary()}],pid()) -> 'ok'
riak_kv_vnode.erl:1893: The call riak_kv_index_hashtree:delete(Items::[{'object',{_,_}},...],Trees::'undefined' | pid()) breaks the contract ([{binary(),binary()}],pid()) -> 'ok'
riak_kv_vnode.erl:2029: Function update_index_delete_stats/1 will never be called
riak_kv_wm_counter.erl:186: The call riak_core_security:check_permission({[46 | 95 | 97 | 101 | 103 | 105 | 107 | 112 | 114 | 116 | 117 | 118,...],{<<_:56>>,_}},Security::any()) breaks the contract (Permission::permission(),Context::context()) -> {'true',context()} | {'false',binary(),context()}
riak_kv_wm_counter.erl:184: The call riak_core_security:check_permission({[46 | 95 | 97 | 101 | 103 | 105 | 107 | 112 | 114 | 116 | 117 | 118,...],{<<_:56>>,_}},Security::any()) breaks the contract (Permission::permission(),Context::context()) -> {'true',context()} | {'false',binary(),context()}
riak_kv_wm_crdt.erl:387: Function produce_json/2 has no local return
riak_kv_wm_crdt.erl:391: The call riak_kv_crdt_json:fetch_response_to_json(Type::'counter' | 'flag' | 'map' | 'register' | 'set' | 'undefined',Value::any(),'undefined' | binary(),[{'counter','riak_dt_pncounter'} | {'flag','riak_dt_od_flag'} | {'map','riak_dt_map'} | {'register','riak_dt_lwwreg'} | {'set','riak_dt_orswot'},...]) does not have an opaque term of type riak_kv_crdt_json:context() as 3rd argument
riak_kv_wm_index.erl:135: The call riak_core_security:check_permission({[46 | 95 | 97 | 100 | 101 | 105 | 107 | 110 | 114 | 118 | 120,...],{<<_:56>>,binary()}},any()) breaks the contract (Permission::permission(),Context::context()) -> {'true',context()} | {'false',binary(),context()}
riak_kv_wm_index.erl:214: Guard test is_integer(NormStart::'undefined' | binary()) can never succeed
riak_kv_wm_keylist.erl:137: The call riak_core_security:check_permission({[46 | 95 | 97 | 101 | 105 | 107 | 108 | 114 | 115 | 116 | 118 | 121,...],{<<_:56>>,_}},any()) breaks the contract (Permission::permission(),Context::context()) -> {'true',context()} | {'false',binary(),context()}
riak_kv_wm_utils.erl:283: The pattern {Scheme, _, Host, Port, _, _} can never match the type {'error','no_scheme' | {_,atom(),_}}
riak_kv_wm_keylist.erl:135: The call riak_core_security:check_permission({[46 | 95 | 97 | 101 | 105 | 107 | 108 | 114 | 115 | 116 | 118 | 121,...],{<<_:56>>,_}},any()) breaks the contract (Permission::permission(),Context::context()) -> {'true',context()} | {'false',binary(),context()}
riak_kv_wm_utils.erl:288: The pattern {Scheme, _, Host, Port, _, _} can never match the type {'error','no_scheme' | {_,atom(),_}}
cluster_info:dump_all_connected/1
cluster_info:dump_nodes/2
cluster_info:format/3
Expand Down Expand Up @@ -103,4 +103,3 @@ Unknown types:
riak_core_apl:preflist2/0
riak_dt:operation/0
riak_dt:value/0
wrq:reqdata/0
44 changes: 23 additions & 21 deletions src/riak_kv_wm_bucket_type.erl
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
accept_bucket_type_body/2
]).

%% @type context() = term()
-record(ctx, {bucket_type, %% binary() - Bucket type (from uri)
client, %% riak_client() - the store client
prefix, %% string() - prefix for resource uris
Expand All @@ -71,11 +70,12 @@
api_version, %% non_neg_integer() - old or new http api
security %% security context
}).
-type context() :: #ctx{}.

-include_lib("webmachine/include/webmachine.hrl").
-include("riak_kv_wm_raw.hrl").

%% @spec init(proplist()) -> {ok, context()}
-spec init(proplists:proplist()) -> {ok, context()}.
%% @doc Initialize this resource. This function extracts the
%% 'prefix' and 'riak' properties from the dispatch args.
init(Props) ->
Expand All @@ -86,8 +86,8 @@ init(Props) ->
bucket_type=proplists:get_value(bucket_type, Props)
}}.

%% @spec service_available(reqdata(), context()) ->
%% {boolean(), reqdata(), context()}
-spec service_available(#wm_reqdata{}, context()) ->
{boolean(), #wm_reqdata{}, context()}.
%% @doc Determine whether or not a connection to Riak can be
%% established. This function also takes this opportunity to extract
%% the 'bucket' bindings from the dispatch.
Expand Down Expand Up @@ -163,15 +163,15 @@ forbidden_check_bucket_type(RD, Ctx) ->
{false, RD, Ctx}.


%% @spec allowed_methods(reqdata(), context()) ->
%% {[method()], reqdata(), context()}
-spec allowed_methods(#wm_reqdata{}, context()) ->
{[atom()], #wm_reqdata{}, context()}.
%% @doc Get the list of methods this resource supports.
%% Properties allows HEAD, GET, and PUT.
allowed_methods(RD, Ctx) when Ctx#ctx.api_version =:= 3 ->
{['HEAD', 'GET', 'PUT'], RD, Ctx}.

%% @spec malformed_request(reqdata(), context()) ->
%% {boolean(), reqdata(), context()}
-spec malformed_request(#wm_reqdata{}, context()) ->
{boolean(), #wm_reqdata{}, context()}.
%% @doc Determine whether query parameters, request headers,
%% and request body are badly-formed.
%% Body format is checked to be valid JSON, including
Expand All @@ -181,8 +181,8 @@ malformed_request(RD, Ctx) when Ctx#ctx.method =:= 'PUT' ->
malformed_request(RD, Ctx) ->
{false, RD, Ctx}.

%% @spec malformed_bucket_put(reqdata(), context()) ->
%% {boolean(), reqdata(), context()}
-spec malformed_props(#wm_reqdata{}, context()) ->
{boolean(), #wm_reqdata{}, context()}.
%% @doc Check the JSON format of a bucket-level PUT.
%% Must be a valid JSON object, containing a "props" object.
malformed_props(RD, Ctx) ->
Expand All @@ -198,9 +198,9 @@ malformed_props(RD, Ctx) ->
{true, props_format_message(RD), Ctx}
end.

%% @spec bucket_format_message(reqdata()) -> reqdata()
-spec props_format_message(#wm_reqdata{}) -> #wm_reqdata{}.
%% @doc Put an error about the format of the bucket-PUT body
%% in the response body of the reqdata().
%% in the response body of the #wm_reqdata{}.
props_format_message(RD) ->
wrq:append_to_resp_body(
["bucket type PUT must be a JSON object of the form:\n",
Expand All @@ -211,29 +211,30 @@ props_format_message(RD) ->
resource_exists(RD, Ctx) ->
{riak_kv_wm_utils:bucket_type_exists(Ctx#ctx.bucket_type), RD, Ctx}.

%% @spec content_types_provided(reqdata(), context()) ->
%% {[{ContentType::string(), Producer::atom()}], reqdata(), context()}
-spec content_types_provided(#wm_reqdata{}, context()) ->
{[{ContentType::string(), Producer::atom()}], #wm_reqdata{}, context()}.
%% @doc List the content types available for representing this resource.
%% "application/json" is the content-type for props requests.
content_types_provided(RD, Ctx) ->
{[{"application/json", produce_bucket_type_body}], RD, Ctx}.

%% @spec encodings_provided(reqdata(), context()) ->
%% {[{Encoding::string(), Producer::function()}], reqdata(), context()}
-spec encodings_provided(#wm_reqdata{}, context()) ->
{[{Encoding::string(), Producer::function()}], #wm_reqdata{}, context()}.
%% @doc List the encodings available for representing this resource.
%% "identity" and "gzip" are available for props requests.
encodings_provided(RD, Ctx) ->
{riak_kv_wm_utils:default_encodings(), RD, Ctx}.

%% @spec content_types_accepted(reqdata(), context()) ->
%% {[{ContentType::string(), Acceptor::atom()}],
%% reqdata(), context()}
-spec content_types_accepted(#wm_reqdata{}, context()) ->
{[{ContentType::string(), Acceptor::atom()}],
#wm_reqdata{}, context()}.
%% @doc Get the list of content types this resource will accept.
%% "application/json" is the only type accepted for props PUT.
content_types_accepted(RD, Ctx) ->
{[{"application/json", accept_bucket_type_body}], RD, Ctx}.

%% @spec produce_bucket_body(reqdata(), context()) -> {binary(), reqdata(), context()}
-spec produce_bucket_type_body(#wm_reqdata{}, context()) ->
{binary(), #wm_reqdata{}, context()}.
%% @doc Produce the bucket properties as JSON.
produce_bucket_type_body(RD, Ctx) ->
Props = riak_core_bucket_type:get(Ctx#ctx.bucket_type),
Expand All @@ -245,7 +246,8 @@ produce_bucket_type_body(RD, Ctx) ->
]}),
{JsonProps, RD, Ctx}.

%% @spec accept_bucket_body(reqdata(), context()) -> {true, reqdata(), context()}
-spec accept_bucket_type_body(#wm_reqdata{}, context()) ->
{true, #wm_reqdata{}, context()}.
%% @doc Modify the bucket properties according to the body of the
%% bucket-level PUT request.
accept_bucket_type_body(RD, Ctx=#ctx{bucket_type=T, bucketprops=Props}) ->
Expand Down
23 changes: 12 additions & 11 deletions src/riak_kv_wm_buckets.erl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
malformed_request/2
]).

%% @type context() = term()
-record(ctx, {
bucket_type, %% binary() - bucket type (from uri)
api_version, %% integer() - Determine which version of the API to use.
Expand All @@ -60,13 +59,14 @@
timeout, %% integer() - list buckets timeout
security %% security context
}).
-type context() :: #ctx{}.

-include_lib("webmachine/include/webmachine.hrl").
-include("riak_kv_wm_raw.hrl").

-define(DEFAULT_TIMEOUT, 5 * 60000).

%% @spec init(proplist()) -> {ok, context()}
-spec init(proplists:proplist()) -> {ok, context()}.
%% @doc Initialize this resource. This function extracts the
%% 'prefix' and 'riak' properties from the dispatch args.
init(Props) ->
Expand All @@ -78,8 +78,8 @@ init(Props) ->
}}.


%% @spec service_available(reqdata(), context()) ->
%% {boolean(), reqdata(), context()}
-spec service_available(#wm_reqdata{}, context()) ->
{boolean(), #wm_reqdata{}, context()}.
%% @doc Determine whether or not a connection to Riak
%% can be established. This function also takes this
%% opportunity to extract the 'bucket' and 'key' path
Expand Down Expand Up @@ -137,16 +137,16 @@ forbidden(RD, Ctx) ->
end
end.

%% @spec content_types_provided(reqdata(), context()) ->
%% {[{ContentType::string(), Producer::atom()}], reqdata(), context()}
-spec content_types_provided(#wm_reqdata{}, context()) ->
{[{ContentType::string(), Producer::atom()}], #wm_reqdata{}, context()}.
%% @doc List the content types available for representing this resource.
%% "application/json" is the content-type for bucket lists.
content_types_provided(RD, Ctx) ->
{[{"application/json", produce_bucket_list}], RD, Ctx}.


%% @spec encodings_provided(reqdata(), context()) ->
%% {[{Encoding::string(), Producer::function()}], reqdata(), context()}
-spec encodings_provided(#wm_reqdata{}, context()) ->
{[{Encoding::string(), Producer::function()}], #wm_reqdata{}, context()}.
%% @doc List the encodings available for representing this resource.
%% "identity" and "gzip" are available for bucket lists.
encodings_provided(RD, Ctx) ->
Expand All @@ -155,8 +155,8 @@ encodings_provided(RD, Ctx) ->
malformed_request(RD, Ctx) ->
malformed_timeout_param(RD, Ctx).

%% @spec malformed_timeout_param(reqdata(), context()) ->
%% {boolean(), reqdata(), context()}
-spec malformed_timeout_param(#wm_reqdata{}, context()) ->
{boolean(), #wm_reqdata{}, context()}.
%% @doc Check that the timeout parameter is are a
%% string-encoded integer. Store the integer value
%% in context() if so.
Expand All @@ -183,7 +183,8 @@ malformed_timeout_param(RD, Ctx) ->
resource_exists(RD, #ctx{bucket_type=BType}=Ctx) ->
{riak_kv_wm_utils:bucket_type_exists(BType), RD, Ctx}.

%% @spec produce_bucket_list(reqdata(), context()) -> {binary(), reqdata(), context()}
-spec produce_bucket_list(#wm_reqdata{}, context()) ->
{binary(), #wm_reqdata{}, context()}.
%% @doc Produce the JSON response to a bucket-level GET.
%% Includes a list of known buckets if the "buckets=true" query
%% param is specified.
Expand Down
6 changes: 2 additions & 4 deletions src/riak_kv_wm_counter.erl
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
to_text/2
]).

%% @type context() = term()
-record(ctx, {api_version, %% integer() - Determine which version of the API to use.
bucket, %% binary() - Bucket name (from uri)
key, %% binary() - Key (from uri)
Expand All @@ -105,15 +104,14 @@
counter_op :: integer() | undefined, %% The amount to add to the counter
security %% security context
}).
%% @type link() = {{Bucket::binary(), Key::binary()}, Tag::binary()}
%% @type index_field() = {Key::string(), Value::string()}
-type context() :: #ctx{}.

-include_lib("webmachine/include/webmachine.hrl").
-include("riak_kv_wm_raw.hrl").
-include("riak_kv_types.hrl").


%% @spec init(proplist()) -> {ok, context()}
-spec init(proplists:proplist()) -> {ok, context()}.
%% @doc Initialize this resource. This function extracts the
%% 'prefix' and 'riak' properties from the dispatch args.
init(Props) ->
Expand Down
23 changes: 12 additions & 11 deletions src/riak_kv_wm_index.erl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
produce_index_results/2
]).

%% @type context() = term()
-record(ctx, {
client, %% riak_client() - the store client
riak, %% local | {node(), atom()} - params for riak client
Expand All @@ -76,14 +75,15 @@
pagination_sort :: boolean() | undefined,
security %% security context
}).
-type context() :: #ctx{}.

-define(ALL_2I_RESULTS, all).

-include_lib("webmachine/include/webmachine.hrl").
-include("riak_kv_wm_raw.hrl").
-include("riak_kv_index.hrl").

%% @spec init(proplist()) -> {ok, context()}
-spec init(proplists:proplist()) -> {ok, context()}.
%% @doc Initialize this resource.
init(Props) ->
{ok, #ctx{
Expand All @@ -92,8 +92,8 @@ init(Props) ->
}}.


%% @spec service_available(reqdata(), context()) ->
%% {boolean(), reqdata(), context()}
-spec service_available(#wm_reqdata{}, context()) ->
{boolean(), #wm_reqdata{}, context()}.
%% @doc Determine whether or not a connection to Riak
%% can be established. Also, extract query params.
service_available(RD, Ctx0=#ctx{riak=RiakProps}) ->
Expand Down Expand Up @@ -145,8 +145,8 @@ forbidden(RD, Ctx) ->
end
end.

%% @spec malformed_request(reqdata(), context()) ->
%% {boolean(), reqdata(), context()}
-spec malformed_request(#wm_reqdata{}, context()) ->
{boolean(), #wm_reqdata{}, context()}.
%% @doc Determine whether query parameters are badly-formed.
%% Specifically, we check that the index operation is of
%% a known type.
Expand Down Expand Up @@ -296,16 +296,16 @@ normalize_boolean("true") ->
normalize_boolean(_) ->
malformed.

%% @spec content_types_provided(reqdata(), context()) ->
%% {[{ContentType::string(), Producer::atom()}], reqdata(), context()}
-spec content_types_provided(#wm_reqdata{}, context()) ->
{[{ContentType::string(), Producer::atom()}], #wm_reqdata{}, context()}.
%% @doc List the content types available for representing this resource.
%% "application/json" is the content-type for bucket lists.
content_types_provided(RD, Ctx) ->
{[{"application/json", produce_index_results}], RD, Ctx}.


%% @spec encodings_provided(reqdata(), context()) ->
%% {[{Encoding::string(), Producer::function()}], reqdata(), context()}
-spec encodings_provided(#wm_reqdata{}, context()) ->
{[{Encoding::string(), Producer::function()}], #wm_reqdata{}, context()}.
%% @doc List the encodings available for representing this resource.
%% "identity" and "gzip" are available for bucket lists.
encodings_provided(RD, Ctx) ->
Expand All @@ -315,7 +315,8 @@ encodings_provided(RD, Ctx) ->
resource_exists(RD, #ctx{bucket_type=BType}=Ctx) ->
{riak_kv_wm_utils:bucket_type_exists(BType), RD, Ctx}.

%% @spec produce_index_results(reqdata(), context()) -> {binary(), reqdata(), context()}
-spec produce_index_results(#wm_reqdata{}, context()) ->
{binary(), #wm_reqdata{}, context()}.
%% @doc Produce the JSON response to an index lookup.
produce_index_results(RD, Ctx) ->
case wrq:get_qs_value("stream", "false", RD) of
Expand Down
Loading