View Source ExRocketmq.Namesrvs (lib_oss v0.1.0)

The namesrvs layer of the rocketmq: how client communicates with the namesrvs. Most time, you should start nameserver under the supervision tree of your application.

EG:


    Supervisor.start_link(
      [
        {Namesrvs,
         remotes: [
           [transport: Transport.Tcp.new(host: "test.rocket-mq.net", port: 31_120)]
         ],
         opts: [
           name: :namesrvs
         ]},
      ],
      strategy: :one_for_one
    )

Your consumer or producer module can communicate with namesrvs by its name

Summary

Functions

Returns a specification to start this module under a supervisor.

get the broker cluster info from the namesrvs

Callback implementation for GenServer.init/1.

query the topic route info from the namesrvs

Types

Link to this type

namesrvs_opts_schema_t()

View Source
@type namesrvs_opts_schema_t() :: [remotes: [keyword()], opts: keyword()]

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

get_broker_cluster_info(namesrvs)

View Source

get the broker cluster info from the namesrvs

Examples

iex> ExRocketmq.Namesrvs.get_broker_cluster_info(namesrvs)
{:ok,
  %ExRocketmq.Models.BrokerClusterInfo{
    broker_addr_table: %{
      "sts-broker-d2-0" => %ExRocketmq.Models.BrokerData{
        broker_addrs: %{"0" => "10.88.4.57:20911", "1" => "10.88.4.189:20911"},
        broker_name: "sts-broker-d2-0",
        cluster: "d2"
      }
    },
    cluster_addr_table: %{"d2" => ["sts-broker-d2-0"]}
}}

Callback implementation for GenServer.init/1.

Link to this function

query_topic_route_info(namesrvs, topic)

View Source
@spec query_topic_route_info(namesrvs :: pid() | atom(), topic :: String.t()) ::
  ExRocketmq.Typespecs.ok_t(ExRocketmq.Models.TopicRouteInfo.t())
  | ExRocketmq.Typespecs.error_t()

query the topic route info from the namesrvs

Examples

iex> ExRocketmq.Namesrvs.query_topic_route_info(namesrvs, "topic")
{:ok,
 %ExRocketmq.Models.TopicRouteInfo{
   broker_datas: [
     %ExRocketmq.Models.BrokerData{
       broker_addrs: %{"0" => "10.88.4.78:20911", "2" => "10.88.4.144:20911"},
       broker_name: "sts-broker-d2-0",
       cluster: "d2"
     }
   ],
   queue_datas: [
     %ExRocketmq.Models.QueueData{
       broker_name: "sts-broker-d2-0",
       perm: 6,
       read_queue_nums: 2,
       topic_syn_flag: 0,
       write_queue_nums: 2
     }
   ]
 }}
@spec stop(pid() | atom()) :: :ok