Skip to content

Commit

Permalink
[#285] Use uuids as tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
robertoaloi committed Mar 19, 2020
1 parent e3f25e2 commit f9e1d3e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
, {rebar3_format, "0.2.1"}
, {ephemeral, "2.0.4"}
, {tdiff, "0.1.2"}
, {uuid, "1.8.0", {pkg, uuid_erl}}
]
}.

Expand Down
4 changes: 4 additions & 0 deletions rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
{<<"katana_code">>,{pkg,<<"katana_code">>,<<"0.2.1">>},1},
{<<"lager">>,{pkg,<<"lager">>,<<"3.6.8">>},0},
{<<"providers">>,{pkg,<<"providers">>,<<"1.8.1">>},1},
{<<"quickrand">>,{pkg,<<"quickrand">>,<<"1.8.0">>},1},
{<<"ranch">>,{pkg,<<"ranch">>,<<"1.7.1">>},0},
{<<"rebar3_format">>,{pkg,<<"rebar3_format">>,<<"0.2.1">>},0},
{<<"redbug">>,{pkg,<<"redbug">>,<<"1.2.1">>},0},
{<<"tdiff">>,{pkg,<<"tdiff">>,<<"0.1.2">>},0},
{<<"uuid">>,{pkg,<<"uuid_erl">>,<<"1.8.0">>},0},
{<<"yamerl">>,{pkg,<<"yamerl">>,<<"0.7.0">>},0},
{<<"zipper">>,{pkg,<<"zipper">>,<<"1.0.1">>},1}]}.
[
Expand All @@ -31,10 +33,12 @@
{<<"katana_code">>, <<"B2195859DF57D8BEBF619A9FD3327CD7D01563A98417156D0F4C5FAB435F2630">>},
{<<"lager">>, <<"897EFC7679BB82383448646C96768CDC4E747464DD18B999C7AACA485686B0DA">>},
{<<"providers">>, <<"70B4197869514344A8A60E2B2A4EF41CA03DEF43CFB1712ECF076A0F3C62F083">>},
{<<"quickrand">>, <<"E47CE597FF067385FF5836C8C7706AC7F8AA7B47DD90C6417E05B64696F872FA">>},
{<<"ranch">>, <<"6B1FAB51B49196860B733A49C07604465A47BDB78AA10C1C16A3D199F7F8C881">>},
{<<"rebar3_format">>, <<"5B4745DC885E12E38C5061D58E87C8C3984B4524A5299846A2B6A57ABE748BD3">>},
{<<"redbug">>, <<"9153EE50E42C39CE3F6EFA65EE746F4A52896DA66862CFB59E7C0F838B7B8414">>},
{<<"tdiff">>, <<"4E1B30321F1B3D600DF65CD60858EDE1235FE4E5EE042110AB5AD90CD6464AC5">>},
{<<"uuid">>, <<"280014F8FF57FCE36EE6E91C3ECF21CBFCE78AAE9854C09597BB4C11E27B66D6">>},
{<<"yamerl">>, <<"E51DBA652DCE74C20A88294130B48051EBBBB0BE7D76F22DE064F0F3CCF0AAF5">>},
{<<"zipper">>, <<"3CCB4F14B97C06B2749B93D8B6C204A1ECB6FAFC6050CACC3B93B9870C05952A">>}]}
].
11 changes: 8 additions & 3 deletions src/els_progress.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

-define(METHOD, <<"$/progress">>).

-export([ send_notification/2 ]).
-export([ send_notification/2
, token/0
]).

%% TODO: uuid support
-type token() :: any().
-type token() :: binary().
-type value() :: els_work_done_progress:value().
-type params() :: #{ token := token()
, value := value()
Expand All @@ -20,3 +21,7 @@ send_notification(Token, Value) ->
, value => Value
},
els_server:send_notification(?METHOD, Params).

-spec token() -> token().
token() ->
list_to_binary(uuid:uuid_to_string(uuid:get_v4())).
7 changes: 2 additions & 5 deletions src/els_work_done_progress.erl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
%%==============================================================================
%% Types
%%==============================================================================
-type percentage() :: pos_integer().
-type percentage() :: 0..100.
-type value_begin() :: #{ kind := 'begin'
, title := binary()
, cancellable => boolean()
Expand Down Expand Up @@ -57,8 +57,7 @@ is_supported() ->

-spec send_create_request() -> els_progress:token().
send_create_request() ->
%% TODO: Hard-coded
Token = <<"1">>,
Token = els_progress:token(),
Method = <<"window/workDoneProgress/create">>,
Params = #{token => Token},
ok = els_server:send_request(Method, Params),
Expand Down Expand Up @@ -86,5 +85,3 @@ value_end(Message) ->
#{ kind => 'end'
, message => Message
}.

%% TODO: Implement workdone cancellation

0 comments on commit f9e1d3e

Please sign in to comment.