Qore AsyncApiDataProvider Module Reference 1.0
Loading...
Searching...
No Matches

Introduction to the AsyncApiDataProvider Module

The AsyncApiDataProvider module provides a dataproviderintro "data provider" API for AsyncAPI 3.0 event-driven APIs. The module is protocol-agnostic and supports pluggable transports for different messaging protocols.

The AsyncApiDataProvider class allows for introspecting an AsyncAPI schema, while the AsyncApiOperationDataProvider class supports the dataproviderintro "data provider" message API for communication with messaging servers.

Supported Transports

The module uses a pluggable transport architecture via the AbstractAsyncApiTransport interface. This allows the same AsyncAPI schema to be used with different messaging protocols:

  • WebSocketTransport - Built-in WebSocket transport
  • MQTT transport - Available via MqttDataProvider module (planned)
  • Kafka transport - Available via KafkaDataProvider module (planned)

Provider Hierarchy

AsyncAPI schemas can be introspected with the following format:

  • Channel: channel_name/operation_id
    • ex: userSignup/sendUserSignup
    • results in a AsyncApiOperationDataProvider object where the message schemas can be queried and messages can be sent/received

Usage Examples

WebSocket Example

%requires AsyncApiDataProvider
# Create provider with WebSocket transport (default when URL provided)
AsyncApiDataProvider provider({
"schema": "chat-api.asyncapi.yaml",
"url": "wss://api.example.com/ws",
});
# Navigate to operation
AbstractDataProvider op = provider.getChildProviderPath("userChat/sendChatMessage");
# Send a message
op.doRequest({"userId": "123", "message": "Hello!"});

Custom Transport Example

%requires AsyncApiDataProvider
# Create a custom transport (e.g., for MQTT)
class MyMqttTransport inherits AbstractAsyncApiTransport {
send(string channel, auto msg, *hash<auto> headers) {
# Send via MQTT client
}
string getProtocol() { return "mqtt"; }
bool isConnected() { return True; }
connect() { }
}
# Use custom transport with AsyncAPI provider
AsyncApiDataProvider provider({
"schema": "iot-api.asyncapi.yaml",
"transport": new MyMqttTransport(),
});

Available Classes

The following classes are provided by this module:

Release Notes

AsyncApiDataProvider v1.0

  • initial release of the module
  • protocol-agnostic design with pluggable transports
  • built-in WebSocket transport support