kane v1.0.0 Kane.Topic

A Kane.Topic is used to interact with and create a topic within the Pub/Sub API.

Setting up and pulling from a subscription is straightforward:

# for the most part, names can be include the project prefix or not
{:ok, subscription} = Kane.Subscription{topic: %Kane.Topic{name: "my-topic"}}
{:ok, messages} = Kane.Subscription.pull(subscription)
Enum.each messages, fn(mess)->
  process_message(mess)
end

# acknowledge message receipt in bulk
Kane.Subscription.ack(subscription, messages)

Link to this section Summary

Functions

Retrieve all the topics from the API. NOTE: Subscription.all/0 doesn't currently support pagination, so if you have more than 100 topics, you won't be able to retrieve all of them

Create a new topic in the API

Find a topic by name. The name can be either a short name (my-topic) or the fully-qualified name (projects/my-project/topics/my-topic)

Adds the project and topic prefix (if necessary) to create a fully-qualified topic name

Strips the project and topic prefix from a fully qualified topic name

Link to this section Types

Link to this type

t()
t() :: %Kane.Topic{name: String.t()}

Link to this section Functions

Link to this function

all(kane)
all(Kane.t()) :: {:ok, [t()]} | Kane.Client.error()

Retrieve all the topics from the API. NOTE: Subscription.all/0 doesn't currently support pagination, so if you have more than 100 topics, you won't be able to retrieve all of them.

Link to this function

create(kane, topic_name)
create(Kane.t(), topic :: t() | String.t()) ::
  {:ok, t()} | {:error, :already_exists} | Kane.Client.error()

Create a new topic in the API.

Link to this function

delete(kane, topic_name)
delete(Kane.t(), topic :: t() | String.t()) ::
  Kane.Client.success() | Kane.Client.error()

Link to this function

find(kane, topic_name)
find(Kane.t(), project_id :: String.t()) :: {:ok, t()} | Kane.Client.error()

Find a topic by name. The name can be either a short name (my-topic) or the fully-qualified name (projects/my-project/topics/my-topic)

Link to this function

full_name(topic_name, project_id)
full_name(t(), project_id :: String.t()) :: String.t()

Adds the project and topic prefix (if necessary) to create a fully-qualified topic name

iex> Kane.Topic.full_name(%Kane.Topic{name: "my-topic"}, "my-project")
"projects/my-project/topics/my-topic"
Link to this function

strip!(project_id, topic_name)
strip!(project_id :: String.t(), topic_name :: String.t()) :: String.t()

Strips the project and topic prefix from a fully qualified topic name

iex> Kane.Topic.strip!("my-project", "projects/my-project/topics/my-topic")
"my-topic"