Bleh
This commit is contained in:
parent
3dfa14d20c
commit
c26f6737dc
18
TODO
18
TODO
@ -2,11 +2,23 @@
|
||||
On redirect a list of hosts of the form [{zx:host(), [zx:realm()]}] must be provided to the downstream client.
|
||||
This is the only way that downstream clients can determine which redirect hosts are useful to it.
|
||||
|
||||
- Connect attempts and established connections should have different report statuses.
|
||||
An established connection does not necessarily have other attempts being made concurrently, so a termination should initiate 3 new connect attempts as init.
|
||||
An attempt is just an attempt. It can fall flat and be replaced only 1::1.
|
||||
- Change zx_daemon request references to counters.
|
||||
Count everything.
|
||||
This will be the only way to sort of track stats other than log analysis.
|
||||
Log analysis sucks.
|
||||
|
||||
- Double-indexing must happen everywhere for anything to be discoverable without traversing the entire state of zx_daemon whenever a client or conn crashes.
|
||||
|
||||
- zx_daemon request() types have been changes to flat, wide tuples as in the main zx module.
|
||||
This change is not yet refected in the using code.
|
||||
|
||||
- Write a logging process.
|
||||
Pick a log rotation scheme.
|
||||
Eventually make it so that it can shed log loads in the event they get out of hand.
|
||||
|
||||
|
||||
- Create zx_daemon primes.
|
||||
See below
|
||||
|
||||
New Feature: ZX Universal lock
|
||||
Cross-instance communication
|
||||
|
||||
@ -50,7 +50,7 @@
|
||||
-type option() :: {string(), term()}.
|
||||
-type host() :: {string() | inet:ip_address(), inet:port_number()}.
|
||||
-type key_id() :: {realm(), key_name()}.
|
||||
-type key_name() :: label().
|
||||
-type key_name() :: lower0_9().
|
||||
-type user() :: {realm(), username()}.
|
||||
-type username() :: label().
|
||||
-type lower0_9() :: [$a..$z | $0..$9 | $_].
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||
-license("GPL-3.0").
|
||||
|
||||
-export([start_monitor/1, stop/1]).
|
||||
-export([start/1, stop/1]).
|
||||
-export([start_link/1]).
|
||||
|
||||
-include("zx_logger.erl").
|
||||
@ -20,24 +20,17 @@
|
||||
|
||||
%%% Startup
|
||||
|
||||
-spec start_monitor(Target) -> Result
|
||||
-spec start(Target) -> Result
|
||||
when Target :: zx:host(),
|
||||
Result :: {ok, PID :: pid(), Mon :: reference()}
|
||||
| {error, Reason},
|
||||
Reason :: term().
|
||||
Result :: {ok, pid()}
|
||||
| {error, Reason :: term()}.
|
||||
%% @doc
|
||||
%% Starts a connection to a given target Zomp node. This call itself should never fail,
|
||||
%% but this process may fail to connect or crash immediately after spawning. Should
|
||||
%% only be called by zx_daemon.
|
||||
|
||||
start_monitor(Target) ->
|
||||
case zx_conn_sup:start_conn(Target) of
|
||||
{ok, Pid} ->
|
||||
Mon = monitor(process, Pid),
|
||||
{ok, Pid, Mon};
|
||||
Error ->
|
||||
Error
|
||||
end.
|
||||
start(Target) ->
|
||||
zx_conn_sup:start_conn(Target).
|
||||
|
||||
|
||||
-spec stop(Conn :: pid()) -> ok.
|
||||
@ -49,16 +42,24 @@ stop(Conn) ->
|
||||
ok.
|
||||
|
||||
|
||||
-spec subscribe(Conn, Realm) -> ok
|
||||
when Conn :: pid(),
|
||||
Realm :: zx:realm(),
|
||||
Result :: ok.
|
||||
-spec subscribe(Conn, Package) -> ok
|
||||
when Conn :: pid(),
|
||||
Package :: zx:package().
|
||||
|
||||
subscribe(Conn, Realm) ->
|
||||
Conn ! {subscribe, Realm},
|
||||
ok.
|
||||
|
||||
|
||||
-spec unsubscribe(Conn, Package) -> ok
|
||||
when Conn :: pid(),
|
||||
Package :: zx:package().
|
||||
|
||||
unsubscribe(Conn, Package) ->
|
||||
Conn ! {unsubscribe, Package},
|
||||
ok.
|
||||
|
||||
|
||||
-spec start_link(Target) ->
|
||||
when Target :: zx:host(),
|
||||
Result :: {ok, pid()}
|
||||
@ -172,6 +173,9 @@ loop(Parent, Debug, Socket) ->
|
||||
ok = handle(Bin, Socket),
|
||||
ok = inet:setopts(Socket, [{active, once}]),
|
||||
loop(Parent, Debug, Socket);
|
||||
{subscribe, Package} ->
|
||||
{unsubscribe, Package} ->
|
||||
|
||||
stop ->
|
||||
ok = zx_net:disconnect(Socket),
|
||||
terminate();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -14,13 +14,12 @@
|
||||
-copyright("Craig Everett <zxq9@zxq9.com>").
|
||||
-license("GPL-3.0").
|
||||
|
||||
|
||||
-export([zomp_home/0, find_zomp_home/0,
|
||||
hosts_cache_file/1, get_prime/1, realm_meta/1,
|
||||
read_project_meta/0, read_project_meta/1, read_package_meta/1,
|
||||
write_project_meta/1, write_project_meta/2,
|
||||
write_terms/2,
|
||||
valid_lower0_9/1, valid_label/1,
|
||||
valid_lower0_9/1, valid_label/1, valid_version/1,
|
||||
string_to_version/1, version_to_string/1,
|
||||
package_id/1, package_string/1,
|
||||
package_dir/1, package_dir/2,
|
||||
@ -139,7 +138,7 @@ read_project_meta(Dir) ->
|
||||
| {error, file:posix()}.
|
||||
|
||||
read_package_meta({Realm, Name, Version}) ->
|
||||
VersionString = Version,
|
||||
{ok, VersionString} = version_to_string(Version),
|
||||
Path = filename:join([zomp_home(), "lib", Realm, Name, VersionString]),
|
||||
read_project_meta(Path).
|
||||
|
||||
@ -250,6 +249,26 @@ valid_label(_, _) ->
|
||||
false.
|
||||
|
||||
|
||||
-spec valid_version(zx:version()) -> boolean().
|
||||
|
||||
valid_version({z, z, z}) ->
|
||||
true;
|
||||
valid_version({X, z, z})
|
||||
when is_integer(X), X >= 0 ->
|
||||
true;
|
||||
valid_version({X, Y, z})
|
||||
when is_integer(X), X >= 0,
|
||||
is_integer(Y), Y >= 0 ->
|
||||
true;
|
||||
valid_version({X, Y, Z})
|
||||
when is_integer(X), X >= 0,
|
||||
is_integer(Y), Y >= 0,
|
||||
is_integer(Z), Z >= 0 ->
|
||||
true;
|
||||
valid_version(_) ->
|
||||
false.
|
||||
|
||||
|
||||
-spec string_to_version(VersionString) -> Result
|
||||
when VersionString :: string(),
|
||||
Result :: {ok, zx:version()}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user