Skip to content

Commit d491285

Browse files
feat(types): Updates the message type to have configurable fields
Also removes extensions as a guest configuration option (for now) Signed-off-by: Taylor Thomas <[email protected]>
1 parent 18318a5 commit d491285

File tree

4 files changed

+103
-12
lines changed

4 files changed

+103
-12
lines changed

imports-request-reply.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,10 @@ action. This error is mainly used when calling `update-guest-configuration`.
4545
<p>The interface doesn't highlight this difference in the type itself as that's uniquely a consumer issue.</p>
4646
<h4><a name="guest_configuration"></a><code>record guest-configuration</code></h4>
4747
<p>Configuration includes a required list of channels the guest is subscribing to, and an
48-
optional list of extensions key-value pairs (e.g., partitions/offsets to read from in
49-
Kafka/EventHubs, QoS etc.).</p>
48+
optional list of extensions key-value pairs</p>
5049
<h5>Record Fields</h5>
5150
<ul>
5251
<li><a name="guest_configuration.channels"></a><code>channels</code>: list&lt;<a href="#channel"><a href="#channel"><code>channel</code></a></a>&gt;</li>
53-
<li><a name="guest_configuration.extensions"></a><code>extensions</code>: option&lt;list&lt;(<code>string</code>, <code>string</code>)&gt;&gt;</li>
5452
</ul>
5553
<h4><a name="message"></a><code>resource message</code></h4>
5654
<h2>A message with a binary payload and additional information</h2>
@@ -86,6 +84,13 @@ Kafka/EventHubs, QoS etc.).</p>
8684
<ul>
8785
<li><a name="method_message.topic.0"></a> <a href="#channel"><a href="#channel"><code>channel</code></a></a></li>
8886
</ul>
87+
<h4><a name="method_message.set_topic"></a><code>[method]message.set-topic: func</code></h4>
88+
<p>Set the topic/subject/channel this message should be sent on</p>
89+
<h5>Params</h5>
90+
<ul>
91+
<li><a name="method_message.set_topic.self"></a><code>self</code>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
92+
<li><a name="method_message.set_topic.topic"></a><code>topic</code>: <a href="#channel"><a href="#channel"><code>channel</code></a></a></li>
93+
</ul>
8994
<h4><a name="method_message.content_type"></a><code>[method]message.content-type: func</code></h4>
9095
<p>An optional content-type describing the format of the data in the message. This is
9196
sometimes described as the &quot;format&quot; type</p>
@@ -97,6 +102,14 @@ sometimes described as the &quot;format&quot; type</p>
97102
<ul>
98103
<li><a name="method_message.content_type.0"></a> option&lt;<code>string</code>&gt;</li>
99104
</ul>
105+
<h4><a name="method_message.set_content_type"></a><code>[method]message.set-content-type: func</code></h4>
106+
<p>Set the content-type describing the format of the data in the message. This is
107+
sometimes described as the &quot;format&quot; type</p>
108+
<h5>Params</h5>
109+
<ul>
110+
<li><a name="method_message.set_content_type.self"></a><code>self</code>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
111+
<li><a name="method_message.set_content_type.content_type"></a><code>content-type</code>: <code>string</code></li>
112+
</ul>
100113
<h4><a name="method_message.data"></a><code>[method]message.data: func</code></h4>
101114
<p>An opaque blob of data</p>
102115
<h5>Params</h5>
@@ -107,6 +120,13 @@ sometimes described as the &quot;format&quot; type</p>
107120
<ul>
108121
<li><a name="method_message.data.0"></a> list&lt;<code>u8</code>&gt;</li>
109122
</ul>
123+
<h4><a name="method_message.set_data"></a><code>[method]message.set-data: func</code></h4>
124+
<p>Set the opaque blob of data for this message, discarding the old value</p>
125+
<h5>Params</h5>
126+
<ul>
127+
<li><a name="method_message.set_data.self"></a><code>self</code>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
128+
<li><a name="method_message.set_data.data"></a><code>data</code>: list&lt;<code>u8</code>&gt;</li>
129+
</ul>
110130
<h4><a name="method_message.metadata"></a><code>[method]message.metadata: func</code></h4>
111131
<p>Optional metadata (also called headers or attributes in some systems) attached to the
112132
message</p>
@@ -118,6 +138,14 @@ message</p>
118138
<ul>
119139
<li><a name="method_message.metadata.0"></a> option&lt;list&lt;(<code>string</code>, <code>string</code>)&gt;&gt;</li>
120140
</ul>
141+
<h4><a name="method_message.add_metadata"></a><code>[method]message.add-metadata: func</code></h4>
142+
<p>Add a new key-value pair to the metadata, overwriting any existing value for the same key</p>
143+
<h5>Params</h5>
144+
<ul>
145+
<li><a name="method_message.add_metadata.self"></a><code>self</code>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
146+
<li><a name="method_message.add_metadata.key"></a><code>key</code>: <code>string</code></li>
147+
<li><a name="method_message.add_metadata.value"></a><code>value</code>: <code>string</code></li>
148+
</ul>
121149
<h4><a name="method_message.complete"></a><code>[method]message.complete: func</code></h4>
122150
<p>Completes/acks the message</p>
123151
<p>A message can exist under several statuses:

