Weddell v0.1.5 Weddell View Source

Documentation for Weddell.

Link to this section Summary

Types

An RPC error

Functions

Acknowledges messages, removing them from the subscription

Return the client currently connected to Pub/Sub.

Creates a new subscription belonging to the topic and the configured project.

Creates a new topic belonging to the configured project.

Deletes a subscription belonging to the configured project.

Deletes a topic belonging to the configured project.

Publish message or messages to a topic.

Pulls messages from a subscription

Start Weddell and connect to the Pub/Sub server.

List subscription details belonging to the configured project.

List subscriptions belonging to a topic.

List topics belonging to the configured project.

Link to this section Types

An RPC error

Link to this section Functions

Link to this function

acknowledge(messages, subscription)

View Source
acknowledge(
  messages :: [Weddell.Message.t()] | Weddell.Message.t(),
  subscription_name :: String.t()
) :: :ok | error()

Acknowledges messages, removing them from the subscription

Examples

messages = [%Message{}, %Message{}]
Weddell.acknowledge(messages, "foo-subscription")
#=> :ok

Return the client currently connected to Pub/Sub.

Link to this function

create_subscription(name, topic, opts \\ [])

View Source
create_subscription(
  subscription_name :: String.t(),
  topic_name :: String.t(),
  Weddell.Client.subscription_options()
) :: :ok | error()

Creates a new subscription belonging to the topic and the configured project.

Examples

Weddell.create_subscription("foo-subscription", "foo-topic", ack_deadline: 10)
#=> :ok

Options

  • :ack_deadline - The maximum amount of time in seconds after receiving a message before a message expires. If this deadline passes without the message being acked it can be pulled again. If this is a push subscription this configures the timeout for the push to the endpoint. The minimum value is 10 seconds and the max 600 seconds. (default: 10)
  • :push_endpoint - If this option is set messages will be automatically pushed to the specified URL. For example, a Webhook endpoint might use "https://example.com/push". (default: nil)
Link to this function

create_topic(name)

View Source
create_topic(topic_name :: String.t()) :: :ok | error()

Creates a new topic belonging to the configured project.

Examples

Weddell.create_topic("foo")
#=> :ok
Link to this function

delete_subscription(name)

View Source
delete_subscription(subscription_name :: String.t()) :: :ok | error()

Deletes a subscription belonging to the configured project.

Examples

Weddell.delete_subscription("foo")
#=> :ok
Link to this function

delete_topic(name)

View Source
delete_topic(topic_name :: String.t()) :: :ok | error()

Deletes a topic belonging to the configured project.

Examples

Weddell.delete_topic("foo")
#=> :ok
Link to this function

publish(messages, topic)

View Source
publish(
  Weddell.Client.Publisher.new_message()
  | [Weddell.Client.Publisher.new_message()],
  topic_name :: String.t()
) :: :ok | error()

Publish message or messages to a topic.

Examples

### Data only

"message-data"
|> Weddell.publish("foo-topic")
#=> :ok

### Data and attributes

{"message-data", %{"foo" => "bar"}}
|> Weddell.publish("foo-topic")
#=> :ok

### Attributes only

%{"foo" => "bar"}
|> Weddell.publish("foo-topic")
#=> :ok

### A list of messages (data and attributes)

[{"message-data-1", %{"foo" => "bar"}},
 {"message-data-2", %{"foo" => "bar"}}]
|> Weddell.publish("foo-topic")
Link to this function

pull(subscription, opts \\ [])

View Source
pull(subscription_name :: String.t(), Weddell.Client.pull_options()) ::
  {:ok, messages :: [Weddell.Message.t()]} | error()

Pulls messages from a subscription

Examples

Weddell.pull("foo-subscription", return_immediately: true, max_messages: 10)
#=> {:ok, [%Message{}]}

Options

  • :return_immediately - If set to true, pull will return immediately even if there are no messages available to return. Otherwise, pull may wait (for a bounded amount of time) until at least one message is available, rather than returning no messages. (default: true)
  • :max_messages - The maximum number of messages to be returned, it may be fewer. (default: 10)

Start Weddell and connect to the Pub/Sub server.

Link to this function

subscriptions(opts \\ [])

View Source
subscriptions(opts :: Weddell.Client.list_options()) ::
  {:ok, subscriptions :: [Weddell.SubscriptionDetails.t()]}
  | {:ok, subscriptions :: [Weddell.SubscriptionDetails.t()],
     Weddell.Client.cursor()}
  | error()

List subscription details belonging to the configured project.

Examples

Weddell.subscriptions(max: 50)
#=> {:ok, [%SubscriptionDetails{}, %SubscriptionDetails{}, ...]}

When more subscriptions exist:

Weddell.subscriptions(max: 1)
#=> {:ok, [%SubscriptionDetails{}], "list-cursor"}

Options

  • :max - The maximum number of subscriptions to return fromn a single request. If more subscriptions exist make another call using the returned cursor. (default: 50)
  • :cursor - List subscriptions starting at a cursor returned by an earlier call. (default: nil)
Link to this function

topic_subscriptions(topic, opts \\ [])

View Source
topic_subscriptions(topic :: String.t(), opts :: Weddell.Client.list_options()) ::
  {:ok, subscriptions :: [String.t()]}
  | {:ok, subscriptions :: [String.t()], Weddell.Client.cursor()}
  | error()

List subscriptions belonging to a topic.

Examples

Weddell.topic_subscriptions("foo-topic", max: 50)
#=> {:ok, ["foo-subscription", "bar-subscription", ...]}

When more subscriptions exist:

Weddell.topic_subscriptions("foo-topic", max: 1)
#=> {:ok, ["foo-subscription"], "list-cursor"}

Options

  • :max - The maximum number of subscriptions to return fromn a single request. If more subscriptions exist make another call using the returned cursor. (default: 50)
  • :cursor - List subscriptions starting at a cursor returned by an earlier call. (default: nil)
Link to this function

topics(opts \\ [])

View Source
topics(opts :: Weddell.Client.list_options()) ::
  {:ok, topic_names :: [String.t()]}
  | {:ok, topic_names :: [String.t()], Weddell.Client.cursor()}
  | error()

List topics belonging to the configured project.

Examples

Weddell.topics(max: 50)
#=> {:ok, ["foo", "bar", ...]}

When more topics exist:

Weddell.topics(max: 1)
#=> {:ok, ["foo"], "list-cursor"}

Options

  • :max - The maximum number of topics to return fromn a single request. If more topics exist make another call using the returned cursor. (default: 50)
  • :cursor - List topics starting at a cursor returned by an earlier call. (default: nil)