Przeglądaj źródła

feature(gen_rpc): support a stateless port discovery

terry-xiaoyu 5 lat temu
rodzic
commit
2b603bfd11
3 zmienionych plików z 25 dodań i 3 usunięć
  1. 19 2
      etc/emqx.conf
  2. 5 0
      priv/emqx.schema
  3. 1 1
      rebar.config

+ 19 - 2
etc/emqx.conf

@@ -317,15 +317,32 @@ rpc.mode = async
 ## NOTE: RPC batch won't work when rpc.mode = sync
 ## NOTE: RPC batch won't work when rpc.mode = sync
 rpc.async_batch_size = 256
 rpc.async_batch_size = 256
 
 
+## RPC port discovery
+##
+## The strategy for discovering the RPC listening port of other nodes.
+##
+## Value: Enum
+## - manual: discover ports by `tcp_server_port` and `tcp_client_port`.
+## - stateless: discover ports in a stateless manner.
+##   If node name is `emqx<N>@127.0.0.1`, where the `<N>` is an integer,
+##   then the listening port will be `5370 + <N>`
+##
+## Defaults to `stateless`.
+rpc.port_discovery = stateless
+
 ## TCP server port for RPC.
 ## TCP server port for RPC.
 ##
 ##
+## Only takes effect when `rpc.port_discovery` = `manual`.
+##
 ## Value: Port [1024-65535]
 ## Value: Port [1024-65535]
-rpc.tcp_server_port = 5369
+#rpc.tcp_server_port = 5369
 
 
 ## TCP port for outgoing RPC connections.
 ## TCP port for outgoing RPC connections.
 ##
 ##
+## Only takes effect when `rpc.port_discovery` = `manual`.
+##
 ## Value: Port [1024-65535]
 ## Value: Port [1024-65535]
-rpc.tcp_client_port = 5369
+#rpc.tcp_client_port = 5369
 
 
 ## Number of outgoing RPC connections.
 ## Number of outgoing RPC connections.
 ##
 ##

+ 5 - 0
priv/emqx.schema

@@ -348,6 +348,11 @@ end}.
   {datatype, integer}
   {datatype, integer}
 ]}.
 ]}.
 
 
+{mapping, "rpc.port_discovery", "gen_rpc.port_discovery", [
+  {default, stateless},
+  {datatype, {enum, [manual, stateless]}}
+]}.
+
 %% RPC server port.
 %% RPC server port.
 {mapping, "rpc.tcp_server_port", "gen_rpc.tcp_server_port", [
 {mapping, "rpc.tcp_server_port", "gen_rpc.tcp_server_port", [
   {default, 5369},
   {default, 5369},

+ 1 - 1
rebar.config

@@ -8,7 +8,7 @@
   {cowboy, {git, "https://github.com/emqx/cowboy", {tag, "2.7.1"}}},
   {cowboy, {git, "https://github.com/emqx/cowboy", {tag, "2.7.1"}}},
   {esockd, {git, "https://github.com/emqx/esockd", {tag, "5.7.2"}}},
   {esockd, {git, "https://github.com/emqx/esockd", {tag, "5.7.2"}}},
   {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.7.4"}}},
   {ekka, {git, "https://github.com/emqx/ekka", {tag, "0.7.4"}}},
-  {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.4.1"}}},
+  {gen_rpc, {git, "https://github.com/emqx/gen_rpc", {tag, "2.5.0"}}},
   {cuttlefish, {git, "https://github.com/emqx/cuttlefish", {tag, "v3.0.0"}}}
   {cuttlefish, {git, "https://github.com/emqx/cuttlefish", {tag, "v3.0.0"}}}
  ]}.
  ]}.