ScheduleSyncer
This class periodically reloads active schedule triggers from the database and reconciles the running cron jobs via GoCronScheduler.
Methods
Run()
@classmethod
def Run(
ctx: context.Context
) - > error
Starts the ScheduleSyncer, which periodically reloads active schedule triggers from the database and reconciles the running cron jobs via GoCronScheduler. This method runs indefinitely until the provided context is cancelled.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for controlling the syncer's lifecycle. When this context is cancelled, the Run method will gracefully shut down. |
Returns
| Type | Description |
|---|---|
error | An error if the syncer encounters a critical issue during its operation. |
sync()
@classmethod
def sync(
ctx: context.Context
)
Synchronizes the active schedule triggers from the database with the GoCronScheduler. This involves fetching the latest active triggers and updating the scheduler to reflect any changes.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for controlling the synchronization operation, allowing for cancellation or timeouts. |
listActiveScheduleTriggers()
@classmethod
def listActiveScheduleTriggers(
ctx: context.Context
) - > ([]*models.Trigger, error)
Retrieves a list of all currently active schedule triggers from the database. This method is used internally to get the latest state of triggers for synchronization.
Parameters
| Name | Type | Description |
|---|---|---|
| ctx | context.Context | The context for controlling the database query, allowing for cancellation or timeouts. |
Returns
| Type | Description |
|---|---|
([]*models.Trigger, error) | A slice of active Trigger models and an error if the retrieval from the database fails. |