imports.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,10 @@ action. This error is mainly used when calling `update-guest-configuration`.
4444
<p>The interface doesn't highlight this difference in the type itself as that's uniquely a consumer issue.</p>
4545
<h4><a name="guest_configuration"></a><code>record guest-configuration</code></h4>
4646
<p>Configuration includes a required list of channels the guest is subscribing to, and an
47-
optional list of extensions key-value pairs (e.g., partitions/offsets to read from in
48-
Kafka/EventHubs, QoS etc.).</p>
47+
optional list of extensions key-value pairs</p>
4948
<h5>Record Fields</h5>
5049
<ul>
5150
<li><a name="guest_configuration.channels"></a><code>channels</code>: list&lt;<a href="#channel"><a href="#channel"><code>channel</code></a></a>&gt;</li>
52-
<li><a name="guest_configuration.extensions"></a><code>extensions</code>: option&lt;list&lt;(<code>string</code>, <code>string</code>)&gt;&gt;</li>
5351
</ul>
5452
<h4><a name="message"></a><code>resource message</code></h4>
5553
<h2>A message with a binary payload and additional information</h2>
@@ -85,6 +83,13 @@ Kafka/EventHubs, QoS etc.).</p>
8583
<ul>
8684
<li><a name="method_message.topic.0"></a> <a href="#channel"><a href="#channel"><code>channel</code></a></a></li>
8785
</ul>
86+
<h4><a name="method_message.set_topic"></a><code>[method]message.set-topic: func</code></h4>
87+
<p>Set the topic/subject/channel this message should be sent on</p>
88+
<h5>Params</h5>
89+
<ul>
90+
<li><a name="method_message.set_topic.self"></a><code>self</code>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
91+
<li><a name="method_message.set_topic.topic"></a><code>topic</code>: <a href="#channel"><a href="#channel"><code>channel</code></a></a></li>
92+
</ul>
8893
<h4><a name="method_message.content_type"></a><code>[method]message.content-type: func</code></h4>
8994
<p>An optional content-type describing the format of the data in the message. This is
9095
sometimes described as the &quot;format&quot; type</p>
@@ -96,6 +101,14 @@ sometimes described as the &quot;format&quot; type</p>
96101
<ul>
97102
<li><a name="method_message.content_type.0"></a> option&lt;<code>string</code>&gt;</li>
98103
</ul>
104+
<h4><a name="method_message.set_content_type"></a><code>[method]message.set-content-type: func</code></h4>
105+
<p>Set the content-type describing the format of the data in the message. This is
106+
sometimes described as the &quot;format&quot; type</p>
107+
<h5>Params</h5>
108+
<ul>
109+
<li><a name="method_message.set_content_type.self"></a><code>self</code>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
110+
<li><a name="method_message.set_content_type.content_type"></a><code>content-type</code>: <code>string</code></li>
111+
</ul>
99112
<h4><a name="method_message.data"></a><code>[method]message.data: func</code></h4>
100113
<p>An opaque blob of data</p>
101114
<h5>Params</h5>
@@ -106,6 +119,13 @@ sometimes described as the &quot;format&quot; type</p>
106119
<ul>
107120
<li><a name="method_message.data.0"></a> list&lt;<code>u8</code>&gt;</li>
108121
</ul>
122+
<h4><a name="method_message.set_data"></a><code>[method]message.set-data: func</code></h4>
123+
<p>Set the opaque blob of data for this message, discarding the old value</p>
124+
<h5>Params</h5>
125+
<ul>
126+
<li><a name="method_message.set_data.self"></a><code>self</code>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
127+
<li><a name="method_message.set_data.data"></a><code>data</code>: list&lt;<code>u8</code>&gt;</li>
128+
</ul>
109129
<h4><a name="method_message.metadata"></a><code>[method]message.metadata: func</code></h4>
110130
<p>Optional metadata (also called headers or attributes in some systems) attached to the
111131
message</p>
@@ -117,6 +137,14 @@ message</p>
117137
<ul>
118138
<li><a name="method_message.metadata.0"></a> option&lt;list&lt;(<code>string</code>, <code>string</code>)&gt;&gt;</li>
119139
</ul>
140+
<h4><a name="method_message.add_metadata"></a><code>[method]message.add-metadata: func</code></h4>
141+
<p>Add a new key-value pair to the metadata, overwriting any existing value for the same key</p>
142+
<h5>Params</h5>
143+
<ul>
144+
<li><a name="method_message.add_metadata.self"></a><code>self</code>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
145+
<li><a name="method_message.add_metadata.key"></a><code>key</code>: <code>string</code></li>
146+
<li><a name="method_message.add_metadata.value"></a><code>value</code>: <code>string</code></li>
147+
</ul>
120148
<h4><a name="method_message.complete"></a><code>[method]message.complete: func</code></h4>
121149
<p>Completes/acks the message</p>
122150
<p>A message can exist under several statuses:

