<?php

/**
 * Example: Recurring Jobs Configuration
 * 
 * Add this to your params-local.php or common/config/params-local.php
 * to define background jobs that automatically re-queue themselves.
 * 
 * The module will bootstrap these jobs when the console application starts,
 * and they will continue running in the background at specified intervals.
 */

return [
    'settings' => [
        'queues' => [
            'recurring' => [
                
                // Example 1: Cart Reminder Job (runs every 4 hours)
                [
                    'class' => 'frontend\jobs\CartReminders',
                    'name' => 'Cart Reminders - Every 4 Hours',
                    'queue' => 'queue',                // Queue component to use
                    'interval' => 14400,               // 4 hours in seconds
                    'ttr' => 3600,                     // Max execution time: 1 hour
                    'enabled' => true,                 // Set to false to disable
                    'checkDuplicates' => true,         // Prevent duplicate jobs on restart
                    'maxRetries' => 3,                 // Retry attempts on failure
                    'params' => [                      // Parameters passed to job constructor
                        // 'customParam' => 'value',
                    ],
                ],
                
                // Example 2: Order Sync Job (runs every 15 minutes)
                [
                    'class' => 'console\jobs\UpdateOrders',
                    'name' => 'NetSuite Order Sync',
                    'queue' => 'netsuitequeue',
                    'interval' => 900,                 // 15 minutes
                    'ttr' => 600,                      // Max execution time: 10 minutes
                    'enabled' => true,
                    'checkDuplicates' => true,
                    'maxRetries' => 5,
                    'params' => [
                        'schedule' => 'auto',
                    ],
                ],
                
                // Example 3: Cleanup Job (runs daily)
                [
                    'class' => 'frontend\jobs\Cleanup',
                    'name' => 'Daily Cleanup Job',
                    'queue' => 'queue',
                    'interval' => 86400,               // 24 hours
                    'ttr' => 1800,                     // Max execution time: 30 minutes
                    'enabled' => true,
                    'checkDuplicates' => true,
                    'maxRetries' => 2,
                ],
                
                // Example 4: Email Queue Processor (runs every minute)
                [
                    'class' => 'common\jobs\ProcessEmails',
                    'name' => 'Email Queue Processor',
                    'queue' => 'mailqueue',
                    'interval' => 60,                  // 1 minute
                    'ttr' => 180,                      // Max execution time: 3 minutes
                    'enabled' => true,
                    'checkDuplicates' => true,
                    'maxRetries' => 3,
                ],
                
                // Example 5: Disabled job (won't start)
                [
                    'class' => 'console\jobs\HeavyProcessing',
                    'name' => 'Heavy Processing (Disabled)',
                    'queue' => 'queue',
                    'interval' => 3600,
                    'enabled' => false,                // This job won't be started
                ],
                
            ],
        ],
    ],
];
