Fix peer mode queries and add help output
This commit is contained in:
parent
94224a7ba0
commit
63d85b9f7a
@ -1 +1 @@
|
|||||||
0.6.0
|
0.6.1
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{application,zx,
|
{application,zx,
|
||||||
[{description,"An Erlang development tool and Zomp user client"},
|
[{description,"An Erlang development tool and Zomp user client"},
|
||||||
{vsn,"0.6.0"},
|
{vsn,"0.6.1"},
|
||||||
{applications,[stdlib,kernel]},
|
{applications,[stdlib,kernel]},
|
||||||
{modules,[zx,zx_auth,zx_conn,zx_conn_sup,zx_daemon,zx_key,
|
{modules,[zx,zx_auth,zx_conn,zx_conn_sup,zx_daemon,zx_key,
|
||||||
zx_lib,zx_local,zx_net,zx_peer,zx_peer_man,
|
zx_lib,zx_local,zx_net,zx_peer,zx_peer_man,
|
||||||
@ -24,7 +24,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(zx).
|
-module(zx).
|
||||||
-vsn("0.6.0").
|
-vsn("0.6.1").
|
||||||
-behavior(application).
|
-behavior(application).
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||||
@ -899,6 +899,7 @@ usage_user() ->
|
|||||||
" zx list realms~n"
|
" zx list realms~n"
|
||||||
" zx list packages Realm~n"
|
" zx list packages Realm~n"
|
||||||
" zx list versions PackageID~n"
|
" zx list versions PackageID~n"
|
||||||
|
" zx list [gui | cli | app | lib]~n"
|
||||||
" zx latest PackageID~n"
|
" zx latest PackageID~n"
|
||||||
" zx search Tag~n"
|
" zx search Tag~n"
|
||||||
" zx describe Package~n"
|
" zx describe Package~n"
|
||||||
@ -9,7 +9,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(zx_auth).
|
-module(zx_auth).
|
||||||
-vsn("0.6.0").
|
-vsn("0.6.1").
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||||
-license("GPL-3.0").
|
-license("GPL-3.0").
|
||||||
@ -7,7 +7,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(zx_conn).
|
-module(zx_conn).
|
||||||
-vsn("0.6.0").
|
-vsn("0.6.1").
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||||
-license("GPL-3.0").
|
-license("GPL-3.0").
|
||||||
@ -5,7 +5,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(zx_conn_sup).
|
-module(zx_conn_sup).
|
||||||
-vsn("0.6.0").
|
-vsn("0.6.1").
|
||||||
-behavior(supervisor).
|
-behavior(supervisor).
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||||
@ -138,7 +138,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(zx_daemon).
|
-module(zx_daemon).
|
||||||
-vsn("0.6.0").
|
-vsn("0.6.1").
|
||||||
-behavior(gen_server).
|
-behavior(gen_server).
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||||
@ -147,8 +147,8 @@
|
|||||||
-export([zomp_mode/0]).
|
-export([zomp_mode/0]).
|
||||||
-export([pass_meta/3, argv/0,
|
-export([pass_meta/3, argv/0,
|
||||||
subscribe/1, unsubscribe/1,
|
subscribe/1, unsubscribe/1,
|
||||||
list/0, list/1, list/2, list/3, list_type/2, latest/1,
|
list/0, list/1, list/2, list/3, list_type/1, latest/1,
|
||||||
describe/1, provides/2, list_deps/1, search/2,
|
describe/1, provides/2, list_deps/1, search/1,
|
||||||
list_sysops/1,
|
list_sysops/1,
|
||||||
fetch/1, install/1, build/1,
|
fetch/1, install/1, build/1,
|
||||||
wait_result/1, wait_results/1]).
|
wait_result/1, wait_results/1]).
|
||||||
@ -187,7 +187,7 @@
|
|||||||
dropped = maps:new() :: requests(),
|
dropped = maps:new() :: requests(),
|
||||||
timer = none :: none | reference(),
|
timer = none :: none | reference(),
|
||||||
mx = mx_new() :: monitor_index(),
|
mx = mx_new() :: monitor_index(),
|
||||||
cx = new_cx() :: conn_index()}).
|
cx = offline :: conn_index()}).
|
||||||
|
|
||||||
-record(conf,
|
-record(conf,
|
||||||
{realms = zx_lib:list_realms() :: [zx:realm()],
|
{realms = zx_lib:list_realms() :: [zx:realm()],
|
||||||
@ -233,7 +233,7 @@
|
|||||||
| {request, pid(), id(), action()}.
|
| {request, pid(), id(), action()}.
|
||||||
-type requests() :: #{id() := {pid(), action()}}.
|
-type requests() :: #{id() := {pid(), action()}}.
|
||||||
-type monitor_index() :: #{pid() := {reference(), category()}}.
|
-type monitor_index() :: #{pid() := {reference(), category()}}.
|
||||||
-type conn_index() :: #cx{} | zomp | proxy.
|
-type conn_index() :: #cx{} | zomp | proxied | offline.
|
||||||
-type realm_meta() :: #rmeta{}.
|
-type realm_meta() :: #rmeta{}.
|
||||||
-type connection() :: #conn{}.
|
-type connection() :: #conn{}.
|
||||||
-type category() :: {Reqs :: [id()], Subs :: [zx:package()]}
|
-type category() :: {Reqs :: [id()], Subs :: [zx:package()]}
|
||||||
@ -446,12 +446,11 @@ list(Realm, Name, Version) ->
|
|||||||
request({list, Realm, Name, Version}).
|
request({list, Realm, Name, Version}).
|
||||||
|
|
||||||
|
|
||||||
-spec list_type(Realm, Type) -> {ok, RequestID}
|
-spec list_type(Target) -> {ok, RequestID}
|
||||||
when Realm :: zx:realm(),
|
when Target :: {zx:realm(), zx:package_type()},
|
||||||
Type :: zx:package_type(),
|
|
||||||
RequestID :: term().
|
RequestID :: term().
|
||||||
|
|
||||||
list_type(Realm, Type) ->
|
list_type({Realm, Type}) ->
|
||||||
true = zx_lib:valid_lower0_9(Realm),
|
true = zx_lib:valid_lower0_9(Realm),
|
||||||
request({list_type, Realm, Type}).
|
request({list_type, Realm, Type}).
|
||||||
|
|
||||||
@ -499,12 +498,11 @@ provides(Realm, Module) ->
|
|||||||
request({provides, Realm, Module}).
|
request({provides, Realm, Module}).
|
||||||
|
|
||||||
|
|
||||||
-spec search(Realm, String) -> {ok, RequestID}
|
-spec search(Target) -> {ok, RequestID}
|
||||||
when Realm :: zx:realm(),
|
when Target :: {zx:realm(), string()},
|
||||||
String :: string(),
|
|
||||||
RequestID :: integer().
|
RequestID :: integer().
|
||||||
|
|
||||||
search(Realm, String) ->
|
search({Realm, String}) ->
|
||||||
request({search, Realm, String}).
|
request({search, Realm, String}).
|
||||||
|
|
||||||
|
|
||||||
@ -751,7 +749,7 @@ start_link() ->
|
|||||||
|
|
||||||
init(none) ->
|
init(none) ->
|
||||||
State = #s{},
|
State = #s{},
|
||||||
{ok, cx_load(State)}.
|
{ok, State}.
|
||||||
|
|
||||||
|
|
||||||
-spec connect() -> ok.
|
-spec connect() -> ok.
|
||||||
@ -957,8 +955,11 @@ terminate(_, _) -> ok.
|
|||||||
do_idle(#s{id = ID, cx = zomp}) ->
|
do_idle(#s{id = ID, cx = zomp}) ->
|
||||||
ok = log(info, "Idling as zomp with ID: ~p.", [ID]),
|
ok = log(info, "Idling as zomp with ID: ~p.", [ID]),
|
||||||
ok = retire(ID);
|
ok = retire(ID);
|
||||||
do_idle(#s{cx = proxy}) ->
|
do_idle(#s{cx = offline}) ->
|
||||||
ok = log(info, "Idling as proxy."),
|
ok = log(info, "Idling while offline."),
|
||||||
|
ok;
|
||||||
|
do_idle(#s{cx = proxied}) ->
|
||||||
|
ok = log(info, "Idling while proxied."),
|
||||||
ok;
|
ok;
|
||||||
do_idle(#s{id = ID, cx = CX}) ->
|
do_idle(#s{id = ID, cx = CX}) ->
|
||||||
ok = log(info, "Idling as prime with ID: ~p.", [ID]),
|
ok = log(info, "Idling as prime with ID: ~p.", [ID]),
|
||||||
@ -1035,10 +1036,12 @@ do_unsubscribe(Pid, Package, State = #s{actions = Actions, mx = MX}) ->
|
|||||||
%% @private
|
%% @private
|
||||||
%% Enqueue requests and update relevant index.
|
%% Enqueue requests and update relevant index.
|
||||||
|
|
||||||
do_request(Requestor, Action, State = #s{id = ID, cx = proxy}) ->
|
do_request(Requestor, Action, State = #s{id = ID, cx = proxied}) ->
|
||||||
Result = zx_proxy:request(Action),
|
Result = zx_proxy:request(Action),
|
||||||
Requestor ! {result, ID, Result},
|
Requestor ! {result, ID, Result},
|
||||||
State;
|
State;
|
||||||
|
do_request(_, _, #s{cx = offline}) ->
|
||||||
|
throw("Trying to perform request while offline. Impossible! I am ded.");
|
||||||
do_request(Requestor, Action, State = #s{id = ID, actions = Actions, mx = MX}) ->
|
do_request(Requestor, Action, State = #s{id = ID, actions = Actions, mx = MX}) ->
|
||||||
NewActions = [{request, Requestor, ID, Action} | Actions],
|
NewActions = [{request, Requestor, ID, Action} | Actions],
|
||||||
NewMX = mx_add_monitor(Requestor, {requestor, ID}, MX),
|
NewMX = mx_add_monitor(Requestor, {requestor, ID}, MX),
|
||||||
@ -1057,9 +1060,12 @@ do_request(Requestor, Action, State = #s{id = ID, actions = Actions, mx = MX}) -
|
|||||||
do_report(Conn, Report, State = #s{cx = zomp}) ->
|
do_report(Conn, Report, State = #s{cx = zomp}) ->
|
||||||
ok = log(warning, "Zomp mode: Discarding report ~tp ~200tp", [Conn, Report]),
|
ok = log(warning, "Zomp mode: Discarding report ~tp ~200tp", [Conn, Report]),
|
||||||
State;
|
State;
|
||||||
do_report(Conn, Report, State = #s{cx = proxy}) ->
|
do_report(Conn, Report, State = #s{cx = proxied}) ->
|
||||||
ok = log(warning, "Proxied: Discarding report ~tp ~200tp", [Conn, Report]),
|
ok = log(warning, "Proxied: Discarding report ~tp ~200tp", [Conn, Report]),
|
||||||
State;
|
State;
|
||||||
|
do_report(Conn, Report, State = #s{cx = offline}) ->
|
||||||
|
ok = log(warning, "Offline: Discarding report ~tp ~200tp", [Conn, Report]),
|
||||||
|
State;
|
||||||
do_report(Conn, {connected, Realms}, State = #s{mx = MX, cx = CX}) ->
|
do_report(Conn, {connected, Realms}, State = #s{mx = MX, cx = CX}) ->
|
||||||
{NewMX, NewCX} =
|
{NewMX, NewCX} =
|
||||||
case cx_connected(Realms, Conn, CX) of
|
case cx_connected(Realms, Conn, CX) of
|
||||||
@ -1154,21 +1160,24 @@ dequeue(Pending) ->
|
|||||||
|
|
||||||
connect(State = #s{cx = zomp}) ->
|
connect(State = #s{cx = zomp}) ->
|
||||||
State;
|
State;
|
||||||
connect(State) ->
|
connect(State = #s{cx = offline}) ->
|
||||||
LockFile = lockfile(),
|
LockFile = lockfile(),
|
||||||
case file:read_file(LockFile) of
|
case file:read_file(LockFile) of
|
||||||
{ok, PS} ->
|
{ok, PS} ->
|
||||||
Port = binary_to_integer(string:trim(PS)),
|
Port = binary_to_integer(string:trim(PS)),
|
||||||
|
ok = log(info, "Connecting to local proxy."),
|
||||||
proxy_connect(Port, State);
|
proxy_connect(Port, State);
|
||||||
{error, enoent} ->
|
{error, enoent} ->
|
||||||
remote_connect(State)
|
remote_connect(cx_load(State))
|
||||||
end.
|
end;
|
||||||
|
connect(State) ->
|
||||||
|
remote_connect(State).
|
||||||
|
|
||||||
|
|
||||||
proxy_connect(Port, State) ->
|
proxy_connect(Port, State) ->
|
||||||
case zx_proxy:connect(Port) of
|
case zx_proxy:connect(Port) of
|
||||||
ok -> State#s{cx = proxy};
|
ok -> State#s{cx = proxied};
|
||||||
error -> remote_connect(State)
|
error -> remote_connect(cx_load(State))
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
@ -1191,7 +1200,7 @@ init_connections([], State) ->
|
|||||||
|
|
||||||
ensure_connections(State = #s{cx = zomp}) ->
|
ensure_connections(State = #s{cx = zomp}) ->
|
||||||
State;
|
State;
|
||||||
ensure_connections(State = #s{cx = proxy}) ->
|
ensure_connections(State = #s{cx = proxied}) ->
|
||||||
State;
|
State;
|
||||||
ensure_connections(State = #s{conf = Conf, mx = MX, cx = CX}) ->
|
ensure_connections(State = #s{conf = Conf, mx = MX, cx = CX}) ->
|
||||||
#conf{realms = Realms, managed = Managed} = Conf,
|
#conf{realms = Realms, managed = Managed} = Conf,
|
||||||
@ -1212,14 +1221,20 @@ ensure_connections(State = #s{conf = Conf, mx = MX, cx = CX}) ->
|
|||||||
|
|
||||||
-spec wipe_connections(state()) -> ok.
|
-spec wipe_connections(state()) -> ok.
|
||||||
|
|
||||||
wipe_connections(State = #s{cx = proxy}) ->
|
wipe_connections(State = #s{cx = proxied}) ->
|
||||||
ok = log(warning, "Proxied: No connections to wipe."),
|
ok = log(warning, "Proxied: No connections to wipe."),
|
||||||
State;
|
State;
|
||||||
|
wipe_connections(State = #s{cx = offline}) ->
|
||||||
|
ok = log(warning, "Offline: No connections to wipe."),
|
||||||
|
State;
|
||||||
|
wipe_connections(State = #s{cx = zomp}) ->
|
||||||
|
ok = log(warning, "Zomp: No connections to wipe."),
|
||||||
|
State;
|
||||||
wipe_connections(State = #s{mx = MX, cx = CX}) ->
|
wipe_connections(State = #s{mx = MX, cx = CX}) ->
|
||||||
{Pids, NewCX} = cx_wipe(CX),
|
Pids = cx_wipe(CX),
|
||||||
Remove = fun(P, M) -> mx_del_monitor(P, conn, M) end,
|
Remove = fun(P, M) -> mx_del_monitor(P, conn, M) end,
|
||||||
NewMX = lists:foldl(Remove, MX, Pids),
|
NewMX = lists:foldl(Remove, MX, Pids),
|
||||||
State#s{mx = NewMX, cx = NewCX}.
|
State#s{mx = NewMX, cx = offline}.
|
||||||
|
|
||||||
|
|
||||||
-spec do_result(ID, Result, State) -> NewState
|
-spec do_result(ID, Result, State) -> NewState
|
||||||
@ -1321,7 +1336,7 @@ do_notify(Conn, Channel, Message, #s{cx = CX}) ->
|
|||||||
%% This function must iterate as far as it can into the request queue, adding response
|
%% This function must iterate as far as it can into the request queue, adding response
|
||||||
%% entries to the pending response structure as it goes.
|
%% entries to the pending response structure as it goes.
|
||||||
|
|
||||||
eval_queue(State = #s{cx = proxy}) ->
|
eval_queue(State = #s{cx = proxied}) ->
|
||||||
State;
|
State;
|
||||||
eval_queue(State = #s{actions = Actions}) ->
|
eval_queue(State = #s{actions = Actions}) ->
|
||||||
InOrder = lists:reverse(Actions),
|
InOrder = lists:reverse(Actions),
|
||||||
@ -1390,7 +1405,8 @@ local_request(R, {describe, N, V}) -> zomp_realm:describe(R, {N, V});
|
|||||||
local_request(R, {provides, M}) -> zomp_realm:provides(R, M);
|
local_request(R, {provides, M}) -> zomp_realm:provides(R, M);
|
||||||
local_request(R, {search, S}) -> zomp_realm:search(R, S);
|
local_request(R, {search, S}) -> zomp_realm:search(R, S);
|
||||||
local_request(R, {list_deps, N, V}) -> zomp_realm:list_deps(R, {N, V});
|
local_request(R, {list_deps, N, V}) -> zomp_realm:list_deps(R, {N, V});
|
||||||
local_request(R, {list_sysops}) -> zomp_realm:list_sysops(R).
|
local_request(R, {list_sysops}) -> zomp_realm:list_sysops(R);
|
||||||
|
local_request(R, {list_type, T}) -> zomp_realm:list_type(R, T).
|
||||||
|
|
||||||
|
|
||||||
remote_dispatch([], State) ->
|
remote_dispatch([], State) ->
|
||||||
@ -2014,23 +2030,6 @@ do_drop_realm(Realm, State) ->
|
|||||||
do_abdicate(Realm, State).
|
do_abdicate(Realm, State).
|
||||||
|
|
||||||
|
|
||||||
-spec become_proxy(State) -> NewState
|
|
||||||
when State :: state(),
|
|
||||||
NewState :: state().
|
|
||||||
|
|
||||||
become_proxy(State = #s{cx = zomp}) ->
|
|
||||||
ok = log(warning, "Already set as zomp node."),
|
|
||||||
State;
|
|
||||||
become_proxy(State = #s{cx = proxy}) ->
|
|
||||||
{ok, Port} = zx_peer_man:listen(),
|
|
||||||
ok = write_lockfile(Port),
|
|
||||||
{ok, ID} = zx_proxy:youre_fired(),
|
|
||||||
State#s{id = ID, cx = zomp};
|
|
||||||
become_proxy(State) ->
|
|
||||||
ok = log(warning, "Already acting proxy."),
|
|
||||||
State.
|
|
||||||
|
|
||||||
|
|
||||||
-spec become_zomp_node(State) -> NewState
|
-spec become_zomp_node(State) -> NewState
|
||||||
when State :: state(),
|
when State :: state(),
|
||||||
NewState :: state().
|
NewState :: state().
|
||||||
@ -2038,9 +2037,13 @@ become_proxy(State) ->
|
|||||||
become_zomp_node(State = #s{cx = zomp}) ->
|
become_zomp_node(State = #s{cx = zomp}) ->
|
||||||
ok = log(warning, "Already set as zomp node."),
|
ok = log(warning, "Already set as zomp node."),
|
||||||
State;
|
State;
|
||||||
become_zomp_node(State = #s{cx = proxy}) ->
|
become_zomp_node(State = #s{cx = offline}) ->
|
||||||
NewState = become_proxy(State),
|
State#s{cx = zomp};
|
||||||
NewState#s{cx = zomp};
|
become_zomp_node(State = #s{cx = proxied}) ->
|
||||||
|
{ok, Port} = zx_peer_man:listen(),
|
||||||
|
ok = write_lockfile(Port),
|
||||||
|
{ok, ID} = zx_proxy:youre_fired(),
|
||||||
|
State#s{id = ID, cx = zomp};
|
||||||
become_zomp_node(State) ->
|
become_zomp_node(State) ->
|
||||||
NewState = wipe_connections(State),
|
NewState = wipe_connections(State),
|
||||||
NewState#s{cx = zomp}.
|
NewState#s{cx = zomp}.
|
||||||
@ -2178,10 +2181,6 @@ mx_drop_monitor(Pid, MX) ->
|
|||||||
%%%
|
%%%
|
||||||
%%% Return values often carry some status information with them.
|
%%% Return values often carry some status information with them.
|
||||||
|
|
||||||
-spec new_cx() -> conn_index().
|
|
||||||
|
|
||||||
new_cx() -> #cx{}.
|
|
||||||
|
|
||||||
|
|
||||||
-spec cx_load(state()) -> state().
|
-spec cx_load(state()) -> state().
|
||||||
%% @private
|
%% @private
|
||||||
@ -2320,9 +2319,11 @@ cx_hosts_cache() ->
|
|||||||
|
|
||||||
cx_realms(#cx{realms = Realms}) ->
|
cx_realms(#cx{realms = Realms}) ->
|
||||||
maps:keys(Realms);
|
maps:keys(Realms);
|
||||||
|
cx_realms(offline) ->
|
||||||
|
zx_lib:list_realms();
|
||||||
cx_realms(zomp) ->
|
cx_realms(zomp) ->
|
||||||
zx_lib:list_realms();
|
zx_lib:list_realms();
|
||||||
cx_realms(proxy) ->
|
cx_realms(proxied) ->
|
||||||
{ok, Realms} = zx_proxy:request(list),
|
{ok, Realms} = zx_proxy:request(list),
|
||||||
Realms.
|
Realms.
|
||||||
|
|
||||||
@ -2330,12 +2331,12 @@ cx_realms(proxy) ->
|
|||||||
-spec cx_mirrors(CX) -> Result
|
-spec cx_mirrors(CX) -> Result
|
||||||
when CX :: conn_index(),
|
when CX :: conn_index(),
|
||||||
Result :: {ok, [zx:host()]}
|
Result :: {ok, [zx:host()]}
|
||||||
| {error, zomp}.
|
| {error, offline | zomp | proxied}.
|
||||||
|
|
||||||
cx_mirrors(#cx{mirrors = Mirrors}) ->
|
cx_mirrors(#cx{mirrors = Mirrors}) ->
|
||||||
{ok, queue:to_list(Mirrors)};
|
{ok, queue:to_list(Mirrors)};
|
||||||
cx_mirrors(zomp) ->
|
cx_mirrors(Status) ->
|
||||||
{error, zomp}.
|
{error, Status}.
|
||||||
|
|
||||||
|
|
||||||
-spec cx_check_service(Realms, CX) -> Result
|
-spec cx_check_service(Realms, CX) -> Result
|
||||||
@ -2453,14 +2454,14 @@ cx_redirect([], CX) ->
|
|||||||
CX.
|
CX.
|
||||||
|
|
||||||
|
|
||||||
-spec cx_wipe(CX) -> ok
|
-spec cx_wipe(CX) -> Pids
|
||||||
when CX :: conn_index().
|
when CX :: conn_index(),
|
||||||
|
Pids :: [pid()].
|
||||||
|
|
||||||
cx_wipe(CX = #cx{conns = Conns, mirrors = Mirrors}) ->
|
cx_wipe(#cx{conns = Conns}) ->
|
||||||
Pids = [P || #conn{pid = P} <- Conns],
|
Pids = [P || #conn{pid = P} <- Conns],
|
||||||
ok = lists:foreach(fun zx_conn:retire/1, Pids),
|
ok = lists:foreach(fun zx_conn:retire/1, Pids),
|
||||||
NewCX = CX#cx{conns = [], hosts = Mirrors},
|
Pids.
|
||||||
{Pids, NewCX}.
|
|
||||||
|
|
||||||
|
|
||||||
-spec cx_disconnected(Conn, CX) -> {Requests, Subs, NewCX}
|
-spec cx_disconnected(Conn, CX) -> {Requests, Subs, NewCX}
|
||||||
@ -8,7 +8,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(zx_key).
|
-module(zx_key).
|
||||||
-vsn("0.6.0").
|
-vsn("0.6.1").
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||||
-license("GPL-3.0").
|
-license("GPL-3.0").
|
||||||
@ -10,7 +10,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(zx_lib).
|
-module(zx_lib).
|
||||||
-vsn("0.6.0").
|
-vsn("0.6.1").
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||||
-license("GPL-3.0").
|
-license("GPL-3.0").
|
||||||
@ -6,7 +6,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(zx_local).
|
-module(zx_local).
|
||||||
-vsn("0.6.0").
|
-vsn("0.6.1").
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||||
-license("GPL-3.0").
|
-license("GPL-3.0").
|
||||||
@ -757,16 +757,27 @@ list_type(Type) ->
|
|||||||
Realms = zx_lib:list_realms(),
|
Realms = zx_lib:list_realms(),
|
||||||
MakeRequest =
|
MakeRequest =
|
||||||
fun(Realm) ->
|
fun(Realm) ->
|
||||||
{ok, ID} = zx_daemon:list_type(Realm, Type),
|
{ok, ID} = zx_daemon:list_type({Realm, Type}),
|
||||||
ID
|
ID
|
||||||
end,
|
end,
|
||||||
Index = [{MakeRequest(R), R} || R <- Realms],
|
Index = [{MakeRequest(R), R} || R <- Realms],
|
||||||
IDs = [element(1, I) || I <- Index],
|
IDs = [element(1, I) || I <- Index],
|
||||||
case zx_daemon:wait_results(IDs) of
|
case zx_daemon:wait_results(IDs) of
|
||||||
{ok, Results} -> print_multirealm(lists:sort(Index), lists:sort(Results));
|
{ok, Results} ->
|
||||||
Error -> Error
|
Packages = scrub_errors(lists:sort(Index), lists:sort(Results), []),
|
||||||
|
lists:foreach(fun print_packages/1, lists:sort(Packages));
|
||||||
|
Error ->
|
||||||
|
Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
scrub_errors([{ID, _} | Index], [{ID, {ok, PackageID}} | Results], Acc) ->
|
||||||
|
scrub_errors(Index, Results, [PackageID | Acc]);
|
||||||
|
scrub_errors([{ID, Realm} | Index], [{ID, Error} | Results], Acc) ->
|
||||||
|
ok = tell(warning, "Received weird result from realm ~tp: ~tp", [Realm, Error]),
|
||||||
|
scrub_errors(Index, Results, Acc);
|
||||||
|
scrub_errors([], [], Acc) ->
|
||||||
|
lists:append(Acc).
|
||||||
|
|
||||||
|
|
||||||
-spec latest(PackageString :: string()) -> zx:outcome().
|
-spec latest(PackageString :: string()) -> zx:outcome().
|
||||||
|
|
||||||
@ -845,7 +856,7 @@ search(String) ->
|
|||||||
Realms = zx_lib:list_realms(),
|
Realms = zx_lib:list_realms(),
|
||||||
MakeRequest =
|
MakeRequest =
|
||||||
fun(Realm) ->
|
fun(Realm) ->
|
||||||
{ok, ID} = zx_daemon:search(Realm, String),
|
{ok, ID} = zx_daemon:search({Realm, String}),
|
||||||
ID
|
ID
|
||||||
end,
|
end,
|
||||||
Index = [{MakeRequest(R), R} || R <- Realms],
|
Index = [{MakeRequest(R), R} || R <- Realms],
|
||||||
@ -5,7 +5,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(zx_net).
|
-module(zx_net).
|
||||||
-vsn("0.6.0").
|
-vsn("0.6.1").
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||||
-license("GPL-3.0").
|
-license("GPL-3.0").
|
||||||
@ -8,7 +8,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(zx_peer).
|
-module(zx_peer).
|
||||||
-vsn("0.6.0").
|
-vsn("0.6.1").
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||||
-license("GPL-3.0").
|
-license("GPL-3.0").
|
||||||
@ -181,7 +181,8 @@ handle_message(<<Command:8, Bin/binary>>) ->
|
|||||||
24 -> list_keys(Payload);
|
24 -> list_keys(Payload);
|
||||||
25 -> zx_daemon:takeover(Payload);
|
25 -> zx_daemon:takeover(Payload);
|
||||||
26 -> zx_daemon:abdicate(Payload);
|
26 -> zx_daemon:abdicate(Payload);
|
||||||
27 -> zx_daemon:drop_realm(Payload)
|
27 -> zx_daemon:drop_realm(Payload);
|
||||||
|
28 -> deferred(fun zx_daemon:list_type/1, Payload)
|
||||||
end,
|
end,
|
||||||
pack(Result).
|
pack(Result).
|
||||||
|
|
||||||
@ -9,7 +9,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(zx_peer_man).
|
-module(zx_peer_man).
|
||||||
-vsn("0.6.0").
|
-vsn("0.6.1").
|
||||||
-behavior(gen_server).
|
-behavior(gen_server).
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||||
@ -6,7 +6,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(zx_peer_sup).
|
-module(zx_peer_sup).
|
||||||
-vsn("0.6.0").
|
-vsn("0.6.1").
|
||||||
-behaviour(supervisor).
|
-behaviour(supervisor).
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||||
@ -10,7 +10,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(zx_peers).
|
-module(zx_peers).
|
||||||
-vsn("0.6.0").
|
-vsn("0.6.1").
|
||||||
-behavior(supervisor).
|
-behavior(supervisor).
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||||
@ -5,7 +5,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(zx_proxy).
|
-module(zx_proxy).
|
||||||
-vsn("0.6.0").
|
-vsn("0.6.1").
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||||
-license("GPL-3.0").
|
-license("GPL-3.0").
|
||||||
@ -167,6 +167,7 @@ dispatch(Socket, Action) ->
|
|||||||
{takeover, R} -> make_query(Socket, 25, R);
|
{takeover, R} -> make_query(Socket, 25, R);
|
||||||
{abdicate, R} -> make_query(Socket, 26, R);
|
{abdicate, R} -> make_query(Socket, 26, R);
|
||||||
{drop_realm, R} -> make_query(Socket, 27, R);
|
{drop_realm, R} -> make_query(Socket, 27, R);
|
||||||
|
{list_type, R, T} -> make_query(Socket, 28, {R, T});
|
||||||
Unexpected ->
|
Unexpected ->
|
||||||
Message = "Received unexpected request action. Action: ~200tp",
|
Message = "Received unexpected request action. Action: ~200tp",
|
||||||
ok = log(warning, Message, [Unexpected]),
|
ok = log(warning, Message, [Unexpected]),
|
||||||
@ -5,7 +5,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(zx_sup).
|
-module(zx_sup).
|
||||||
-vsn("0.6.0").
|
-vsn("0.6.1").
|
||||||
-behavior(supervisor).
|
-behavior(supervisor).
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||||
@ -6,7 +6,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(zx_tty).
|
-module(zx_tty).
|
||||||
-vsn("0.6.0").
|
-vsn("0.6.1").
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||||
-license("GPL-3.0").
|
-license("GPL-3.0").
|
||||||
@ -5,7 +5,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(zx_userconf).
|
-module(zx_userconf).
|
||||||
-vsn("0.6.0").
|
-vsn("0.6.1").
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||||
-license("GPL-3.0").
|
-license("GPL-3.0").
|
||||||
@ -7,7 +7,7 @@
|
|||||||
%%% @end
|
%%% @end
|
||||||
|
|
||||||
-module(zx_zsp).
|
-module(zx_zsp).
|
||||||
-vsn("0.6.0").
|
-vsn("0.6.1").
|
||||||
-author("Craig Everett <zxq9@zxq9.com>").
|
-author("Craig Everett <zxq9@zxq9.com>").
|
||||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||||
-license("GPL-3.0").
|
-license("GPL-3.0").
|
||||||
@ -8,7 +8,7 @@
|
|||||||
{license,"MIT"}.
|
{license,"MIT"}.
|
||||||
{modules,[]}.
|
{modules,[]}.
|
||||||
{name,"zx"}.
|
{name,"zx"}.
|
||||||
{package_id,{"otpr","zx",{0,6,0}}}.
|
{package_id,{"otpr","zx",{0,6,1}}}.
|
||||||
{prefix,"zx_"}.
|
{prefix,"zx_"}.
|
||||||
{repo_url,"https://gitlab.com/zxq9/zx"}.
|
{repo_url,"https://gitlab.com/zxq9/zx"}.
|
||||||
{tags,["tools","package manager","erlang"]}.
|
{tags,["tools","package manager","erlang"]}.
|
||||||
Loading…
x
Reference in New Issue
Block a user