fix 语法告警
This commit is contained in:
parent
4618e0a562
commit
aa4a62f3e8
@ -57,7 +57,7 @@ get_precision(Timestamp) when is_integer(Timestamp) ->
|
||||
<<"ms">>
|
||||
end.
|
||||
|
||||
-spec write_data(Measurement :: binary(), Tags :: map(), FieldsList :: list(), Timestamp :: integer()) -> no_return().
|
||||
-spec write_data(Measurement :: binary(), Tags :: map(), FieldsList :: list(), Timestamp :: integer()) -> term().
|
||||
write_data(Measurement, Tags, FieldsList, Timestamp) when is_binary(Measurement), is_map(Tags), is_list(FieldsList), is_integer(Timestamp) ->
|
||||
%% 过来掉没有key的选项
|
||||
NFieldsList = lists:filter(fun data_filter/1, FieldsList),
|
||||
@ -76,12 +76,12 @@ write_data(Measurement, Tags, FieldsList, Timestamp) when is_binary(Measurement)
|
||||
ok
|
||||
end.
|
||||
|
||||
-spec write(Pid :: pid(), Bucket :: binary(), Org :: binary(), Points :: list()) -> no_return().
|
||||
-spec write(Pid :: pid(), Bucket :: binary(), Org :: binary(), Points :: list()) -> ok.
|
||||
write(Pid, Bucket, Org, Points) when is_pid(Pid), is_binary(Bucket), is_binary(Org), is_list(Points) ->
|
||||
write(Pid, Bucket, Org, <<"ms">>, Points).
|
||||
|
||||
%% Precision的值为: ms|ns|s; 表示时间的精度,默认为毫秒(ms)
|
||||
-spec write(Pid :: pid(), Bucket :: binary(), Org :: binary(), Precision :: binary(), Points :: list()) -> no_return().
|
||||
-spec write(Pid :: pid(), Bucket :: binary(), Org :: binary(), Precision :: binary(), Points :: list()) -> ok.
|
||||
write(Pid, Bucket, Org, Precision, Points) when is_pid(Pid), is_binary(Bucket), is_binary(Org), is_binary(Precision), is_list(Points) ->
|
||||
gen_server:cast(Pid, {write, Bucket, Org, Precision, Points}).
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ get_alias_name(Name) when is_binary(Name) ->
|
||||
get_alias_pid(Name) when is_binary(Name) ->
|
||||
gproc:whereis_name({n, l, get_alias_name(Name)}).
|
||||
|
||||
-spec forward(Pid :: pid(), Metric :: binary()) -> no_return().
|
||||
-spec forward(Pid :: pid(), Metric :: binary()) -> ok.
|
||||
forward(Pid, Metric) when is_pid(Pid), is_binary(Metric) ->
|
||||
gen_server:cast(Pid, {forward, Metric}).
|
||||
|
||||
|
||||
@ -192,11 +192,7 @@ recover_inflight(Buffer = #buffer{timer_map = TimerMap}) ->
|
||||
NBuffer0 = persist_memory_inflight(Buffer),
|
||||
case endpoint_outbox:reset_reader(NBuffer0#buffer.outbox) of
|
||||
{ok, NOutbox} ->
|
||||
NBuffer0#buffer{outbox = NOutbox, timer_map = #{}, flight_num = 0};
|
||||
{error, Reason} ->
|
||||
logger:warning("[endpoint_buffer] recover inflight failed, endpoint_id: ~p, reason: ~p",
|
||||
[buffer_endpoint_id(Buffer), Reason]),
|
||||
NBuffer0#buffer{timer_map = #{}, flight_num = 0}
|
||||
NBuffer0#buffer{outbox = NOutbox, timer_map = #{}, flight_num = 0}
|
||||
end.
|
||||
|
||||
-spec resize(Buffer :: #buffer{}, WindowSize :: integer()) -> #buffer{}.
|
||||
@ -293,11 +289,7 @@ persist_memory_inflight(Buffer = #buffer{timer_map = TimerMap}) ->
|
||||
reset_reader_after_recover(Buffer = #buffer{outbox = Outbox}) ->
|
||||
case endpoint_outbox:reset_reader(Outbox) of
|
||||
{ok, NOutbox} ->
|
||||
Buffer#buffer{outbox = NOutbox};
|
||||
{error, Reason} ->
|
||||
logger:warning("[endpoint_buffer] reset reader failed, endpoint_id: ~p, reason: ~p",
|
||||
[buffer_endpoint_id(Buffer), Reason]),
|
||||
Buffer
|
||||
Buffer#buffer{outbox = NOutbox}
|
||||
end.
|
||||
|
||||
-spec count_inflight(flight_source(), #{integer() => timer_entry()}) -> non_neg_integer().
|
||||
|
||||
@ -415,7 +415,7 @@ ensure_writable_segment(RecordBytes, Outbox = #outbox{
|
||||
checkpoint = #outbox_checkpoint{acked_seq = AckedSeq}
|
||||
}) ->
|
||||
case find_segment(Segments, WriteSegment) of
|
||||
undefined ->
|
||||
false ->
|
||||
{ok, WriteSegment, Outbox};
|
||||
#segment{records = Records, bytes = Bytes} ->
|
||||
NeedRoll = Records > 0 andalso (Records >= MaxRecords orelse Bytes + RecordBytes > MaxBytes),
|
||||
@ -483,7 +483,7 @@ update_written_segment(Segments, SegmentId, Path, Seq, RecordBytes) ->
|
||||
compare_segment(#segment{id = Id0}, #segment{id = Id1}) ->
|
||||
Id0 =< Id1.
|
||||
|
||||
-spec find_segment([#segment{}], pos_integer()) -> undefined | #segment{}.
|
||||
-spec find_segment([#segment{}], pos_integer()) -> false | #segment{}.
|
||||
find_segment(Segments, SegmentId) ->
|
||||
lists:keyfind(SegmentId, #segment.id, Segments).
|
||||
|
||||
@ -566,15 +566,7 @@ reset_reader_after_prune(Outbox = #outbox{
|
||||
false ->
|
||||
case reset_reader(Outbox) of
|
||||
{ok, NOutbox} ->
|
||||
NOutbox;
|
||||
{error, _} ->
|
||||
Outbox#outbox{
|
||||
reader = #outbox_reader{
|
||||
segment = undefined,
|
||||
offset = 0,
|
||||
fd = undefined
|
||||
}
|
||||
}
|
||||
NOutbox
|
||||
end
|
||||
end.
|
||||
|
||||
@ -811,13 +803,11 @@ maybe_open_write_fd(Outbox = #outbox{
|
||||
}
|
||||
}) ->
|
||||
case find_segment(Segments, WriteSegment) of
|
||||
undefined ->
|
||||
false ->
|
||||
{ok, Outbox};
|
||||
_ ->
|
||||
ensure_write_fd(WriteSegment, Outbox)
|
||||
end;
|
||||
maybe_open_write_fd(Outbox = #outbox{}) ->
|
||||
{ok, Outbox}.
|
||||
end.
|
||||
|
||||
-spec maybe_open_read_fd(outbox()) -> {ok, outbox()} | {error, term()}.
|
||||
maybe_open_read_fd(Outbox = #outbox{reader = #outbox_reader{segment = undefined}}) ->
|
||||
|
||||
@ -70,7 +70,7 @@ get_name(UUID) when is_binary(UUID) ->
|
||||
get_alias_name(HostId0) when is_integer(HostId0) ->
|
||||
{iot_host_id, HostId0}.
|
||||
|
||||
-spec kill(UUID :: binary()) -> no_return().
|
||||
-spec kill(UUID :: binary()) -> ok | true.
|
||||
kill(UUID) when is_binary(UUID) ->
|
||||
case get_pid(UUID) of
|
||||
undefined ->
|
||||
@ -80,7 +80,7 @@ kill(UUID) when is_binary(UUID) ->
|
||||
end.
|
||||
|
||||
%% 处理消息
|
||||
-spec handle(Pid :: pid(), Packet :: {atom(), any()}) -> no_return().
|
||||
-spec handle(Pid :: pid(), Packet :: tuple()) -> ok.
|
||||
handle(Pid, Packet) when is_pid(Pid) ->
|
||||
gen_statem:cast(Pid, {handle, Packet}).
|
||||
|
||||
@ -154,7 +154,7 @@ await_reply(Pid, Ref, Timeout) when is_pid(Pid), is_reference(Ref), is_integer(T
|
||||
pub(Pid, Topic, Qos, Content) when is_pid(Pid), is_binary(Topic), is_integer(Qos), is_binary(Content) ->
|
||||
gen_statem:call(Pid, {pub, Topic, Qos, Content}).
|
||||
|
||||
-spec heartbeat(Pid :: pid()) -> no_return().
|
||||
-spec heartbeat(Pid :: undefined | pid()) -> ok.
|
||||
heartbeat(undefined) ->
|
||||
ok;
|
||||
heartbeat(Pid) when is_pid(Pid) ->
|
||||
@ -402,4 +402,4 @@ maybe_mark_host_offline(UUID) ->
|
||||
Other ->
|
||||
logger:warning("[iot_host] host: ~p, load status failed while marking offline: ~p", [UUID, Other]),
|
||||
ok
|
||||
end.
|
||||
end.
|
||||
|
||||
@ -186,7 +186,7 @@ request_error_response(Code, Reason) when is_integer(Code), is_binary(Reason) ->
|
||||
end.
|
||||
|
||||
-spec request_error_http_response(Reason :: term()) ->
|
||||
{ok, HttpStatus :: integer(), Body :: iolist()}.
|
||||
{ok, HttpStatus :: 400 | 504, Body :: binary()}.
|
||||
request_error_http_response(Reason) ->
|
||||
HttpStatus = request_error_status(Reason),
|
||||
{ok, HttpStatus, request_error_response(HttpStatus, reason_to_binary(Reason))}.
|
||||
@ -220,7 +220,7 @@ decode_json_bytes(Data) when is_binary(Data) ->
|
||||
end.
|
||||
|
||||
-spec handle_deploy_container(pid(), binary(), integer(), map()) ->
|
||||
{ok, integer(), iolist()}.
|
||||
{ok, 200 | 400 | 504, binary()}.
|
||||
handle_deploy_container(Pid, UUID, TaskId, Config) ->
|
||||
case iot_host:deploy_container(Pid, TaskId, Config) of
|
||||
{ok, Ref} ->
|
||||
|
||||
@ -82,9 +82,7 @@ parse_body(Req0) ->
|
||||
case cowboy_req:read_urlencoded_body(Req0) of
|
||||
{ok, PostParams0, Req1} ->
|
||||
PostParams = maps:from_list(PostParams0),
|
||||
{ok, PostParams, Req1};
|
||||
{more, _PostParams0, Req1} ->
|
||||
{error, 413, iot_util:json_error(413, <<"payload too large">>), Req1}
|
||||
{ok, PostParams, Req1}
|
||||
end;
|
||||
_ ->
|
||||
{ok, #{}, Req0}
|
||||
|
||||
@ -38,7 +38,7 @@
|
||||
}).
|
||||
|
||||
%% 向通道中写入消息
|
||||
-spec pub(Pid :: pid(), Topic :: binary(), Qos :: integer(), Content :: binary()) -> no_return().
|
||||
-spec pub(Pid :: pid(), Topic :: binary(), Qos :: integer(), Content :: binary()) -> ok.
|
||||
pub(Pid, Topic, Qos, Content) when is_pid(Pid), is_binary(Topic), is_integer(Qos), is_binary(Content) ->
|
||||
gen_server:cast(Pid, {pub, Topic, Qos, Content}).
|
||||
|
||||
@ -52,7 +52,7 @@ cancel_command_call(Pid, Ref) when is_pid(Pid), is_reference(Ref) ->
|
||||
gen_server:call(Pid, {cancel_command_call, Ref}).
|
||||
|
||||
%% 关闭方法
|
||||
-spec stop(Pid :: pid(), Reason :: any()) -> no_return().
|
||||
-spec stop(Pid :: undefined | pid(), Reason :: any()) -> ok.
|
||||
stop(undefined, _Reason) ->
|
||||
ok;
|
||||
stop(Pid, Reason) when is_pid(Pid) ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user