Pulsar.ServiceDiscovery (Pulsar v2.10.1)

Copy Markdown View Source

This module handles topic lookup operations that discover which broker owns a particular topic. The lookup process may involve following redirects across multiple brokers in a cluster before finding the authoritative broker for a topic.

Example

{:ok, broker_pid} = Pulsar.ServiceDiscovery.lookup_topic("persistent://public/default/my-topic")

Summary

Functions

lookup_topic(topic, opts \\ [])

@spec lookup_topic(
  String.t(),
  keyword()
) :: {:ok, pid()} | {:error, any()}

partition_count(topic, opts \\ [])

@spec partition_count(
  String.t(),
  keyword()
) :: {:ok, non_neg_integer()} | {:error, term()}

Returns the number of partitions for topic.

Performs a single partitioned-topic-metadata lookup against a random broker. Returns {:ok, partitions} where partitions is 0 for a non-partitioned topic, or {:error, reason} if the lookup failed.