Weddell v0.1.5 Weddell View Source
Documentation for Weddell.
Link to this section Summary
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
acknowledge(messages, subscription)
View Sourceacknowledge( 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.
create_subscription(name, topic, opts \\ [])
View Sourcecreate_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)
Creates a new topic belonging to the configured project.
Examples
Weddell.create_topic("foo")
#=> :ok
Deletes a subscription belonging to the configured project.
Examples
Weddell.delete_subscription("foo")
#=> :ok
Deletes a topic belonging to the configured project.
Examples
Weddell.delete_topic("foo")
#=> :ok
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")
pull(subscription, opts \\ [])
View Sourcepull(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.
subscriptions(opts \\ [])
View Sourcesubscriptions(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)
topic_subscriptions(topic, opts \\ [])
View Sourcetopic_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)
topics(opts \\ [])
View Sourcetopics(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)