Weddell v0.1.5 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

t()

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

Link to this type

send_opts()

View Source
send_opts() :: [send_opt()]

Options used when writing to a stream

A Pub/Sub subscriber stream

Link to this section Functions

Link to this function

close(stream)

View Source
close(t()) :: :ok

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

expected_error?(message)

View Source
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{}
Link to this function

recv(stream)

View Source
recv(stream :: t()) :: Enumerable.t()

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{...}]
Link to this function

send(stream, opts \\ [])

View Source
send(stream :: t(), send_opts()) :: :ok

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)