ccproxy.plugins.pricing.tasks¶
ccproxy.plugins.pricing.tasks
¶
Pricing plugin scheduled tasks.
BaseScheduledTask
¶
BaseScheduledTask(
name,
interval_seconds,
enabled=True,
max_backoff_seconds=300.0,
jitter_factor=0.25,
)
Bases: ABC
Abstract base class for all scheduled tasks.
Provides common functionality for task lifecycle management, error handling, and exponential backoff for failed executions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Human-readable task name |
required |
interval_seconds
|
float
|
Interval between task executions in seconds |
required |
enabled
|
bool
|
Whether the task is enabled |
True
|
max_backoff_seconds
|
float
|
Maximum backoff delay for failed tasks |
300.0
|
jitter_factor
|
float
|
Jitter factor for backoff randomization (0.0-1.0) |
0.25
|
Source code in ccproxy/plugins/pricing/tasks.py
run
abstractmethod
async
¶
Execute the task logic.
Returns:
| Type | Description |
|---|---|
bool
|
True if task completed successfully, False otherwise |
setup
async
¶
Optional setup hook called before the task starts running.
Override this method to perform any initialization required by the task.
teardown
async
¶
Optional teardown hook called when the task stops.
Override this method to perform any cleanup required by the task.
start
async
¶
Start the scheduled task.
Source code in ccproxy/plugins/pricing/tasks.py
stop
async
¶
Stop the scheduled task.
Source code in ccproxy/plugins/pricing/tasks.py
is_running
¶
get_status
¶
Get current task status information.
Source code in ccproxy/plugins/pricing/tasks.py
PricingCacheUpdateTask
¶
PricingCacheUpdateTask(
name,
interval_seconds,
pricing_service,
enabled=True,
force_refresh_on_startup=False,
)
Bases: BaseScheduledTask
Task for updating pricing cache periodically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Task name |
required |
interval_seconds
|
float
|
Interval between pricing updates |
required |
pricing_service
|
PricingService
|
Pricing service instance |
required |
enabled
|
bool
|
Whether task is enabled |
True
|
force_refresh_on_startup
|
bool
|
Whether to force refresh on first run |
False
|
Source code in ccproxy/plugins/pricing/tasks.py
run
async
¶
Execute pricing cache update.