Skip to content

Commit

Permalink
[pr feedback] added set-metadata method + revisited topic
Browse files Browse the repository at this point in the history
Signed-off-by: danbugs <[email protected]>
  • Loading branch information
danbugs committed Oct 28, 2024
1 parent 49ac282 commit c811951
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ jobs:
- uses: actions/checkout@v2
- uses: WebAssembly/wit-abi-up-to-date@v17
with:
wit-bindgen: '0.30.0'
wit-bindgen: '0.34.0'
worlds: 'imports imports-request-reply messaging-core messaging-request-reply'
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ It would make sense for a lot of these functions to be asynchronous, but that is
the component model. Asynchronous support will be added as part of WASI Preview 3. When async support becomes
available, we plan to update the wasi-messaging interface to incorporate asynchronous patterns.

> **Note**: Ensure you have version 0.30.0 of `wit-bindgen` installed to avoid compatibility issues.
> **Note**: Ensure you have version 0.34.0 of `wit-bindgen` installed to avoid compatibility issues.
21 changes: 12 additions & 9 deletions imports-request-reply.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ This allows the component to perform request/reply messaging patterns.</p>
<h4><a id="constructor_message"></a><code>[constructor]message: func</code></h4>
<h5>Params</h5>
<ul>
<li><a id="constructor_message.topic"></a><a href="#topic"><code>topic</code></a>: <code>string</code></li>
<li><a id="constructor_message.data"></a><code>data</code>: list&lt;<code>u8</code>&gt;</li>
</ul>
<h5>Return values</h5>
Expand All @@ -83,13 +82,6 @@ This allows the component to perform request/reply messaging patterns.</p>
<ul>
<li><a id="method_message_topic.0"></a> <a href="#topic"><a href="#topic"><code>topic</code></a></a></li>
</ul>
<h4><a id="method_message_set_topic"></a><code>[method]message.set-topic: func</code></h4>
<p>Set the topic/subject/channel this message should be sent on</p>
<h5>Params</h5>
<ul>
<li><a id="method_message_set_topic.self"></a><code>self</code>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
<li><a id="method_message_set_topic.topic"></a><a href="#topic"><code>topic</code></a>: <a href="#topic"><a href="#topic"><code>topic</code></a></a></li>
</ul>
<h4><a id="method_message_content_type"></a><code>[method]message.content-type: func</code></h4>
<p>An optional content-type describing the format of the data in the message. This is
sometimes described as the &quot;format&quot; type</p>
Expand Down Expand Up @@ -145,6 +137,13 @@ message</p>
<li><a id="method_message_add_metadata.key"></a><code>key</code>: <code>string</code></li>
<li><a id="method_message_add_metadata.value"></a><code>value</code>: <code>string</code></li>
</ul>
<h4><a id="method_message_set_metadata"></a><code>[method]message.set-metadata: func</code></h4>
<p>Set the metadata</p>
<h5>Params</h5>
<ul>
<li><a id="method_message_set_metadata.self"></a><code>self</code>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
<li><a id="method_message_set_metadata.meta"></a><code>meta</code>: <a href="#metadata"><a href="#metadata"><code>metadata</code></a></a></li>
</ul>
<h4><a id="method_message_remove_metadata"></a><code>[method]message.remove-metadata: func</code></h4>
<p>Remove a key-value pair from the metadata</p>
<h5>Params</h5>
Expand Down Expand Up @@ -216,7 +215,7 @@ return the list of messages received up to that point.</p>
<li><a id="request.0"></a> result&lt;list&lt;own&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;&gt;, <a href="#error"><a href="#error"><code>error</code></a></a>&gt;</li>
</ul>
<h4><a id="reply"></a><code>reply: func</code></h4>
<p>Replies to the given message with the given response message. The details of which channel
<p>Replies to the given message with the given response message. The details of which topic
the message is sent to is up to the implementation. This allows for reply-to details to be
handled in the best way possible for the underlying messaging system.</p>
<p>Please note that this reply functionality is different than something like HTTP because there
Expand Down Expand Up @@ -247,6 +246,9 @@ where the reply is sent and the connection is closed.</p>
#### <a id="error"></a>`type error`
[`error`](#error)
<p>
#### <a id="topic"></a>`type topic`
[`topic`](#topic)
<p>
----
<h3>Functions</h3>
<h4><a id="send"></a><code>send: func</code></h4>
Expand All @@ -255,6 +257,7 @@ where the reply is sent and the connection is closed.</p>
<ul>
<li><a id="send.c"></a><code>c</code>: borrow&lt;<a href="#client"><a href="#client"><code>client</code></a></a>&gt;</li>
<li><a id="send.message"></a><a href="#message"><code>message</code></a>: own&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
<li><a id="send.topic"></a><a href="#topic"><code>topic</code></a>: <a href="#topic"><a href="#topic"><code>topic</code></a></a></li>
</ul>
<h5>Return values</h5>
<ul>
Expand Down
19 changes: 11 additions & 8 deletions imports.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ It includes the <code>producer</code> interface for sending messages.</p>
<h4><a id="constructor_message"></a><code>[constructor]message: func</code></h4>
<h5>Params</h5>
<ul>
<li><a id="constructor_message.topic"></a><a href="#topic"><code>topic</code></a>: <code>string</code></li>
<li><a id="constructor_message.data"></a><code>data</code>: list&lt;<code>u8</code>&gt;</li>
</ul>
<h5>Return values</h5>
Expand All @@ -82,13 +81,6 @@ It includes the <code>producer</code> interface for sending messages.</p>
<ul>
<li><a id="method_message_topic.0"></a> <a href="#topic"><a href="#topic"><code>topic</code></a></a></li>
</ul>
<h4><a id="method_message_set_topic"></a><code>[method]message.set-topic: func</code></h4>
<p>Set the topic/subject/channel this message should be sent on</p>
<h5>Params</h5>
<ul>
<li><a id="method_message_set_topic.self"></a><code>self</code>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
<li><a id="method_message_set_topic.topic"></a><a href="#topic"><code>topic</code></a>: <a href="#topic"><a href="#topic"><code>topic</code></a></a></li>
</ul>
<h4><a id="method_message_content_type"></a><code>[method]message.content-type: func</code></h4>
<p>An optional content-type describing the format of the data in the message. This is
sometimes described as the &quot;format&quot; type</p>
Expand Down Expand Up @@ -144,6 +136,13 @@ message</p>
<li><a id="method_message_add_metadata.key"></a><code>key</code>: <code>string</code></li>
<li><a id="method_message_add_metadata.value"></a><code>value</code>: <code>string</code></li>
</ul>
<h4><a id="method_message_set_metadata"></a><code>[method]message.set-metadata: func</code></h4>
<p>Set the metadata</p>
<h5>Params</h5>
<ul>
<li><a id="method_message_set_metadata.self"></a><code>self</code>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
<li><a id="method_message_set_metadata.meta"></a><code>meta</code>: <a href="#metadata"><a href="#metadata"><code>metadata</code></a></a></li>
</ul>
<h4><a id="method_message_remove_metadata"></a><code>[method]message.remove-metadata: func</code></h4>
<p>Remove a key-value pair from the metadata</p>
<h5>Params</h5>
Expand All @@ -164,6 +163,9 @@ message</p>
#### <a id="error"></a>`type error`
[`error`](#error)
<p>
#### <a id="topic"></a>`type topic`
[`topic`](#topic)
<p>
----
<h3>Functions</h3>
<h4><a id="send"></a><code>send: func</code></h4>
Expand All @@ -172,6 +174,7 @@ message</p>
<ul>
<li><a id="send.c"></a><code>c</code>: borrow&lt;<a href="#client"><a href="#client"><code>client</code></a></a>&gt;</li>
<li><a id="send.message"></a><a href="#message"><code>message</code></a>: own&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
<li><a id="send.topic"></a><a href="#topic"><code>topic</code></a>: <a href="#topic"><a href="#topic"><code>topic</code></a></a></li>
</ul>
<h5>Return values</h5>
<ul>
Expand Down
23 changes: 13 additions & 10 deletions messaging-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ enabling the component to handle incoming messages without request/reply capabil
<h4><a id="constructor_message"></a><code>[constructor]message: func</code></h4>
<h5>Params</h5>
<ul>
<li><a id="constructor_message.topic"></a><a href="#topic"><code>topic</code></a>: <code>string</code></li>
<li><a id="constructor_message.data"></a><code>data</code>: list&lt;<code>u8</code>&gt;</li>
</ul>
<h5>Return values</h5>
Expand All @@ -87,13 +86,6 @@ enabling the component to handle incoming messages without request/reply capabil
<ul>
<li><a id="method_message_topic.0"></a> <a href="#topic"><a href="#topic"><code>topic</code></a></a></li>
</ul>
<h4><a id="method_message_set_topic"></a><code>[method]message.set-topic: func</code></h4>
<p>Set the topic/subject/channel this message should be sent on</p>
<h5>Params</h5>
<ul>
<li><a id="method_message_set_topic.self"></a><code>self</code>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
<li><a id="method_message_set_topic.topic"></a><a href="#topic"><code>topic</code></a>: <a href="#topic"><a href="#topic"><code>topic</code></a></a></li>
</ul>
<h4><a id="method_message_content_type"></a><code>[method]message.content-type: func</code></h4>
<p>An optional content-type describing the format of the data in the message. This is
sometimes described as the &quot;format&quot; type</p>
Expand Down Expand Up @@ -149,6 +141,13 @@ message</p>
<li><a id="method_message_add_metadata.key"></a><code>key</code>: <code>string</code></li>
<li><a id="method_message_add_metadata.value"></a><code>value</code>: <code>string</code></li>
</ul>
<h4><a id="method_message_set_metadata"></a><code>[method]message.set-metadata: func</code></h4>
<p>Set the metadata</p>
<h5>Params</h5>
<ul>
<li><a id="method_message_set_metadata.self"></a><code>self</code>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
<li><a id="method_message_set_metadata.meta"></a><code>meta</code>: <a href="#metadata"><a href="#metadata"><code>metadata</code></a></a></li>
</ul>
<h4><a id="method_message_remove_metadata"></a><code>[method]message.remove-metadata: func</code></h4>
<p>Remove a key-value pair from the metadata</p>
<h5>Params</h5>
Expand All @@ -169,6 +168,9 @@ message</p>
#### <a id="error"></a>`type error`
[`error`](#error)
<p>
#### <a id="topic"></a>`type topic`
[`topic`](#topic)
<p>
----
<h3>Functions</h3>
<h4><a id="send"></a><code>send: func</code></h4>
Expand All @@ -177,6 +179,7 @@ message</p>
<ul>
<li><a id="send.c"></a><code>c</code>: borrow&lt;<a href="#client"><a href="#client"><code>client</code></a></a>&gt;</li>
<li><a id="send.message"></a><a href="#message"><code>message</code></a>: own&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
<li><a id="send.topic"></a><a href="#topic"><code>topic</code></a>: <a href="#topic"><a href="#topic"><code>topic</code></a></a></li>
</ul>
<h5>Return values</h5>
<ul>
Expand All @@ -198,7 +201,7 @@ message</p>
<h3>Functions</h3>
<h4><a id="handle"></a><code>handle: func</code></h4>
<p>Whenever this guest receives a message in one of the subscribed topics, the message is
sent to this handler. The guest is responsible for matching on the channel and handling the
sent to this handler. The guest is responsible for matching on the topic and handling the
message accordingly. Implementors (such as hosts) calling this interface should make their
own decisions on how to handle errors returned from this function.</p>
<h5>Params</h5>
Expand All @@ -211,7 +214,7 @@ own decisions on how to handle errors returned from this function.</p>
</ul>
<h4><a id="get_topics"></a><code>get-topics: func</code></h4>
<p>Returns a list of topics (represented as <code>string</code>s) at runtime the guest should be subscribed
to at runtime. Implementors should consider also allowing subscriptions to be made at compile time
Implementors should consider also allowing subscriptions to be made at compile time
via some sort of configuration file. This function is intended to be called at the start of the
guest's lifecycle before any messages are sent.</p>
<h5>Return values</h5>
Expand Down
25 changes: 14 additions & 11 deletions messaging-request-reply.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ handling incoming messages with request/reply capabilities.</p>
<h4><a id="constructor_message"></a><code>[constructor]message: func</code></h4>
<h5>Params</h5>
<ul>
<li><a id="constructor_message.topic"></a><a href="#topic"><code>topic</code></a>: <code>string</code></li>
<li><a id="constructor_message.data"></a><code>data</code>: list&lt;<code>u8</code>&gt;</li>
</ul>
<h5>Return values</h5>
Expand All @@ -89,13 +88,6 @@ handling incoming messages with request/reply capabilities.</p>
<ul>
<li><a id="method_message_topic.0"></a> <a href="#topic"><a href="#topic"><code>topic</code></a></a></li>
</ul>
<h4><a id="method_message_set_topic"></a><code>[method]message.set-topic: func</code></h4>
<p>Set the topic/subject/channel this message should be sent on</p>
<h5>Params</h5>
<ul>
<li><a id="method_message_set_topic.self"></a><code>self</code>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
<li><a id="method_message_set_topic.topic"></a><a href="#topic"><code>topic</code></a>: <a href="#topic"><a href="#topic"><code>topic</code></a></a></li>
</ul>
<h4><a id="method_message_content_type"></a><code>[method]message.content-type: func</code></h4>
<p>An optional content-type describing the format of the data in the message. This is
sometimes described as the &quot;format&quot; type</p>
Expand Down Expand Up @@ -151,6 +143,13 @@ message</p>
<li><a id="method_message_add_metadata.key"></a><code>key</code>: <code>string</code></li>
<li><a id="method_message_add_metadata.value"></a><code>value</code>: <code>string</code></li>
</ul>
<h4><a id="method_message_set_metadata"></a><code>[method]message.set-metadata: func</code></h4>
<p>Set the metadata</p>
<h5>Params</h5>
<ul>
<li><a id="method_message_set_metadata.self"></a><code>self</code>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
<li><a id="method_message_set_metadata.meta"></a><code>meta</code>: <a href="#metadata"><a href="#metadata"><code>metadata</code></a></a></li>
</ul>
<h4><a id="method_message_remove_metadata"></a><code>[method]message.remove-metadata: func</code></h4>
<p>Remove a key-value pair from the metadata</p>
<h5>Params</h5>
Expand Down Expand Up @@ -222,7 +221,7 @@ return the list of messages received up to that point.</p>
<li><a id="request.0"></a> result&lt;list&lt;own&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;&gt;, <a href="#error"><a href="#error"><code>error</code></a></a>&gt;</li>
</ul>
<h4><a id="reply"></a><code>reply: func</code></h4>
<p>Replies to the given message with the given response message. The details of which channel
<p>Replies to the given message with the given response message. The details of which topic
the message is sent to is up to the implementation. This allows for reply-to details to be
handled in the best way possible for the underlying messaging system.</p>
<p>Please note that this reply functionality is different than something like HTTP because there
Expand Down Expand Up @@ -253,6 +252,9 @@ where the reply is sent and the connection is closed.</p>
#### <a id="error"></a>`type error`
[`error`](#error)
<p>
#### <a id="topic"></a>`type topic`
[`topic`](#topic)
<p>
----
<h3>Functions</h3>
<h4><a id="send"></a><code>send: func</code></h4>
Expand All @@ -261,6 +263,7 @@ where the reply is sent and the connection is closed.</p>
<ul>
<li><a id="send.c"></a><code>c</code>: borrow&lt;<a href="#client"><a href="#client"><code>client</code></a></a>&gt;</li>
<li><a id="send.message"></a><a href="#message"><code>message</code></a>: own&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
<li><a id="send.topic"></a><a href="#topic"><code>topic</code></a>: <a href="#topic"><a href="#topic"><code>topic</code></a></a></li>
</ul>
<h5>Return values</h5>
<ul>
Expand All @@ -282,7 +285,7 @@ where the reply is sent and the connection is closed.</p>
<h3>Functions</h3>
<h4><a id="handle"></a><code>handle: func</code></h4>
<p>Whenever this guest receives a message in one of the subscribed topics, the message is
sent to this handler. The guest is responsible for matching on the channel and handling the
sent to this handler. The guest is responsible for matching on the topic and handling the
message accordingly. Implementors (such as hosts) calling this interface should make their
own decisions on how to handle errors returned from this function.</p>
<h5>Params</h5>
Expand All @@ -295,7 +298,7 @@ own decisions on how to handle errors returned from this function.</p>
</ul>
<h4><a id="get_topics"></a><code>get-topics: func</code></h4>
<p>Returns a list of topics (represented as <code>string</code>s) at runtime the guest should be subscribed
to at runtime. Implementors should consider also allowing subscriptions to be made at compile time
Implementors should consider also allowing subscriptions to be made at compile time
via some sort of configuration file. This function is intended to be called at the start of the
guest's lifecycle before any messages are sent.</p>
<h5>Return values</h5>
Expand Down
4 changes: 2 additions & 2 deletions wit/guest.wit
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ interface incoming-handler {
use types.{message, error, topic};

/// Whenever this guest receives a message in one of the subscribed topics, the message is
/// sent to this handler. The guest is responsible for matching on the channel and handling the
/// sent to this handler. The guest is responsible for matching on the topic and handling the
/// message accordingly. Implementors (such as hosts) calling this interface should make their
/// own decisions on how to handle errors returned from this function.
handle: func(message: message) -> result<_, error>;

// Returns a list of topics (represented as `string`s) at runtime the guest should be subscribed
// to at runtime. Implementors should consider also allowing subscriptions to be made at compile time
// Implementors should consider also allowing subscriptions to be made at compile time
// via some sort of configuration file. This function is intended to be called at the start of the
// guest's lifecycle before any messages are sent.
get-topics: func() -> result<list<topic>, error>;
Expand Down
4 changes: 2 additions & 2 deletions wit/producer.wit
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/// The producer interface is used to send messages to a channel/topic.
interface producer {
use types.{client, message, error};
use types.{client, message, error, topic};

/// Sends the message using the given client.
send: func(c: borrow<client>, message: message) -> result<_, error>;
send: func(c: borrow<client>, message: message, topic: topic) -> result<_, error>;
}
2 changes: 1 addition & 1 deletion wit/request-reply.wit
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface request-reply {
/// return the list of messages received up to that point.
request: func(c: borrow<client>, message: borrow<message>, options: option<request-options>) -> result<list<message>, error>;

/// Replies to the given message with the given response message. The details of which channel
/// Replies to the given message with the given response message. The details of which topic
/// the message is sent to is up to the implementation. This allows for reply-to details to be
/// handled in the best way possible for the underlying messaging system.
///
Expand Down
6 changes: 3 additions & 3 deletions wit/types.wit
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ interface types {

/// A message with a binary payload and additional information
resource message {
constructor(topic: string, data: list<u8>);
constructor(data: list<u8>);
/// The topic/subject/channel this message was received or should be sent on
topic: func() -> topic;
/// Set the topic/subject/channel this message should be sent on
set-topic: func(topic: topic);
/// An optional content-type describing the format of the data in the message. This is
/// sometimes described as the "format" type
content-type: func() -> option<string>;
Expand All @@ -45,6 +43,8 @@ interface types {
metadata: func() -> option<metadata>;
/// Add a new key-value pair to the metadata, overwriting any existing value for the same key
add-metadata: func(key: string, value: string);
/// Set the metadata
set-metadata: func(meta: metadata);
/// Remove a key-value pair from the metadata
remove-metadata: func(key: string);
}
Expand Down

0 comments on commit c811951

Please sign in to comment.