grape
https://github.com/intridea/grape
Ruby
An opinionated framework for creating REST-like APIs in Ruby.
Gitlab::Database::MigrationHelpers#queue_background_migration_jobs_by_range_at_intervals
Queues background migration jobs for an entire table, batched by ID range.
Each job is scheduled with a `delay_interval` in between.
If you use a small interval, then some jobs may run at the same time.
model_class - The table being iterated over
job_class_name - The background migration job class as a string
delay_interval - The duration between each job's scheduled time (must respond to `to_f`)
batch_size - The maximum number of rows per job
Example:
class Route < ActiveRecord::Base
include EachBatch
self.table_name = 'routes'
end
queue_background_migration_jobs_by_range_at_intervals(Route, 'ProcessRoutes', 1.minute)
Where the model_class includes EachBatch, and the background migration exists:
class Gitlab::BackgroundMigration::ProcessRoutes
def perform(start_id, end_id)
# do something
end
endEdit
git clone [email protected]:intridea/grape.git
cd grape
open
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-Gitlab--Database--MigrationHelpers-queue_background_migration_jobs_by_range_at_intervals-for-pr
# Commit to gitgit add git commit -m "better docs for Gitlab::Database::MigrationHelpers#queue_background_migration_jobs_by_range_at_intervals"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-Gitlab--Database--MigrationHelpers-queue_background_migration_jobs_by_range_at_intervals-for-pr
hub pull-request
# Celebrate!