Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid loading all tasks to validate a Run#task_name #866

Merged
merged 1 commit into from
Aug 23, 2023

Commits on Aug 18, 2023

  1. Avoid loading all tasks to validate a Run#task_name

    Currently, creating a `Run` record validates that its `task_name`
    belongs to the list returned by `Task.available_tasks`.
    
    Generating this list requires the gem to browse through the task
    namespace(s) to find and load all tasks in the application (see
    `Task#load_constants`).
    
    Although in most situations this should not be a problem, the Shopify
    monolith defines a relatively large amount of maintenance tasks, which
    take a considerable amount of time to load.
    
    Loading all tasks is only absolutely necessary when the application
    wants to display a list of all tasks. In any other scenario, for example
    testing a single task, it should not be necessary to load all tasks.
    
    This commit makes that possible by making use of `Task.named` to confirm
    that the task name is valid.
    Because `available_tasks` relies on `.descendants`, and `Task.named`
    uses ` < Task` to test inheritance, I don't think this will have any
    unintended effect on the gem's behaviour.
    davidstosik committed Aug 18, 2023
    Configuration menu
    Copy the full SHA
    292ebc3 View commit details
    Browse the repository at this point in the history