From: Christopher Date: Tue, 17 Mar 2020 23:06:40 +0000 (-0500) Subject: expose replica and quorum X-Git-Url: http://git.entropealabs.com/?a=commitdiff_plain;h=116dabf19efa2c0901922f9bb4b1cd13a8bf98c0;p=wampex_client.git expose replica and quorum --- diff --git a/lib/router.ex b/lib/router.ex index 9736b83..2909839 100644 --- a/lib/router.ex +++ b/lib/router.ex @@ -4,23 +4,30 @@ defmodule Wampex.Router do alias Wampex.Router.{Proxy, REST} alias Wampex.Router.Transports.WebSocket - @spec start_link(name: module(), port: pos_integer(), topologies: []) :: + @spec start_link( + name: module(), + port: pos_integer(), + topologies: [], + replicas: integer(), + quorum: integer() + ) :: {:ok, pid()} | {:error, {:already_started, pid()} | {:shutdown, term()} | term()} - def start_link(name: name, port: port, topologies: topologies) when is_atom(name) do - Supervisor.start_link(__MODULE__, {name, port, topologies}, name: name) + def start_link(name: name, port: port, topologies: topologies, replicas: repls, quorum: quorum) + when is_atom(name) do + Supervisor.start_link(__MODULE__, {name, port, topologies, repls, quorum}, name: name) end - @spec init({module(), pos_integer(), list()}) :: + @spec init({module(), pos_integer(), list(), integer(), integer()}) :: {:ok, {:supervisor.sup_flags(), [:supervisor.child_spec()]}} | :ignore - def init({name, port, topologies}) do + def init({name, port, topologies, replicas, quorum}) do children = [ {ClusterKV, [ name: db_name(name), topologies: topologies, - replicas: 1, - quorum: 1 + replicas: replicas, + quorum: quorum ]}, {Proxy, [name: proxy_name(name)]}, {Plug.Cowboy, scheme: :http, plug: REST, options: [port: port, dispatch: dispatch(name)]} diff --git a/test/wampex_test.exs b/test/wampex_test.exs index 881d88b..77027f0 100644 --- a/test/wampex_test.exs +++ b/test/wampex_test.exs @@ -25,7 +25,17 @@ defmodule WampexTest do setup_all do topologies = Application.get_env(:cluster_kv, :topologies) - [server: Router.start_link(name: TestRouter, port: 4000, topologies: topologies)] + + [ + server: + Router.start_link( + name: TestRouter, + port: 4000, + topologies: topologies, + replicas: 1, + quorum: 1 + ) + ] end @session %Session{url: @url, realm: @realm, roles: @roles}