30 lines
795 B
Plaintext
30 lines
795 B
Plaintext
|
package wasmcloud:messaging@0.2.0;
|
||
|
|
||
|
/// Types common to message broker interactions
|
||
|
interface types {
|
||
|
/// A message sent to or received from a broker
|
||
|
record broker-message {
|
||
|
subject: string,
|
||
|
body: list<u8>,
|
||
|
reply-to: option<string>,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
interface handler {
|
||
|
use types.{broker-message};
|
||
|
|
||
|
/// Callback handled to invoke a function when a message is received from a subscription
|
||
|
handle-message: func(msg: broker-message) -> result<_, string>;
|
||
|
}
|
||
|
|
||
|
interface consumer {
|
||
|
use types.{broker-message};
|
||
|
|
||
|
/// Perform a request operation on a subject
|
||
|
request: func(subject: string, body: list<u8>, timeout-ms: u32) -> result<broker-message, string>;
|
||
|
|
||
|
/// Publish a message to a subject without awaiting a response
|
||
|
publish: func(msg: broker-message) -> result<_, string>;
|
||
|
}
|
||
|
|