ack v0.3.1 Ack View Source

Ack is a tiny application that might be used as drop-in to handle acknowledgments between processes.

When App1 sends something to App2 it might require the acknowledgement back confirming the successful processing of this something. For instance, App1 might call an API endpoint of App2, which triggers a long process, or it might place a message into RabbitMQ and expect to receive an ack to perform some cleanup, or whatever.

In this scenario, App1 might instruct Ack to listen for the ack from App2 for a message

  • %{key: key, timeout: msecs}

where key is the unique identifier of the message to be acknowledged. Upon receival, if the key is known to the system, Ack will broadcast the message of the following shape

  • %{status: :ack, key: key}

to :ack channel. App1 should be subscribed to {Ack.Horn, :ack} channel in order to receive this message.

If the key is unknown to the system, on of the following possible messages

  • %{status: :nack, key: key}, when the key was explicitly not acked
  • %{status: :invalid, key: key}, when the key is not known to the system
  • %{status: :unknown, key: key, value: value}, when somewhat unexpected happened

The former one os routed to {Ack.Horn, :nack} channel, the last two are broadcasted to {Ack.Horn, :error} channel.

The broadcast is done with Envío package, consider reading the documentation there to get more details about subscriptions.

Currently only HTTP endpoint is supported for ack callbacks.

Link to this section Summary

Functions

Adds a listener for the key with a timeout specified (defaults to 5 sec.)

Link to this section Types

Link to this type

t()

View Source
t() :: %{key: String.t(), timeout: timeout()}

Link to this section Functions

Link to this function

listen(params)

View Source
listen(t()) :: :ok | {:error, term()}

Adds a listener for the key with a timeout specified (defaults to 5 sec.)