Rambling 'slf/doc-cluster-terminology' branch #58
3 changed files with 23 additions and 14 deletions
|
@ -129,7 +129,8 @@ main2(FluName, TcpPort, DataDir, Props) ->
|
|||
ok
|
||||
end,
|
||||
{ok, ListenerPid} = start_listen_server(FluName, TcpPort, Witness_p, DataDir,
|
||||
ets_table_name(FluName), ProjectionPid),
|
||||
ets_table_name(FluName), ProjectionPid,
|
||||
Props),
|
||||
%% io:format(user, "Listener started: ~w~n", [{FluName, ListenerPid}]),
|
||||
|
||||
Config_e = machi_util:make_config_filename(DataDir, "unused"),
|
||||
|
@ -154,9 +155,10 @@ main2(FluName, TcpPort, DataDir, Props) ->
|
|||
start_append_server(FluName, Witness_p, Wedged_p, EpochId) ->
|
||||
machi_flu1_subsup:start_append_server(FluName, Witness_p, Wedged_p, EpochId).
|
||||
|
||||
start_listen_server(FluName, TcpPort, Witness_p, DataDir, EtsTab, ProjectionPid) ->
|
||||
start_listen_server(FluName, TcpPort, Witness_p, DataDir, EtsTab, ProjectionPid,
|
||||
Props) ->
|
||||
machi_flu1_subsup:start_listener(FluName, TcpPort, Witness_p, DataDir,
|
||||
EtsTab, ProjectionPid).
|
||||
EtsTab, ProjectionPid, Props).
|
||||
|
||||
%% This is the name of the projection store that is spawned by the
|
||||
%% *flu*, for use primarily in testing scenarios. In normal use, we
|
||||
|
|
|
@ -69,20 +69,22 @@
|
|||
%% Clustering: cluster map version number
|
||||
namespace_version = 0 :: machi_dt:namespace_version(),
|
||||
%% Clustering: my (and my chain's) assignment to a specific namespace
|
||||
namespace = <<"">> :: machi_dt:namespace(),
|
||||
namespace = <<>> :: machi_dt:namespace(),
|
||||
|
||||
%% High mode only
|
||||
high_clnt :: pid(),
|
||||
|
||||
%% anything you want
|
||||
props = [] :: list() % proplist
|
||||
props = [] :: proplists:proplist()
|
||||
}).
|
||||
|
||||
-type socket() :: any().
|
||||
-type state() :: #state{}.
|
||||
|
||||
-spec start_link(ranch:ref(), socket(), module(), [term()]) -> {ok, pid()}.
|
||||
start_link(Ref, Socket, Transport, [FluName, Witness, DataDir, EpochTab, ProjStore]) ->
|
||||
start_link(Ref, Socket, Transport, [FluName, Witness, DataDir, EpochTab, ProjStore, Props]) ->
|
||||
NS = proplists:get_value(namespace, Props, <<>>),
|
||||
true = is_binary(NS),
|
||||
proc_lib:start_link(?MODULE, init, [#state{ref=Ref,
|
||||
socket=Socket,
|
||||
transport=Transport,
|
||||
|
@ -90,7 +92,9 @@ start_link(Ref, Socket, Transport, [FluName, Witness, DataDir, EpochTab, ProjSto
|
|||
witness=Witness,
|
||||
data_dir=DataDir,
|
||||
epoch_tab=EpochTab,
|
||||
proj_store=ProjStore}]).
|
||||
proj_store=ProjStore,
|
||||
namespace=NS,
|
||||
props=Props}]).
|
||||
|
||||
-spec init(state()) -> no_return().
|
||||
init(#state{ref=Ref, socket=Socket, transport=Transport}=State) ->
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
-export([start_link/1,
|
||||
start_append_server/4,
|
||||
stop_append_server/1,
|
||||
start_listener/6,
|
||||
start_listener/7,
|
||||
stop_listener/1,
|
||||
subsup_name/1,
|
||||
listener_name/1]).
|
||||
|
@ -67,11 +67,13 @@ stop_append_server(FluName) ->
|
|||
ok = supervisor:delete_child(SubSup, FluName).
|
||||
|
||||
-spec start_listener(pv1_server(), inet:port_number(), boolean(),
|
||||
string(), ets:tab(), atom() | pid()) -> {ok, pid()}.
|
||||
start_listener(FluName, TcpPort, Witness, DataDir, EpochTab, ProjStore) ->
|
||||
string(), ets:tab(), atom() | pid(),
|
||||
proplists:proplist()) -> {ok, pid()}.
|
||||
start_listener(FluName, TcpPort, Witness, DataDir, EpochTab, ProjStore,
|
||||
Props) ->
|
||||
supervisor:start_child(subsup_name(FluName),
|
||||
listener_spec(FluName, TcpPort, Witness, DataDir,
|
||||
EpochTab, ProjStore)).
|
||||
EpochTab, ProjStore, Props)).
|
||||
|
||||
-spec stop_listener(pv1_server()) -> ok.
|
||||
stop_listener(FluName) ->
|
||||
|
@ -97,12 +99,13 @@ init([]) ->
|
|||
%% private
|
||||
|
||||
-spec listener_spec(pv1_server(), inet:port_number(), boolean(),
|
||||
string(), ets:tab(), atom() | pid()) -> supervisor:child_spec().
|
||||
listener_spec(FluName, TcpPort, Witness, DataDir, EpochTab, ProjStore) ->
|
||||
string(), ets:tab(), atom() | pid(),
|
||||
proplists:proplist()) -> supervisor:child_spec().
|
||||
listener_spec(FluName, TcpPort, Witness, DataDir, EpochTab, ProjStore, Props) ->
|
||||
ListenerName = listener_name(FluName),
|
||||
NbAcceptors = 10,
|
||||
TcpOpts = [{port, TcpPort}, {backlog, ?BACKLOG}],
|
||||
NetServerOpts = [FluName, Witness, DataDir, EpochTab, ProjStore],
|
||||
NetServerOpts = [FluName, Witness, DataDir, EpochTab, ProjStore, Props],
|
||||
ranch:child_spec(ListenerName, NbAcceptors,
|
||||
ranch_tcp, TcpOpts,
|
||||
machi_flu1_net_server, NetServerOpts).
|
||||
|
|
Loading…
Reference in a new issue