messaging.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,10 @@ action. This error is mainly used when calling `update-guest-configuration`.
4949
<p>The interface doesn't highlight this difference in the type itself as that's uniquely a consumer issue.</p>
5050
<h4><a name="guest_configuration"></a><code>record guest-configuration</code></h4>
5151
<p>Configuration includes a required list of channels the guest is subscribing to, and an
52-
optional list of extensions key-value pairs (e.g., partitions/offsets to read from in
53-
Kafka/EventHubs, QoS etc.).</p>
52+
optional list of extensions key-value pairs</p>
5453
<h5>Record Fields</h5>
5554
<ul>
5655
<li><a name="guest_configuration.channels"></a><code>channels</code>: list&lt;<a href="#channel"><a href="#channel"><code>channel</code></a></a>&gt;</li>
57-
<li><a name="guest_configuration.extensions"></a><code>extensions</code>: option&lt;list&lt;(<code>string</code>, <code>string</code>)&gt;&gt;</li>
5856
</ul>
5957
<h4><a name="message"></a><code>resource message</code></h4>
6058
<h2>A message with a binary payload and additional information</h2>
@@ -90,6 +88,13 @@ Kafka/EventHubs, QoS etc.).</p>
9088
<ul>
9189
<li><a name="method_message.topic.0"></a> <a href="#channel"><a href="#channel"><code>channel</code></a></a></li>
9290
</ul>
91+
<h4><a name="method_message.set_topic"></a><code>[method]message.set-topic: func</code></h4>
92+
<p>Set the topic/subject/channel this message should be sent on</p>
93+
<h5>Params</h5>
94+
<ul>
95+
<li><a name="method_message.set_topic.self"></a><code>self</code>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
96+
<li><a name="method_message.set_topic.topic"></a><code>topic</code>: <a href="#channel"><a href="#channel"><code>channel</code></a></a></li>
97+
</ul>
9398
<h4><a name="method_message.content_type"></a><code>[method]message.content-type: func</code></h4>
9499
<p>An optional content-type describing the format of the data in the message. This is
95100
sometimes described as the &quot;format&quot; type</p>
@@ -101,6 +106,14 @@ sometimes described as the &quot;format&quot; type</p>
101106
<ul>
102107
<li><a name="method_message.content_type.0"></a> option&lt;<code>string</code>&gt;</li>
103108
</ul>
109+
<h4><a name="method_message.set_content_type"></a><code>[method]message.set-content-type: func</code></h4>
110+
<p>Set the content-type describing the format of the data in the message. This is
111+
sometimes described as the &quot;format&quot; type</p>
112+
<h5>Params</h5>
113+
<ul>
114+
<li><a name="method_message.set_content_type.self"></a><code>self</code>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
115+
<li><a name="method_message.set_content_type.content_type"></a><code>content-type</code>: <code>string</code></li>
116+
</ul>
104117
<h4><a name="method_message.data"></a><code>[method]message.data: func</code></h4>
105118
<p>An opaque blob of data</p>
106119
<h5>Params</h5>
@@ -111,6 +124,13 @@ sometimes described as the &quot;format&quot; type</p>
111124
<ul>
112125
<li><a name="method_message.data.0"></a> list&lt;<code>u8</code>&gt;</li>
113126
</ul>
127+
<h4><a name="method_message.set_data"></a><code>[method]message.set-data: func</code></h4>
128+
<p>Set the opaque blob of data for this message, discarding the old value</p>
129+
<h5>Params</h5>
130+
<ul>
131+
<li><a name="method_message.set_data.self"></a><code>self</code>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
132+
<li><a name="method_message.set_data.data"></a><code>data</code>: list&lt;<code>u8</code>&gt;</li>
133+
</ul>
114134
<h4><a name="method_message.metadata"></a><code>[method]message.metadata: func</code></h4>
115135
<p>Optional metadata (also called headers or attributes in some systems) attached to the
116136
message</p>
@@ -122,6 +142,14 @@ message</p>
122142
<ul>
123143
<li><a name="method_message.metadata.0"></a> option&lt;list&lt;(<code>string</code>, <code>string</code>)&gt;&gt;</li>
124144
</ul>
145+
<h4><a name="method_message.add_metadata"></a><code>[method]message.add-metadata: func</code></h4>
146+
<p>Add a new key-value pair to the metadata, overwriting any existing value for the same key</p>
147+
<h5>Params</h5>
148+
<ul>
149+
<li><a name="method_message.add_metadata.self"></a><code>self</code>: borrow&lt;<a href="#message"><a href="#message"><code>message</code></a></a>&gt;</li>
150+
<li><a name="method_message.add_metadata.key"></a><code>key</code>: <code>string</code></li>
151+
<li><a name="method_message.add_metadata.value"></a><code>value</code>: <code>string</code></li>
152+
</ul>
125153
<h4><a name="method_message.complete"></a><code>[method]message.complete: func</code></h4>
126154
<p>Completes/acks the message</p>
127155
<p>A message can exist under several statuses:

