Skip to content

Latest commit

 

History

History
220 lines (220 loc) · 10.4 KB

messaging.md

File metadata and controls

220 lines (220 loc) · 10.4 KB

Import interface wasi:messaging/[email protected]


Types

resource client

A connection to a message-exchange service (e.g., buffer, broker, etc.).

resource error

TODO(danbugs): This should be eventually extracted as an underlying type for other wasi-cloud-core interfaces.

type channel

string

There are two types of channels: - publish-subscribe channel, which is a broadcast channel, and - point-to-point channel, which is a unicast channel.

The interface doesn't highlight this difference in the type itself as that's uniquely a consumer issue.

record guest-configuration

Configuration includes a required list of channels the guest is subscribing to, and an optional list of extensions key-value pairs (e.g., partitions/offsets to read from in Kafka/EventHubs, QoS etc.).

Record Fields
  • channels: list<channel>
  • extensions: option<list<(string, string)>>

enum format-spec

Format specification for messages

Enum Cases
  • cloudevents
  • http
  • amqp
  • mqtt
  • kafka
  • raw

record message

A message with a binary payload, a format specification, and decorative metadata.

Record Fields
  • data: list<u8>
  • format: format-spec
  • metadata: option<list<(string, string)>>

Functions

[static]client.connect: func

Params
  • name: string
Return values

[static]error.trace: func

Return values
  • string

Import interface wasi:messaging/[email protected]


Types

type client

client

#### `type channel` [`channel`](#channel)

#### `type message` [`message`](#message)

#### `type error` [`error`](#error)

----

Functions

send: func

Params
Return values

Import interface wasi:messaging/[email protected]


Types

type client

client

#### `type message` [`message`](#message)

#### `type channel` [`channel`](#channel)

#### `type error` [`error`](#error)

#### `type guest-configuration` [`guest-configuration`](#guest_configuration)

----

Functions

subscribe-try-receive: func

Blocking receive for t-milliseconds with ephemeral subscription – if no message is received, returns None

Params
Return values

subscribe-receive: func

Blocking receive until message with ephemeral subscription

Params
Return values

update-guest-configuration: func

'Fit-all' type function for updating a guest's configuration – this could be useful for:

  • unsubscribing from a channel,
  • checkpointing,
  • etc..
Params
Return values

complete-message: func

A message can exist under several statuses: (1) available: the message is ready to be read, (2) acquired: the message has been sent to a consumer (but still exists in the queue), (3) accepted (result of complete-message): the message has been received and ACK-ed by a consumer and can be safely removed from the queue, (4) rejected (result of abandon-message): the message has been received and NACK-ed by a consumer, at which point it can be:

  • deleted,
  • sent to a dead-letter queue, or
  • kept in the queue for further processing.
Params
Return values

abandon-message: func

Params
Return values

Export interface wasi:messaging/[email protected]


Types

type message

message

#### `type guest-configuration` [`guest-configuration`](#guest_configuration)

#### `type error` [`error`](#error)

----

Functions

configure: func

Returns the list of channels (and extension metadata within guest-configuration) that this component should subscribe to and be handled by the subsequent handler within guest-configuration

Return values

handler: func

Whenever this guest receives a message in one of the subscribed channels, the message is sent to this handler

Params
Return values