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
AsyncApiDataProvider provider({
"schema": "chat-api.asyncapi.yaml",
"url": "wss://api.example.com/ws",
});
AbstractDataProvider op = provider.getChildProviderPath("userChat/sendChatMessage");
op.doRequest({"userId": "123", "message": "Hello!"});
Custom Transport Example
%requires AsyncApiDataProvider
class MyMqttTransport inherits AbstractAsyncApiTransport {
send(string channel, auto msg, *hash<auto> headers) {
}
string getProtocol() { return "mqtt"; }
bool isConnected() { return True; }
connect() { }
}
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