README
¶
Reactorcide API Client Examples
This directory contains example API clients demonstrating how to interact with the Reactorcide API and its Corndogs integration.
Overview
The Reactorcide API provides endpoints for:
- Creating jobs that are automatically submitted to Corndogs for queuing
- Monitoring job status and progress
- Managing job lifecycle (list, cancel, delete)
- Retrieving job logs and artifacts (when object store is configured)
Corndogs Integration Flow
When you create a job through the API:
- Job Creation: The job is created in the database with initial status
- Corndogs Submission: The job is automatically submitted to Corndogs queue
- Task ID Storage: The Corndogs task ID is stored with the job for tracking
- Worker Processing: Workers poll Corndogs for tasks and execute them using runnerlib
- Status Updates: Job status is updated as it progresses through Corndogs states
- Result Storage: Logs and artifacts are stored in the configured object store
Examples
Go Client (api_client.go)
A complete Go client implementation with:
- Health check
- Job creation with Corndogs queue configuration
- Job status monitoring
- Job management (list, cancel, delete)
- Polling with timeout for job completion
Python Client (api_client.py)
A Python client implementation with:
- Class-based API wrapper
- Multiple example scenarios (git jobs, simple jobs)
- Error handling and timeout management
- Environment variable configuration
Authentication
The API uses Bearer token authentication. To use these examples:
For Testing (Development Only)
- Create a test user in the database
- Generate a token value (e.g.,
test-api-token-{user_id}) - Store the SHA256 hash of the token in the database
- Use the original token value in the
Authorization: Bearer {token}header
For Production
- Use the proper user registration flow
- Generate secure API tokens through the API
- Store tokens securely (never commit them to version control)
Running the Examples
Go Example
# Set environment variables
export REACTORCIDE_API_URL=http://localhost:8080
export REACTORCIDE_API_TOKEN=your-api-token
# Run the example
go run api_client.go
Python Example
# Install dependencies
pip install requests
# Set environment variables
export REACTORCIDE_API_URL=http://localhost:8080
export REACTORCIDE_API_TOKEN=your-api-token
# Run the example
python api_client.py
Job Configuration
When creating jobs, you can specify:
Required Fields
name: Job namejob_command: Command to execute in the containersource_type: Either "git" or "copy"
Optional Fields
description: Job descriptiongit_url: Git repository URL (for git source type)git_ref: Branch, tag, or commit SHAsource_path: Local path (for copy source type)runner_image: Docker image (default: alpine:latest)job_env_vars: Environment variables as key-value pairsqueue_name: Corndogs queue name (default: "default")timeout_seconds: Job timeoutpriority: Job priority (higher values = higher priority)
Job Status Values
Jobs progress through these states:
submitted: Initial state when submitted to Corndogsqueued: Job is in the Corndogs queuerunning: Worker has claimed the job and is executing itcompleted: Job finished successfullyfailed: Job failed during executioncancelled: Job was cancelled by usersubmit_failed: Failed to submit to Corndogs (job remains in database)
Error Handling
Both examples include error handling for:
- Network failures
- Authentication errors
- Invalid job configurations
- Timeout during job execution
- API errors with detailed messages
Integration with Corndogs
The examples demonstrate how Reactorcide integrates with Corndogs:
- Queue Selection: Specify
queue_nameto route jobs to specific Corndogs queues - Priority: Set job priority for Corndogs scheduling
- Timeout: Configure job timeout that Corndogs will enforce
- Task Tracking: The API stores Corndogs task IDs for correlation
- Status Sync: Job status reflects the Corndogs task state
Next Steps
For production use:
- Implement proper authentication and token management
- Add retry logic for transient failures
- Implement log streaming from object store
- Add webhook support for job completion notifications
- Integrate with your CI/CD pipeline
Documentation
¶
There is no documentation for this package.
Click to show internal directories.
Click to hide internal directories.