kane v0.0.5 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)

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

Types

t :: %Kane.Topic{name: binary}

Functions

all()

Specs

all :: {:ok, [t]} | Kane.Client.Response.Error.t

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(topic)

Specs

create(t | String.t) ::
  {:ok, t} |
  {:error, :already_exists} |
  Kane.Client.Response.Error.t

Create a new topic in the API

delete(topic)

Specs

delete(t | String.t) ::
  {:ok, String.t, non_neg_integer} |
  Kane.Client.Response.Error.t
find(name)

Specs

find(String.t) ::
  {:ok, t} |
  Kane.Client.Response.Error.t

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)

full_name(topic)

Specs

full_name(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"})
"projects/my-project/topics/my-topic"
strip!(name)

Specs

strip!(String.t) :: String.t

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

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