Events API
API for event-driven pipeline execution.
Overview
The Events API allows you to trigger pipeline executions based on events from message topics. It uses serverless event processing for automatic scaling.
Prerequisites
- A message topic must be specified in the pipeline's
eventoption. - The event processing service must be installed in the cluster.
Endpoints
POST /api/v1/events/{pipeline_id}
Starts the event trigger for a pipeline.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
pipeline_id | string | Yes | Pipeline ID |
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
pipeline_version | string | No | Use a specific version |
Response
200 OK
{
"message": "Event started successfully"
}
Behavior Description
- If existing event services and sources exist, they are deleted.
- A new event service is created.
- A message source is created to subscribe to the specified topic.
- When a message arrives on the topic, the pipeline is executed.
Error Responses
| Status Code | Description |
|---|---|
| 500 Internal Server Error | Pipeline does not have an event option |
GET /api/v1/events/{pipeline_id}
Retrieves the status of an event trigger.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
pipeline_id | string | Yes | Pipeline ID |
Response
200 OK
{
"ready": true
}
| Field | Type | Description |
|---|---|---|
ready | boolean | Event service readiness status |
DELETE /api/v1/events/{pipeline_id}
Stops and deletes the event trigger.
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
pipeline_id | string | Yes | Pipeline ID |
Response
200 OK
{
"message": "Event deleted successfully"
}
Pipeline Configuration
To use event triggers, a message topic must be specified in the pipeline options.
{
"id": "pipeline-abc123",
"name": "Event Pipeline",
"options": {
"event": "my-topic"
},
"steps": [...]
}
Architecture
┌──────────────┐ ┌─────────────────┐ ┌──────────────────┐
│ Message Topic│────>│ Event Source │────>│ Event Service │
│ (event) │ │ (Subscriber) │ │ (Pipeline Runner)│
└──────────────┘ └─────────────────┘ └──────────────────┘
- Message Topic: The topic where event messages are published
- Event Source: Subscribes to the topic and delivers events
- Event Service: Receives events and executes the pipeline
Usage Examples
cURL
# Start event trigger
curl -X POST https://api.dhub.io/api/v1/events/pipeline-abc123 \
-H "Authorization: Bearer <access_token>"
# Check event status
curl https://api.dhub.io/api/v1/events/pipeline-abc123 \
-H "Authorization: Bearer <access_token>"
# Stop event trigger
curl -X DELETE https://api.dhub.io/api/v1/events/pipeline-abc123 \
-H "Authorization: Bearer <access_token>"
Event-Driven Pipeline Workflow
// 1. Create pipeline (with event option)
await fetch('/api/v1/pipelines/', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Order Processing',
options: {
event: 'orders-topic'
},
steps: [...]
})
});
// 2. Start event trigger
await fetch(`/api/v1/events/${pipelineId}`, {
method: 'POST',
headers: { 'Authorization': `Bearer ${token}` }
});
// 3. Check status
const status = await fetch(`/api/v1/events/${pipelineId}`, {
headers: { 'Authorization': `Bearer ${token}` }
}).then(res => res.json());
console.log('Event ready:', status.ready);
Scaling
The event processing service automatically scales based on traffic:
- Scale to Zero: When there are no events, instances scale down to 0
- Auto-scaling: Automatically scales out based on event processing volume