Skip to content

Commit

Permalink
addressing first round of feedback: added type aliases, added remove-…
Browse files Browse the repository at this point in the history
…metadata method, added new-line at the end of files, improved argument names, removed .gitignore, improved documentation, changed get-subscriptions function name

Signed-off-by: danbugs <[email protected]>
  • Loading branch information
danbugs committed Oct 4, 2024
1 parent 6a4af1b commit 49ac282
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 62 deletions.
2 changes: 0 additions & 2 deletions .gitignore

This file was deleted.

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.30.0 of `wit-bindgen` installed to avoid compatibility issues.
31 changes: 23 additions & 8 deletions imports-request-reply.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<h1><a id="imports_request_reply"></a>World imports-request-reply</h1>
<p>The <a href="#imports_request_reply"><code>imports-request-reply</code></a> world extends <code>imports</code> by including the <code>request-reply</code> interface.
This allows the component to perform request/reply messaging patterns.</p>
<ul>
<li>Imports:
<ul>
Expand All @@ -11,6 +13,12 @@
<h2><a id="wasi_messaging_types_0_2_0_draft"></a>Import interface wasi:messaging/[email protected]</h2>
<hr />
<h3>Types</h3>
<h4><a id="metadata"></a><code>type metadata</code></h4>
<p><a href="#metadata"><a href="#metadata"><code>metadata</code></a></a></p>
<p>A type alias for list<tuple<string, string>> to represent metadata attached to a message
<h4><a id="topic"></a><code>type topic</code></h4>
<p><code>string</code></p>
<p>A type alias for string to represent a message topic
<h4><a id="client"></a><code>resource client</code></h4>
<p>A connection to a message-exchange service (e.g., buffer, broker, etc.).</p>
<h4><a id="error"></a><code>variant error</code></h4>
Expand Down Expand Up @@ -58,7 +66,7 @@
<h4><a id="constructor_message"></a><code>[constructor]message: func</code></h4>
<h5>Params</h5>
<ul>
<li><a id="constructor_message.topic"></a><code>topic</code>: <code>string</code></li>
<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 @@ -73,14 +81,14 @@
</ul>
<h5>Return values</h5>
<ul>
<li><a id="method_message_topic.0"></a> <code>string</code></li>
<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><code>topic</code>: <code>string</code></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
Expand Down Expand Up @@ -127,7 +135,7 @@ message</p>
</ul>
<h5>Return values</h5>
<ul>
<li><a id="method_message_metadata.0"></a> option&lt;list&lt;(<code>string</code>, <code>string</code>)&gt;&gt;</li>
<li><a id="method_message_metadata.0"></a> option&lt;<a href="#metadata"><a href="#metadata"><code>metadata</code></a></a>&gt;</li>
</ul>
<h4><a id="method_message_add_metadata"></a><code>[method]message.add-metadata: func</code></h4>
<p>Add a new key-value pair to the metadata, overwriting any existing value for the same key</p>
Expand All @@ -137,6 +145,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_remove_metadata"></a><code>[method]message.remove-metadata: func</code></h4>
<p>Remove a key-value pair from the metadata</p>
<h5>Params</h5>
<ul>
<li><a id="method_message_remove_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_remove_metadata.key"></a><code>key</code>: <code>string</code></li>
</ul>
<h2><a id="wasi_messaging_request_reply_0_2_0_draft"></a>Import interface wasi:messaging/[email protected]</h2>
<p>The request-reply interface allows a guest to send a message and await a response. This
interface is considered optional as not all message services support the concept of
Expand Down Expand Up @@ -193,8 +208,8 @@ return the list of messages received up to that point.</p>
<h5>Params</h5>
<ul>
<li><a id="request.c"></a><code>c</code>: borrow&lt;<a href="#client"><a href="#client"><code>client</code></a></a>&gt;</li>
<li><a id="request.msg"></a><code>msg</code>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
<li><a id="request.opts"></a><code>opts</code>: option&lt;own&lt;<a href="#request_options"><a href="#request_options"><code>request-options</code></a></a>&gt;&gt;</li>
<li><a id="request.message"></a><a href="#message"><code>message</code></a>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
<li><a id="request.options"></a><code>options</code>: option&lt;own&lt;<a href="#request_options"><a href="#request_options"><code>request-options</code></a></a>&gt;&gt;</li>
</ul>
<h5>Return values</h5>
<ul>
Expand All @@ -213,7 +228,7 @@ where the reply is sent and the connection is closed.</p>
<h5>Params</h5>
<ul>
<li><a id="reply.reply_to"></a><code>reply-to</code>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
<li><a id="reply.reply"></a><a href="#reply"><code>reply</code></a>: own&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
<li><a id="reply.message"></a><a href="#message"><code>message</code></a>: own&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
</ul>
<h5>Return values</h5>
<ul>
Expand All @@ -239,7 +254,7 @@ where the reply is sent and the connection is closed.</p>
<h5>Params</h5>
<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.m"></a><code>m</code>: own&lt;<a href="#message"><a href="#message"><code>message</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>
</ul>
<h5>Return values</h5>
<ul>
Expand Down
25 changes: 20 additions & 5 deletions imports.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<h1><a id="imports"></a>World imports</h1>
<p>The <a href="#imports"><code>imports</code></a> world defines the interfaces that the component will import from the host.
It includes the <code>producer</code> interface for sending messages.</p>
<ul>
<li>Imports:
<ul>
Expand All @@ -10,6 +12,12 @@
<h2><a id="wasi_messaging_types_0_2_0_draft"></a>Import interface wasi:messaging/[email protected]</h2>
<hr />
<h3>Types</h3>
<h4><a id="metadata"></a><code>type metadata</code></h4>
<p><a href="#metadata"><a href="#metadata"><code>metadata</code></a></a></p>
<p>A type alias for list<tuple<string, string>> to represent metadata attached to a message
<h4><a id="topic"></a><code>type topic</code></h4>
<p><code>string</code></p>
<p>A type alias for string to represent a message topic
<h4><a id="client"></a><code>resource client</code></h4>
<p>A connection to a message-exchange service (e.g., buffer, broker, etc.).</p>
<h4><a id="error"></a><code>variant error</code></h4>
Expand Down Expand Up @@ -57,7 +65,7 @@
<h4><a id="constructor_message"></a><code>[constructor]message: func</code></h4>
<h5>Params</h5>
<ul>
<li><a id="constructor_message.topic"></a><code>topic</code>: <code>string</code></li>
<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 @@ -72,14 +80,14 @@
</ul>
<h5>Return values</h5>
<ul>
<li><a id="method_message_topic.0"></a> <code>string</code></li>
<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><code>topic</code>: <code>string</code></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
Expand Down Expand Up @@ -126,7 +134,7 @@ message</p>
</ul>
<h5>Return values</h5>
<ul>
<li><a id="method_message_metadata.0"></a> option&lt;list&lt;(<code>string</code>, <code>string</code>)&gt;&gt;</li>
<li><a id="method_message_metadata.0"></a> option&lt;<a href="#metadata"><a href="#metadata"><code>metadata</code></a></a>&gt;</li>
</ul>
<h4><a id="method_message_add_metadata"></a><code>[method]message.add-metadata: func</code></h4>
<p>Add a new key-value pair to the metadata, overwriting any existing value for the same key</p>
Expand All @@ -136,6 +144,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_remove_metadata"></a><code>[method]message.remove-metadata: func</code></h4>
<p>Remove a key-value pair from the metadata</p>
<h5>Params</h5>
<ul>
<li><a id="method_message_remove_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_remove_metadata.key"></a><code>key</code>: <code>string</code></li>
</ul>
<h2><a id="wasi_messaging_producer_0_2_0_draft"></a>Import interface wasi:messaging/[email protected]</h2>
<p>The producer interface is used to send messages to a channel/topic.</p>
<hr />
Expand All @@ -156,7 +171,7 @@ message</p>
<h5>Params</h5>
<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.m"></a><code>m</code>: own&lt;<a href="#message"><a href="#message"><code>message</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>
</ul>
<h5>Return values</h5>
<ul>
Expand Down
40 changes: 29 additions & 11 deletions messaging-core.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<h1><a id="messaging_core"></a>World messaging-core</h1>
<p>The <a href="#messaging_core"><code>messaging-core</code></a> world includes the basic <code>imports</code> and exports the <code>incoming-handler</code>,
enabling the component to handle incoming messages without request/reply capabilities.</p>
<ul>
<li>Imports:
<ul>
Expand All @@ -15,6 +17,12 @@
<h2><a id="wasi_messaging_types_0_2_0_draft"></a>Import interface wasi:messaging/[email protected]</h2>
<hr />
<h3>Types</h3>
<h4><a id="metadata"></a><code>type metadata</code></h4>
<p><a href="#metadata"><a href="#metadata"><code>metadata</code></a></a></p>
<p>A type alias for list<tuple<string, string>> to represent metadata attached to a message
<h4><a id="topic"></a><code>type topic</code></h4>
<p><code>string</code></p>
<p>A type alias for string to represent a message topic
<h4><a id="client"></a><code>resource client</code></h4>
<p>A connection to a message-exchange service (e.g., buffer, broker, etc.).</p>
<h4><a id="error"></a><code>variant error</code></h4>
Expand Down Expand Up @@ -62,7 +70,7 @@
<h4><a id="constructor_message"></a><code>[constructor]message: func</code></h4>
<h5>Params</h5>
<ul>
<li><a id="constructor_message.topic"></a><code>topic</code>: <code>string</code></li>
<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 @@ -77,14 +85,14 @@
</ul>
<h5>Return values</h5>
<ul>
<li><a id="method_message_topic.0"></a> <code>string</code></li>
<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><code>topic</code>: <code>string</code></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
Expand Down Expand Up @@ -131,7 +139,7 @@ message</p>
</ul>
<h5>Return values</h5>
<ul>
<li><a id="method_message_metadata.0"></a> option&lt;list&lt;(<code>string</code>, <code>string</code>)&gt;&gt;</li>
<li><a id="method_message_metadata.0"></a> option&lt;<a href="#metadata"><a href="#metadata"><code>metadata</code></a></a>&gt;</li>
</ul>
<h4><a id="method_message_add_metadata"></a><code>[method]message.add-metadata: func</code></h4>
<p>Add a new key-value pair to the metadata, overwriting any existing value for the same key</p>
Expand All @@ -141,6 +149,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_remove_metadata"></a><code>[method]message.remove-metadata: func</code></h4>
<p>Remove a key-value pair from the metadata</p>
<h5>Params</h5>
<ul>
<li><a id="method_message_remove_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_remove_metadata.key"></a><code>key</code>: <code>string</code></li>
</ul>
<h2><a id="wasi_messaging_producer_0_2_0_draft"></a>Import interface wasi:messaging/[email protected]</h2>
<p>The producer interface is used to send messages to a channel/topic.</p>
<hr />
Expand All @@ -161,7 +176,7 @@ message</p>
<h5>Params</h5>
<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.m"></a><code>m</code>: own&lt;<a href="#message"><a href="#message"><code>message</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>
</ul>
<h5>Return values</h5>
<ul>
Expand All @@ -176,6 +191,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="handle"></a><code>handle: func</code></h4>
Expand All @@ -185,18 +203,18 @@ message accordingly. Implementors (such as hosts) calling this interface should
own decisions on how to handle errors returned from this function.</p>
<h5>Params</h5>
<ul>
<li><a id="handle.ms"></a><code>ms</code>: own&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
<li><a id="handle.message"></a><a href="#message"><code>message</code></a>: own&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
</ul>
<h5>Return values</h5>
<ul>
<li><a id="handle.0"></a> result&lt;_, <a href="#error"><a href="#error"><code>error</code></a></a>&gt;</li>
</ul>
<h4><a id="get_subscriptions"></a><code>get-subscriptions: func</code></h4>
<p>Subscribe to a list of topics (represented as <code>string</code>s) at runtime.
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
<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
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>
<ul>
<li><a id="get_subscriptions.0"></a> result&lt;list&lt;<code>string</code>&gt;, <a href="#error"><a href="#error"><code>error</code></a></a>&gt;</li>
<li><a id="get_topics.0"></a> result&lt;list&lt;<a href="#topic"><a href="#topic"><code>topic</code></a></a>&gt;, <a href="#error"><a href="#error"><code>error</code></a></a>&gt;</li>
</ul>
Loading

0 comments on commit 49ac282

Please sign in to comment.