|
| 1 | +<h1><a name="messaging">World messaging</a></h1> |
| 2 | +<ul> |
| 3 | +<li>Imports: |
| 4 | +<ul> |
| 5 | +< li>interface < a href= "#wasi:messaging_messaging_types_0.1.0">< code>wasi:messaging/ [email protected]</ code></ a></ li> |
| 6 | +< li>interface < a href= "#wasi:messaging_producer_0.1.0">< code>wasi:messaging/ [email protected]</ code></ a></ li> |
| 7 | +< li>interface < a href= "#wasi:messaging_consumer_0.1.0">< code>wasi:messaging/ [email protected]</ code></ a></ li> |
| 8 | +</ul> |
| 9 | +</li> |
| 10 | +<li>Exports: |
| 11 | +<ul> |
| 12 | +< li>interface < a href= "#wasi:messaging_messaging_guest_0.1.0">< code>wasi:messaging/ [email protected]</ code></ a></ li> |
| 13 | +</ul> |
| 14 | +</li> |
| 15 | +</ul> |
| 16 | +< h2>< a name= "wasi:messaging_messaging_types_0.1.0">Import interface wasi:messaging/ [email protected]</ a></ h2> |
| 17 | +<hr /> |
| 18 | +<h3>Types</h3> |
| 19 | +<h4><a name="client"><code>resource client</code></a></h4> |
| 20 | +<p>A connection to a message-exchange service (e.g., buffer, broker, etc.).</p> |
| 21 | +<h4><a name="error"><code>resource error</code></a></h4> |
| 22 | +<p>TODO(danbugs): This should be eventually extracted as an underlying type for other wasi-cloud-core interfaces.</p> |
| 23 | +<h4><a name="channel"><code>type channel</code></a></h4> |
| 24 | +<p><code>string</code></p> |
| 25 | +<p>There are two types of channels: |
| 26 | +- publish-subscribe channel, which is a broadcast channel, and |
| 27 | +- point-to-point channel, which is a unicast channel. |
| 28 | +<p>The interface doesn't highlight this difference in the type itself as that's uniquely a consumer issue.</p> |
| 29 | +<h4><a name="guest_configuration"><code>record guest-configuration</code></a></h4> |
| 30 | +<p>Configuration includes a required list of channels the guest is subscribing to, and an optional list of extensions key-value pairs |
| 31 | +(e.g., partitions/offsets to read from in Kafka/EventHubs, QoS etc.).</p> |
| 32 | +<h5>Record Fields</h5> |
| 33 | +<ul> |
| 34 | +<li><a name="guest_configuration.channels"><code>channels</code></a>: list<<a href="#channel"><a href="#channel"><code>channel</code></a></a>></li> |
| 35 | +<li><a name="guest_configuration.extensions"><code>extensions</code></a>: option<list<(<code>string</code>, <code>string</code>)>></li> |
| 36 | +</ul> |
| 37 | +<h4><a name="format_spec"><code>enum format-spec</code></a></h4> |
| 38 | +<p>Format specification for messages</p> |
| 39 | +<ul> |
| 40 | +<li>more info: https://github.com/clemensv/spec/blob/registry-extensions/registry/spec.md#message-formats</li> |
| 41 | +<li>message metadata can further decorate w/ things like format version, and so on.</li> |
| 42 | +</ul> |
| 43 | +<h5>Enum Cases</h5> |
| 44 | +<ul> |
| 45 | +<li><a name="format_spec.cloudevents"><code>cloudevents</code></a></li> |
| 46 | +<li><a name="format_spec.http"><code>http</code></a></li> |
| 47 | +<li><a name="format_spec.amqp"><code>amqp</code></a></li> |
| 48 | +<li><a name="format_spec.mqtt"><code>mqtt</code></a></li> |
| 49 | +<li><a name="format_spec.kafka"><code>kafka</code></a></li> |
| 50 | +<li><a name="format_spec.raw"><code>raw</code></a></li> |
| 51 | +</ul> |
| 52 | +<h4><a name="message"><code>record message</code></a></h4> |
| 53 | +<p>A message with a binary payload, a format specification, and decorative metadata.</p> |
| 54 | +<h5>Record Fields</h5> |
| 55 | +<ul> |
| 56 | +<li><a name="message.data"><code>data</code></a>: list<<code>u8</code>></li> |
| 57 | +<li><a name="message.format"><code>format</code></a>: <a href="#format_spec"><a href="#format_spec"><code>format-spec</code></a></a></li> |
| 58 | +<li><a name="message.metadata"><code>metadata</code></a>: option<list<(<code>string</code>, <code>string</code>)>></li> |
| 59 | +</ul> |
| 60 | +<hr /> |
| 61 | +<h3>Functions</h3> |
| 62 | +<h4><a name="static_client.connect"><code>[static]client.connect: func</code></a></h4> |
| 63 | +<h5>Params</h5> |
| 64 | +<ul> |
| 65 | +<li><a name="static_client.connect.name"><code>name</code></a>: <code>string</code></li> |
| 66 | +</ul> |
| 67 | +<h5>Return values</h5> |
| 68 | +<ul> |
| 69 | +<li><a name="static_client.connect.0"></a> result<own<<a href="#client"><a href="#client"><code>client</code></a></a>>, own<<a href="#error"><a href="#error"><code>error</code></a></a>>></li> |
| 70 | +</ul> |
| 71 | +<h4><a name="static_error.trace"><code>[static]error.trace: func</code></a></h4> |
| 72 | +<h5>Return values</h5> |
| 73 | +<ul> |
| 74 | +<li><a name="static_error.trace.0"></a> <code>string</code></li> |
| 75 | +</ul> |
| 76 | +< h2>< a name= "wasi:messaging_producer_0.1.0">Import interface wasi:messaging/ [email protected]</ a></ h2> |
| 77 | +<hr /> |
| 78 | +<h3>Types</h3> |
| 79 | +<h4><a name="client"><code>type client</code></a></h4> |
| 80 | +<p><a href="#client"><a href="#client"><code>client</code></a></a></p> |
| 81 | +<p> |
| 82 | +#### <a name="channel">`type channel`</a> |
| 83 | +[`channel`](#channel) |
| 84 | +<p> |
| 85 | +#### <a name="message">`type message`</a> |
| 86 | +[`message`](#message) |
| 87 | +<p> |
| 88 | +#### <a name="error">`type error`</a> |
| 89 | +[`error`](#error) |
| 90 | +<p> |
| 91 | +---- |
| 92 | +<h3>Functions</h3> |
| 93 | +<h4><a name="send"><code>send: func</code></a></h4> |
| 94 | +<h5>Params</h5> |
| 95 | +<ul> |
| 96 | +<li><a name="send.c"><code>c</code></a>: own<<a href="#client"><a href="#client"><code>client</code></a></a>></li> |
| 97 | +<li><a name="send.ch"><code>ch</code></a>: <a href="#channel"><a href="#channel"><code>channel</code></a></a></li> |
| 98 | +<li><a name="send.m"><code>m</code></a>: list<<a href="#message"><a href="#message"><code>message</code></a></a>></li> |
| 99 | +</ul> |
| 100 | +<h5>Return values</h5> |
| 101 | +<ul> |
| 102 | +<li><a name="send.0"></a> result<_, own<<a href="#error"><a href="#error"><code>error</code></a></a>>></li> |
| 103 | +</ul> |
| 104 | +< h2>< a name= "wasi:messaging_consumer_0.1.0">Import interface wasi:messaging/ [email protected]</ a></ h2> |
| 105 | +<hr /> |
| 106 | +<h3>Types</h3> |
| 107 | +<h4><a name="client"><code>type client</code></a></h4> |
| 108 | +<p><a href="#client"><a href="#client"><code>client</code></a></a></p> |
| 109 | +<p> |
| 110 | +#### <a name="message">`type message`</a> |
| 111 | +[`message`](#message) |
| 112 | +<p> |
| 113 | +#### <a name="channel">`type channel`</a> |
| 114 | +[`channel`](#channel) |
| 115 | +<p> |
| 116 | +#### <a name="error">`type error`</a> |
| 117 | +[`error`](#error) |
| 118 | +<p> |
| 119 | +#### <a name="guest_configuration">`type guest-configuration`</a> |
| 120 | +[`guest-configuration`](#guest_configuration) |
| 121 | +<p> |
| 122 | +---- |
| 123 | +<h3>Functions</h3> |
| 124 | +<h4><a name="subscribe_try_receive"><code>subscribe-try-receive: func</code></a></h4> |
| 125 | +<p>Blocking receive for t-milliseconds with ephemeral subscription – if no message is received, returns None</p> |
| 126 | +<h5>Params</h5> |
| 127 | +<ul> |
| 128 | +<li><a name="subscribe_try_receive.c"><code>c</code></a>: own<<a href="#client"><a href="#client"><code>client</code></a></a>></li> |
| 129 | +<li><a name="subscribe_try_receive.ch"><code>ch</code></a>: <a href="#channel"><a href="#channel"><code>channel</code></a></a></li> |
| 130 | +<li><a name="subscribe_try_receive.t_milliseconds"><code>t-milliseconds</code></a>: <code>u32</code></li> |
| 131 | +</ul> |
| 132 | +<h5>Return values</h5> |
| 133 | +<ul> |
| 134 | +<li><a name="subscribe_try_receive.0"></a> result<option<list<<a href="#message"><a href="#message"><code>message</code></a></a>>>, own<<a href="#error"><a href="#error"><code>error</code></a></a>>></li> |
| 135 | +</ul> |
| 136 | +<h4><a name="subscribe_receive"><code>subscribe-receive: func</code></a></h4> |
| 137 | +<p>Blocking receive until message with ephemeral subscription</p> |
| 138 | +<h5>Params</h5> |
| 139 | +<ul> |
| 140 | +<li><a name="subscribe_receive.c"><code>c</code></a>: own<<a href="#client"><a href="#client"><code>client</code></a></a>></li> |
| 141 | +<li><a name="subscribe_receive.ch"><code>ch</code></a>: <a href="#channel"><a href="#channel"><code>channel</code></a></a></li> |
| 142 | +</ul> |
| 143 | +<h5>Return values</h5> |
| 144 | +<ul> |
| 145 | +<li><a name="subscribe_receive.0"></a> result<list<<a href="#message"><a href="#message"><code>message</code></a></a>>, own<<a href="#error"><a href="#error"><code>error</code></a></a>>></li> |
| 146 | +</ul> |
| 147 | +<h4><a name="update_guest_configuration"><code>update-guest-configuration: func</code></a></h4> |
| 148 | +<p>'Fit-all' type function for updating a guest's configuration – this could be useful for:</p> |
| 149 | +<ul> |
| 150 | +<li>unsubscribing from a channel,</li> |
| 151 | +<li>checkpointing,</li> |
| 152 | +<li>etc..</li> |
| 153 | +</ul> |
| 154 | +<h5>Params</h5> |
| 155 | +<ul> |
| 156 | +<li><a name="update_guest_configuration.gc"><code>gc</code></a>: <a href="#guest_configuration"><a href="#guest_configuration"><code>guest-configuration</code></a></a></li> |
| 157 | +</ul> |
| 158 | +<h5>Return values</h5> |
| 159 | +<ul> |
| 160 | +<li><a name="update_guest_configuration.0"></a> result<_, own<<a href="#error"><a href="#error"><code>error</code></a></a>>></li> |
| 161 | +</ul> |
| 162 | +<h4><a name="complete_message"><code>complete-message: func</code></a></h4> |
| 163 | +<p>A message can exist under several statuses: |
| 164 | +(1) available: the message is ready to be read, |
| 165 | +(2) acquired: the message has been sent to a consumer (but still exists in the queue), |
| 166 | +(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, |
| 167 | +(4) rejected (result of abandon-message): the message has been received and NACK-ed by a consumer, at which point it can be:</p> |
| 168 | +<ul> |
| 169 | +<li>deleted,</li> |
| 170 | +<li>sent to a dead-letter queue, or</li> |
| 171 | +<li>kept in the queue for further processing.</li> |
| 172 | +</ul> |
| 173 | +<h5>Params</h5> |
| 174 | +<ul> |
| 175 | +<li><a name="complete_message.m"><code>m</code></a>: <a href="#message"><a href="#message"><code>message</code></a></a></li> |
| 176 | +</ul> |
| 177 | +<h5>Return values</h5> |
| 178 | +<ul> |
| 179 | +<li><a name="complete_message.0"></a> result<_, own<<a href="#error"><a href="#error"><code>error</code></a></a>>></li> |
| 180 | +</ul> |
| 181 | +<h4><a name="abandon_message"><code>abandon-message: func</code></a></h4> |
| 182 | +<h5>Params</h5> |
| 183 | +<ul> |
| 184 | +<li><a name="abandon_message.m"><code>m</code></a>: <a href="#message"><a href="#message"><code>message</code></a></a></li> |
| 185 | +</ul> |
| 186 | +<h5>Return values</h5> |
| 187 | +<ul> |
| 188 | +<li><a name="abandon_message.0"></a> result<_, own<<a href="#error"><a href="#error"><code>error</code></a></a>>></li> |
| 189 | +</ul> |
| 190 | +< h2>< a name= "wasi:messaging_messaging_guest_0.1.0">Export interface wasi:messaging/ [email protected]</ a></ h2> |
| 191 | +<hr /> |
| 192 | +<h3>Types</h3> |
| 193 | +<h4><a name="message"><code>type message</code></a></h4> |
| 194 | +<p><a href="#message"><a href="#message"><code>message</code></a></a></p> |
| 195 | +<p> |
| 196 | +#### <a name="guest_configuration">`type guest-configuration`</a> |
| 197 | +[`guest-configuration`](#guest_configuration) |
| 198 | +<p> |
| 199 | +#### <a name="error">`type error`</a> |
| 200 | +[`error`](#error) |
| 201 | +<p> |
| 202 | +---- |
| 203 | +<h3>Functions</h3> |
| 204 | +<h4><a name="configure"><code>configure: func</code></a></h4> |
| 205 | +<p>Returns the list of channels (and extension metadata within guest-configuration) that |
| 206 | +this component should subscribe to and be handled by the subsequent handler within guest-configuration</p> |
| 207 | +<h5>Return values</h5> |
| 208 | +<ul> |
| 209 | +<li><a name="configure.0"></a> result<<a href="#guest_configuration"><a href="#guest_configuration"><code>guest-configuration</code></a></a>, own<<a href="#error"><a href="#error"><code>error</code></a></a>>></li> |
| 210 | +</ul> |
| 211 | +<h4><a name="handler"><code>handler: func</code></a></h4> |
| 212 | +<p>Whenever this guest receives a message in one of the subscribed channels, the message is sent to this handler</p> |
| 213 | +<h5>Params</h5> |
| 214 | +<ul> |
| 215 | +<li><a name="handler.ms"><code>ms</code></a>: list<<a href="#message"><a href="#message"><code>message</code></a></a>></li> |
| 216 | +</ul> |
| 217 | +<h5>Return values</h5> |
| 218 | +<ul> |
| 219 | +<li><a name="handler.0"></a> result<_, own<<a href="#error"><a href="#error"><code>error</code></a></a>>></li> |
| 220 | +</ul> |
0 commit comments