Alternera.Plugins.AnypointMq.Wire (alternera_plugin_anypoint_mq v0.9.0)

Copy Markdown View Source

What the Anypoint MQ step (AnypointMq.Broker) and the Anypoint MQ source (AnypointMq.Source) share about the broker's REST API: the broker URL's check, a path segment's encoding and limit, the token of the tenant's auth profile for a call (Plugin.Provisional.Credentials), and reading and decoding the broker's answers.

Summary

Functions

A received message's body as text: the JSON of one the broker sent as a value.

url as a broker URL: http or https, a host, no query or fragment, without a trailing /; {:error, message} otherwise.

An answer's text as JSON: {:ok, nil} when empty, {:error, message} (a fragment after "the broker's answer to …") when it is not JSON.

value as one URL path segment.

An integer, or one written as text; nil otherwise.

The longest a value that goes into the URL as one path segment may be, in bytes.

An answer's body read whole and released.

The most bytes of a receive's answer a call reads (Outbound.call/3's cap), whatever the batch: room for one of the broker's largest messages, escaped, about 30 MiB, more than the 16 MiB default (Outbound.max_response_bytes/0). A batch whose answer is larger fails response_too_large: a source trigger then asks for fewer messages, a consume step's author lowers its batch_size. Sized for the batch instead, ten messages would be read whole at about 300 MiB.

Whether a received entry can be settled: an object whose headers carry its messageId and its lockId.

The start of an answer's text for a message, after a :; empty when there is none.

A map's keys as text; an empty map for anything else.

The Authorization value of the tenant's auth profile for a call to url (Credentials.for_call/3), renew the value a first call was answered 401 with (nil for a first call): {:ok, value, outbound_us}, or {:error, message, outbound_us} naming what to set up.

Functions

body_text(body)

@spec body_text(term()) :: binary()

A received message's body as text: the JSON of one the broker sent as a value.

check_url(url)

@spec check_url(String.t()) :: {:ok, String.t()} | {:error, String.t()}

url as a broker URL: http or https, a host, no query or fragment, without a trailing /; {:error, message} otherwise.

decode(body)

@spec decode(binary()) :: {:ok, term()} | {:error, String.t()}

An answer's text as JSON: {:ok, nil} when empty, {:error, message} (a fragment after "the broker's answer to …") when it is not JSON.

encode(value)

@spec encode(String.t()) :: String.t()

value as one URL path segment.

integer(value)

@spec integer(term()) :: integer() | nil

An integer, or one written as text; nil otherwise.

max_segment()

@spec max_segment() :: pos_integer()

The longest a value that goes into the URL as one path segment may be, in bytes.

read_body(body)

@spec read_body(term()) :: binary()

An answer's body read whole and released.

receive_cap()

@spec receive_cap() :: pos_integer()

The most bytes of a receive's answer a call reads (Outbound.call/3's cap), whatever the batch: room for one of the broker's largest messages, escaped, about 30 MiB, more than the 16 MiB default (Outbound.max_response_bytes/0). A batch whose answer is larger fails response_too_large: a source trigger then asks for fewer messages, a consume step's author lowers its batch_size. Sized for the batch instead, ten messages would be read whole at about 300 MiB.

settleable?(arg1)

@spec settleable?(term()) :: boolean()

Whether a received entry can be settled: an object whose headers carry its messageId and its lockId.

shown(body)

@spec shown(term()) :: String.t()

The start of an answer's text for a message, after a :; empty when there is none.

stringy(map)

@spec stringy(term()) :: map()

A map's keys as text; an empty map for anything else.

token(context, url, renew)

@spec token(map(), String.t(), String.t() | nil) ::
  {:ok, String.t(), non_neg_integer()} | {:error, String.t(), non_neg_integer()}

The Authorization value of the tenant's auth profile for a call to url (Credentials.for_call/3), renew the value a first call was answered 401 with (nil for a first call): {:ok, value, outbound_us}, or {:error, message, outbound_us} naming what to set up.