diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 45c37c2..7669187 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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' diff --git a/README.md b/README.md index 01f7bbe..1d303b8 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/imports-request-reply.md b/imports-request-reply.md index bdfa2d6..949b348 100644 --- a/imports-request-reply.md +++ b/imports-request-reply.md @@ -66,7 +66,6 @@ This allows the component to perform request/reply messaging patterns.

[constructor]message: func

Params
Return values
@@ -83,13 +82,6 @@ This allows the component to perform request/reply messaging patterns.

-

[method]message.set-topic: func

-

Set the topic/subject/channel this message should be sent on

-
Params
-

[method]message.content-type: func

An optional content-type describing the format of the data in the message. This is sometimes described as the "format" type

@@ -145,6 +137,13 @@ message

  • key: string
  • value: string
  • +

    [method]message.set-metadata: func

    +

    Set the metadata

    +
    Params
    +

    [method]message.remove-metadata: func

    Remove a key-value pair from the metadata

    Params
    @@ -216,7 +215,7 @@ return the list of messages received up to that point.

  • result<list<own<message>>, error>
  • reply: func

    -

    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.

    Please note that this reply functionality is different than something like HTTP because there @@ -247,6 +246,9 @@ where the reply is sent and the connection is closed.

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

    +#### `type topic` +[`topic`](#topic) +

    ----

    Functions

    send: func

    @@ -255,6 +257,7 @@ where the reply is sent and the connection is closed.

    Return values
    +

    [method]message.set-metadata: func

    +

    Set the metadata

    +
    Params
    +

    [method]message.remove-metadata: func

    Remove a key-value pair from the metadata

    Params
    @@ -164,6 +163,9 @@ message

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

    +#### `type topic` +[`topic`](#topic) +

    ----

    Functions

    send: func

    @@ -172,6 +174,7 @@ message

    Return values
    +

    [method]message.set-metadata: func

    +

    Set the metadata

    +
    Params
    +

    [method]message.remove-metadata: func

    Remove a key-value pair from the metadata

    Params
    @@ -169,6 +168,9 @@ message

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

    +#### `type topic` +[`topic`](#topic) +

    ----

    Functions

    send: func

    @@ -177,6 +179,7 @@ message

    Return values

    get-topics: func

    Returns a list of topics (represented as strings) 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.

    Return values
    diff --git a/messaging-request-reply.md b/messaging-request-reply.md index f2ec63c..6dff9b8 100644 --- a/messaging-request-reply.md +++ b/messaging-request-reply.md @@ -72,7 +72,6 @@ handling incoming messages with request/reply capabilities.

    [constructor]message: func

    Params
    Return values
    @@ -89,13 +88,6 @@ handling incoming messages with request/reply capabilities.

    -

    [method]message.set-topic: func

    -

    Set the topic/subject/channel this message should be sent on

    -
    Params
    -

    [method]message.content-type: func

    An optional content-type describing the format of the data in the message. This is sometimes described as the "format" type

    @@ -151,6 +143,13 @@ message

  • key: string
  • value: string
  • +

    [method]message.set-metadata: func

    +

    Set the metadata

    +
    Params
    +

    [method]message.remove-metadata: func

    Remove a key-value pair from the metadata

    Params
    @@ -222,7 +221,7 @@ return the list of messages received up to that point.

  • result<list<own<message>>, error>
  • reply: func

    -

    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.

    Please note that this reply functionality is different than something like HTTP because there @@ -253,6 +252,9 @@ where the reply is sent and the connection is closed.

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

    +#### `type topic` +[`topic`](#topic) +

    ----

    Functions

    send: func

    @@ -261,6 +263,7 @@ where the reply is sent and the connection is closed.

    Return values

    get-topics: func

    Returns a list of topics (represented as strings) 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.

    Return values
    diff --git a/wit/guest.wit b/wit/guest.wit index 940bb31..29c916d 100644 --- a/wit/guest.wit +++ b/wit/guest.wit @@ -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, error>; diff --git a/wit/producer.wit b/wit/producer.wit index 86c509d..9c86915 100644 --- a/wit/producer.wit +++ b/wit/producer.wit @@ -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, message: message) -> result<_, error>; + send: func(c: borrow, message: message, topic: topic) -> result<_, error>; } diff --git a/wit/request-reply.wit b/wit/request-reply.wit index 8fe8031..da8a543 100644 --- a/wit/request-reply.wit +++ b/wit/request-reply.wit @@ -33,7 +33,7 @@ interface request-reply { /// return the list of messages received up to that point. request: func(c: borrow, message: borrow, options: option) -> result, 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. /// diff --git a/wit/types.wit b/wit/types.wit index 0c0b82b..5c0b417 100644 --- a/wit/types.wit +++ b/wit/types.wit @@ -25,11 +25,9 @@ interface types { /// A message with a binary payload and additional information resource message { - constructor(topic: string, data: list); + constructor(data: list); /// 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; @@ -45,6 +43,8 @@ interface types { metadata: func() -> option; /// 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); }