Weddell v0.1.2 Weddell.Client.Subscriber.Stream View Source
A streaming connection to a subscription.
Link to this section Summary
Types
A message and a new deadline in seconds
Option values used when writing to a stream
Options used when writing to a stream
A Pub/Sub subscriber stream
Functions
Close an open stream
Open a new stream on a subscription
Receive messages from a stream
Send a response to a stream
Link to this section Types
Link to this type
message_delay()
View Source
message_delay() :: {Weddell.Message.t(), seconds :: pos_integer()}
A message and a new deadline in seconds
Link to this type
send_opt()
View Source
send_opt() :: {:ack, [Weddell.Message.t()]} | {:delay, [message_delay()]} | {:stream_deadline, seconds :: pos_integer()}
Option values used when writing to a stream
Options used when writing to a stream
A Pub/Sub subscriber stream
Link to this section Functions
Close an open stream.
Example
{:ok, client} = Weddell.Client.connect("weddell-project")
stream = Weddell.Client.Subscriber.Stream.open(client, "foo-subscription")
Weddell.Client.Subscriber.Stream.close(stream)
#=> :ok
Link to this function
open(client, subscription)
View Source
open(Weddell.Client.t(), subscription :: String.t()) :: t()
Open a new stream on a subscription.
Streams can be used to pull new messages from a subscription and also respond with acknowledgements or delays.
Example
{:ok, client} = Weddell.Client.connect("weddell-project")
Weddell.Client.Subscriber.Stream.open(client, "foo-subscription")
#=> %Weddell.Client.Subscriber.Stream{}
Receive messages from a stream.
Example
{:ok, client} = Weddell.Client.connect("weddell-project")
client
|> Weddell.Client.Subscriber.Stream.open("foo-subscription")
|> Weddell.Client.Subscriber.Stream.recv()
|> Enum.take(1)
#=> [%Message{...}]
Send a response to a stream.
Example
{:ok, client} = Weddell.Client.connect("weddell-project")
stream = Weddell.Client.Subscriber.Stream.open(client, "foo-subscription")
Weddell.Client.Subscriber.Stream.send(stream,
ack: [%Message{}],
delay: [{%Message{}, 60}],
stream_deadline: 120)
#=> :ok
Options
ack
- Messages to be acknowledged. (default: [])delay
- Messages to be delayed and the period for which to delay. (default: [])stream_deadline
- The time period to wait before resending a message on this stream. (default: 10)