wit/types.wit

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,33 @@ interface types {
2626
type channel = string;
2727

2828
/// Configuration includes a required list of channels the guest is subscribing to, and an
29-
/// optional list of extensions key-value pairs (e.g., partitions/offsets to read from in
30-
/// Kafka/EventHubs, QoS etc.).
29+
/// optional list of extensions key-value pairs
3130
record guest-configuration {
3231
channels: list<channel>,
33-
extensions: option<list<tuple<string, string>>>
3432
}
3533

3634
/// A message with a binary payload and additional information
3735
resource message {
3836
constructor(topic: channel, data: list<u8>, content-type: option<string>, metadata: option<list<tuple<string, string>>>);
3937
/// The topic/subject/channel this message was received or should be sent on
4038
topic: func() -> channel;
39+
/// Set the topic/subject/channel this message should be sent on
40+
set-topic: func(topic: channel);
4141
/// An optional content-type describing the format of the data in the message. This is
4242
/// sometimes described as the "format" type
4343
content-type: func() -> option<string>;
44+
/// Set the content-type describing the format of the data in the message. This is
45+
/// sometimes described as the "format" type
46+
set-content-type: func(content-type: string);
4447
/// An opaque blob of data
4548
data: func() -> list<u8>;
49+
/// Set the opaque blob of data for this message, discarding the old value
50+
set-data: func(data: list<u8>);
4651
/// Optional metadata (also called headers or attributes in some systems) attached to the
4752
/// message
4853
metadata: func() -> option<list<tuple<string, string>>>;
54+
/// Add a new key-value pair to the metadata, overwriting any existing value for the same key
55+
add-metadata: func(key: string, value: string);
4956

5057
/// Completes/acks the message
5158
///

0 commit comments

Comments
 (0)