Skip to main content
Version: v0.1.0

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 event option.
  • 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

ParameterTypeRequiredDescription
pipeline_idstringYesPipeline ID

Query Parameters

ParameterTypeRequiredDescription
pipeline_versionstringNoUse a specific version

Response

200 OK

{
"message": "Event started successfully"
}

Behavior Description

  1. If existing event services and sources exist, they are deleted.
  2. A new event service is created.
  3. A message source is created to subscribe to the specified topic.
  4. When a message arrives on the topic, the pipeline is executed.

Error Responses

Status CodeDescription
500 Internal Server ErrorPipeline does not have an event option

GET /api/v1/events/{pipeline_id}

Retrieves the status of an event trigger.

Path Parameters

ParameterTypeRequiredDescription
pipeline_idstringYesPipeline ID

Response

200 OK

{
"ready": true
}
FieldTypeDescription
readybooleanEvent service readiness status

DELETE /api/v1/events/{pipeline_id}

Stops and deletes the event trigger.

Path Parameters

ParameterTypeRequiredDescription
pipeline_idstringYesPipeline 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)│
└──────────────┘ └─────────────────┘ └──────────────────┘
  1. Message Topic: The topic where event messages are published
  2. Event Source: Subscribes to the topic and delivers events
  3. 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