Quick Setup

This directory contains scripts to quickly set up and test the e-commerce reliability examples from Chapter 1.

๐Ÿš€ Quick Start

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_01_ecommerce_reliability/setup-scripts/blog-setup.sh | bash

# Or with custom app name
curl -fsSL https://raw.githubusercontent.com/tasker-systems/tasker/main/spec/blog/post_01_ecommerce_reliability/setup-scripts/blog-setup.sh | bash -s -- --app-name my-ecommerce-demo

Requirements: 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_01_ecommerce_reliability/setup-scripts/blog-setup.sh -o blog-setup.sh
chmod +x blog-setup.sh

# Run with options
./blog-setup.sh --app-name ecommerce-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 /checkout - Start checkout workflow

  • GET /order_status/:task_id - Monitor order processing

๐Ÿงช Testing the Reliability Features

Start the Application

Wait for all services to be ready (you'll see "Ready for connections" messages).

Test Successful Checkout

Test Payment Failure (Retryable)

Monitor Workflow Status

๐Ÿ”ง Key Features Demonstrated

Reliability Patterns

  • Smart Retry Logic: Different retry strategies for different failure types

  • Circuit Breaker: Prevents cascading failures

  • Graceful Degradation: Continues processing when possible

  • Timeout Handling: Prevents hanging operations

Error Handling

  • Retryable Errors: Payment timeouts, temporary service unavailability

  • Permanent Errors: Invalid cart items, insufficient inventory

  • Escalation: Failed retries trigger alerts and manual intervention

Workflow Orchestration

  • Step Dependencies: Each step waits for its prerequisites

  • Parallel Processing: Independent steps run simultaneously

  • State Management: Complete workflow state tracking

  • Recovery: Failed workflows can be resumed from last successful step

๐Ÿ” Monitoring and Observability

Docker Logs

Workflow Monitoring

๐Ÿ› ๏ธ Customization

Adding New Products

Edit the step handlers to include your product catalog:

Modifying Retry Logic

Update the YAML configuration:

Adding New Failure Scenarios

Create new payment tokens in process_payment_handler.rb:

๐Ÿ”ง Troubleshooting

Common Issues

Docker services won't start:

  • Ensure Docker is running: docker --version

  • Check for port conflicts: docker-compose ps

  • Free up resources: docker system prune

Application not responding:

  • Wait for database initialization (30-60 seconds)

  • Check logs: docker-compose logs web

  • Verify all services are healthy: docker-compose ps

Workflows not processing:

  • Ensure Sidekiq is running: docker-compose logs sidekiq

  • Check Redis connectivity: docker-compose exec redis redis-cli ping

  • Verify database migrations: docker-compose exec web rails db:migrate:status

Getting Help

  1. Check service status: docker-compose ps

  2. View logs: docker-compose logs -f

  3. Restart services: docker-compose restart

  4. Clean restart: docker-compose down && docker-compose up

๐Ÿ“– Learn More

๐Ÿ›‘ Cleanup

When you're done experimenting:

Last updated