fix(ft): fix typings
This commit is contained in:
parent
2f1970adbc
commit
f6461fe287
|
@ -44,6 +44,7 @@
|
||||||
transfer := emqx_ft:transfer(),
|
transfer := emqx_ft:transfer(),
|
||||||
name := file:name(),
|
name := file:name(),
|
||||||
size := _Bytes :: non_neg_integer(),
|
size := _Bytes :: non_neg_integer(),
|
||||||
|
timestamp := emqx_datetime:epoch_second(),
|
||||||
uri => uri_string:uri_string(),
|
uri => uri_string:uri_string(),
|
||||||
meta => emqx_ft:filemeta()
|
meta => emqx_ft:filemeta()
|
||||||
}.
|
}.
|
||||||
|
|
|
@ -45,15 +45,7 @@
|
||||||
-type options() :: _TODO.
|
-type options() :: _TODO.
|
||||||
-type transfer() :: emqx_ft:transfer().
|
-type transfer() :: emqx_ft:transfer().
|
||||||
-type filemeta() :: emqx_ft:filemeta().
|
-type filemeta() :: emqx_ft:filemeta().
|
||||||
-type exportinfo() :: #{
|
-type exportinfo() :: emqx_ft_storage:file_info().
|
||||||
transfer := transfer(),
|
|
||||||
name := file:name(),
|
|
||||||
uri := uri_string:uri_string(),
|
|
||||||
timestamp := emqx_datetime:epoch_second(),
|
|
||||||
size := _Bytes :: non_neg_integer(),
|
|
||||||
meta => filemeta()
|
|
||||||
}.
|
|
||||||
|
|
||||||
-type file_error() :: emqx_ft_storage_fs:file_error().
|
-type file_error() :: emqx_ft_storage_fs:file_error().
|
||||||
|
|
||||||
-type export_st() :: #{
|
-type export_st() :: #{
|
||||||
|
|
|
@ -32,19 +32,20 @@
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-type headers() :: #{binary() | string() => iodata()}.
|
-type headers() :: #{binary() | string() => iodata()}.
|
||||||
|
-type erlcloud_headers() :: list({string(), iodata()}).
|
||||||
|
|
||||||
-type key() :: string().
|
-type key() :: string().
|
||||||
-type part_number() :: non_neg_integer().
|
-type part_number() :: non_neg_integer().
|
||||||
-type upload_id() :: string().
|
-type upload_id() :: string().
|
||||||
-type etag() :: string().
|
-type etag() :: string().
|
||||||
|
|
||||||
-type upload_options() :: list({acl, emqx_s3:acl()}).
|
-type upload_options() :: list({acl, emqx_s3:acl()}).
|
||||||
|
|
||||||
-opaque client() :: #{
|
-opaque client() :: #{
|
||||||
aws_config := aws_config(),
|
aws_config := aws_config(),
|
||||||
options := upload_options(),
|
upload_options := upload_options(),
|
||||||
bucket := string(),
|
bucket := string(),
|
||||||
headers := headers()
|
headers := erlcloud_headers(),
|
||||||
|
url_expire_time := non_neg_integer()
|
||||||
}.
|
}.
|
||||||
|
|
||||||
-type config() :: #{
|
-type config() :: #{
|
||||||
|
@ -62,7 +63,7 @@
|
||||||
max_retries := non_neg_integer() | undefined
|
max_retries := non_neg_integer() | undefined
|
||||||
}.
|
}.
|
||||||
|
|
||||||
-type s3_options() :: list({string(), string()}).
|
-type s3_options() :: proplists:proplist().
|
||||||
|
|
||||||
-define(DEFAULT_REQUEST_TIMEOUT, 30000).
|
-define(DEFAULT_REQUEST_TIMEOUT, 30000).
|
||||||
-define(DEFAULT_MAX_RETRIES, 2).
|
-define(DEFAULT_MAX_RETRIES, 2).
|
||||||
|
@ -171,10 +172,10 @@ abort_multipart(#{bucket := Bucket, headers := Headers, aws_config := AwsConfig}
|
||||||
{error, Reason}
|
{error, Reason}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec list(client(), s3_options()) -> ok_or_error(term()).
|
-spec list(client(), s3_options()) -> ok_or_error(proplists:proplist(), term()).
|
||||||
list(#{bucket := Bucket, aws_config := AwsConfig}, Options) ->
|
list(#{bucket := Bucket, aws_config := AwsConfig}, Options) ->
|
||||||
try
|
try erlcloud_s3:list_objects(Bucket, Options, AwsConfig) of
|
||||||
{ok, erlcloud_s3:list_objects(Bucket, Options, AwsConfig)}
|
Result -> {ok, Result}
|
||||||
catch
|
catch
|
||||||
error:{aws_error, Reason} ->
|
error:{aws_error, Reason} ->
|
||||||
?SLOG(debug, #{msg => "list_objects_fail", bucket => Bucket, reason => Reason}),
|
?SLOG(debug, #{msg => "list_objects_fail", bucket => Bucket, reason => Reason}),
|
||||||
|
|
|
@ -20,12 +20,13 @@ create_table() ->
|
||||||
set
|
set
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-spec register(ets:tid(), pid(), reference(), emqx_s3_profile_http_pools:pool_name()) -> true.
|
-spec register(ets:tid(), pid(), reference(), emqx_s3_profile_http_pools:pool_name()) -> ok.
|
||||||
register(Tab, Pid, MRef, PoolName) ->
|
register(Tab, Pid, MRef, PoolName) ->
|
||||||
true = ets:insert(Tab, {Pid, {MRef, PoolName}}),
|
true = ets:insert(Tab, {Pid, {MRef, PoolName}}),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
-spec unregister(ets:tid(), pid()) -> emqx_s3_profile_http_pools:pool_name() | undefined.
|
-spec unregister(ets:tid(), pid()) ->
|
||||||
|
{reference(), emqx_s3_profile_http_pools:pool_name()} | undefined.
|
||||||
unregister(Tab, Pid) ->
|
unregister(Tab, Pid) ->
|
||||||
case ets:take(Tab, Pid) of
|
case ets:take(Tab, Pid) of
|
||||||
[{Pid, {MRef, PoolName}}] ->
|
[{Pid, {MRef, PoolName}}] ->
|
||||||
|
|
|
@ -89,7 +89,8 @@ unregister_client(ProfileId, PoolName) ->
|
||||||
set_outdated(ProfileId, PoolName, Timeout) ->
|
set_outdated(ProfileId, PoolName, Timeout) ->
|
||||||
Key = key(ProfileId, PoolName),
|
Key = key(ProfileId, PoolName),
|
||||||
Now = erlang:monotonic_time(millisecond),
|
Now = erlang:monotonic_time(millisecond),
|
||||||
ets:update_element(?TAB, Key, {#pool.deadline, Now + Timeout}).
|
_ = ets:update_element(?TAB, Key, {#pool.deadline, Now + Timeout}),
|
||||||
|
ok.
|
||||||
|
|
||||||
-spec outdated(emqx_s3:profile_id()) ->
|
-spec outdated(emqx_s3:profile_id()) ->
|
||||||
[pool_name()].
|
[pool_name()].
|
||||||
|
|
|
@ -48,7 +48,8 @@
|
||||||
max_part_size := pos_integer(),
|
max_part_size := pos_integer(),
|
||||||
upload_id := undefined | emqx_s3_client:upload_id(),
|
upload_id := undefined | emqx_s3_client:upload_id(),
|
||||||
etags := [emqx_s3_client:etag()],
|
etags := [emqx_s3_client:etag()],
|
||||||
part_number := emqx_s3_client:part_number()
|
part_number := emqx_s3_client:part_number(),
|
||||||
|
headers := emqx_s3_client:headers()
|
||||||
}.
|
}.
|
||||||
|
|
||||||
%% 5MB
|
%% 5MB
|
||||||
|
@ -252,7 +253,7 @@ upload_part(
|
||||||
Error
|
Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec complete_upload(data()) -> ok_or_error(term()).
|
-spec complete_upload(data()) -> ok_or_error(data(), term()).
|
||||||
complete_upload(
|
complete_upload(
|
||||||
#{
|
#{
|
||||||
client := Client,
|
client := Client,
|
||||||
|
|
Loading…
Reference in New Issue