Quick Setup
This directory contains scripts to quickly set up and test the microservices coordination examples from Chapter 3.
๐ Quick Start
One-Command Setup (Recommended)
The fastest way to try the example with zero local dependencies:
# Download and run the setup script
curl -fsSL https://raw.githubusercontent.com/tasker-systems/tasker/main/spec/blog/post_03_microservices_coordination/setup-scripts/blog-setup.sh | bash
# Or with custom app name
curl -fsSL https://raw.githubusercontent.com/tasker-systems/tasker/main/spec/blog/post_03_microservices_coordination/setup-scripts/blog-setup.sh | bash -s -- --app-name my-microservices-demoRequirements: Docker and Docker Compose only
Local Setup
If you prefer to run the setup script locally:
# Download the script
curl -fsSL https://raw.githubusercontent.com/tasker-systems/tasker/main/spec/blog/post_03_microservices_coordination/setup-scripts/blog-setup.sh -o blog-setup.sh
chmod +x blog-setup.sh
# Run with options
./blog-setup.sh --app-name microservices-demo --output-dir ./demos๐ ๏ธ How It Works
Docker-Based Architecture
The setup script creates a complete Docker environment with:
Rails application with live code reloading
PostgreSQL 15 database
Redis 7 for background job processing
Sidekiq for workflow execution
All tested code examples from the GitHub repository
Integration with Tasker Repository
All code examples are downloaded directly from the tested repository:
This ensures the examples are always up-to-date and have passed integration tests.
๐ What Gets Created
Application Structure
API Endpoints
POST /user_onboarding- Start user onboarding workflowGET /user_onboarding/status/:task_id- Monitor onboarding progressGET /user_onboarding/results/:task_id- Get onboarding results
๐งช Testing the Microservices Coordination
Start the Application
Wait for all services to be ready (you'll see "Ready for connections" messages).
Create New User Account
Monitor Onboarding Progress
Get Onboarding Results
Test with Different Plan Types
๐ง Key Features Demonstrated
Service Orchestration
The workflow demonstrates coordination across multiple services:
User service for account creation
Billing service for payment setup
Notification service for welcome emails
Each service has its own retry and timeout policies
Circuit Breaker Pattern
Built-in resilience against service failures:
Automatic retry for transient failures
Circuit breaker prevents cascading failures
Graceful degradation when services are unavailable
Structured Input Validation
Comprehensive validation of complex nested data:
User information validation (email, phone, names)
Billing information validation (plan types, payment methods)
Preferences validation (consent, notification settings)
Type safety and schema enforcement
API Abstraction
Clean separation between business logic and API handling:
Step handlers focus on business logic
API concerns handle service integration
Consistent error handling across services
Correlation ID tracking for distributed tracing
Idempotency Handling
Safe retry of operations:
Duplicate detection for user creation
Idempotent billing setup
Safe preference updates
๐ Monitoring and Observability
Docker Logs
Workflow Monitoring
Service Health Tracking
Each step provides service-specific information:
Which service was called
Response times and status codes
Retry attempts and failure reasons
Correlation IDs for distributed tracing
๐ ๏ธ Customization
Adding New Services
Create a new API concern for the service
Create a step handler that uses the concern
Add the step to the YAML configuration
Example:
Modifying Service Behavior
Update the API concerns to change service interaction:
Adjusting Retry Policies
Update the YAML configuration for different services:
๐ง Troubleshooting
Common Issues
Docker services won't start:
Ensure Docker is running:
docker --versionCheck for port conflicts:
docker-compose psFree up resources:
docker system prune
Workflow doesn't start:
Ensure all services are healthy:
docker-compose psCheck Sidekiq is running:
docker-compose logs sidekiqVerify database is ready:
docker-compose exec web rails db:migrate:status
Service calls fail:
Check network connectivity between containers
Verify service URLs in the API concerns
Review correlation IDs in logs for distributed tracing
Check for authentication or authorization issues
Steps fail with validation errors:
Verify input data matches the YAML schema
Check for required fields in nested objects
Ensure data types match expectations (strings, booleans, etc.)
Getting Help
Check service status:
docker-compose psView logs:
docker-compose logs -fRestart services:
docker-compose restartClean restart:
docker-compose down && docker-compose up
๐ฎ Related Examples
Chapter 1: E-commerce Reliability - Foundation patterns
Chapter 2: Data Pipeline Resilience - Batch processing patterns
๐ Learn More
Code Examples: GitHub Repository
Integration Tests: See how the examples are tested in the repository
๐ Cleanup
When you're done experimenting:
๐ก Next Steps
Once you have the workflow running:
Experiment with service failures - Simulate network timeouts and service unavailability
Customize the business logic - Add new validation rules or service integrations
Add new services - Extend with additional microservices
Implement real integrations - Replace mock services with real APIs
Scale the coordination - Test with multiple concurrent workflows
The patterns demonstrated here scale from simple service orchestration to complex distributed systems with dozens of microservices.
Last updated