From c2a7421ad0aece25d11ab5056a8b98f18bedd64a Mon Sep 17 00:00:00 2001 From: Jiaxiao Zhou Date: Tue, 20 Feb 2024 16:26:42 -0800 Subject: [PATCH] chore(*): split world to imports and re-version to `0.2.0-draft` (#20) this commit splits the existing messaging world into two worlds. 1. imports 2. messaging that includes imports world to follow the convention of other WIT packages in WASI. It also re-versions the wit package to `0.2.0-draft` Signed-off-by: Jiaxiao Zhou (Mossaka) --- .github/workflows/main.yml | 3 +- imports.md | 184 +++++++++++++++++++++++++++++++++++++ messaging.md | 120 ++++++++++++------------ wit/messaging.wit | 7 +- 4 files changed, 251 insertions(+), 63 deletions(-) create mode 100644 imports.md diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9ba6465..a084cc6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,4 +13,5 @@ jobs: - uses: actions/checkout@v2 - uses: WebAssembly/wit-abi-up-to-date@v17 with: - wit-bindgen: '0.16.0' + wit-bindgen: '0.18.0' + worlds: 'imports messaging' diff --git a/imports.md b/imports.md new file mode 100644 index 0000000..cc4b825 --- /dev/null +++ b/imports.md @@ -0,0 +1,184 @@ +

World imports

+ +

Import interface wasi:messaging/messaging-types@0.2.0-draft

+
+

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
+ +

enum format-spec

+

Format specification for messages

+ +
Enum Cases
+ +

record message

+

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

+
Record Fields
+ +
+

Functions

+

[static]client.connect: func

+
Params
+ +
Return values
+ +

[static]error.trace: func

+
Return values
+ +

Import interface wasi:messaging/producer@0.2.0-draft

+
+

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/consumer@0.2.0-draft

+
+

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:

+ +
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:

+ +
Params
+ +
Return values
+ +

abandon-message: func

+
Params
+ +
Return values
+ diff --git a/messaging.md b/messaging.md index a41b1ca..3774be8 100644 --- a/messaging.md +++ b/messaging.md @@ -2,39 +2,39 @@ -

Import interface wasi:messaging/messaging-types@0.1.0

+

Import interface wasi:messaging/messaging-types@0.2.0-draft


Types

-

resource client

+

resource client

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

-

resource error

+

resource error

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

-

type channel

+

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

+

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
-

enum format-spec

+

enum format-spec

Format specification for messages

Enum Cases
-

record message

+

record message

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

Record Fields

Functions

-

[static]client.connect: func

+

[static]client.connect: func

Params
Return values
-

[static]error.trace: func

+

[static]error.trace: func

Return values
-

Import interface wasi:messaging/producer@0.1.0

+

Import interface wasi:messaging/producer@0.2.0-draft


Types

-

type client

+

type client

client

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

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

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

----

Functions

-

send: func

+

send: func

Params
Return values
-

Import interface wasi:messaging/consumer@0.1.0

+

Import interface wasi:messaging/consumer@0.2.0-draft


Types

-

type client

+

type client

client

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

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

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

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

----

Functions

-

subscribe-try-receive: func

+

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

+

subscribe-receive: func

Blocking receive until message with ephemeral subscription

Params
Return values
-

update-guest-configuration: func

+

update-guest-configuration: func

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

Params
Return values
-

complete-message: func

+

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), @@ -172,47 +172,47 @@

Params
Return values
-

abandon-message: func

+

abandon-message: func

Params
Return values
-

Export interface wasi:messaging/messaging-guest@0.1.0

+

Export interface wasi:messaging/messaging-guest@0.2.0-draft


Types

-

type message

+

type message

message

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

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

----

Functions

-

configure: func

+

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

+

handler: func

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

Params
Return values