README.md in rails-cloud-tasks-0.0.1 vs README.md in rails-cloud-tasks-0.0.2

- old
+ new

@@ -34,22 +34,38 @@ # ./config/initializers/rails_cloud_tasks.rb require 'rails-cloud-tasks' RailsCloudTasks.configure do |config| + config.service_account_email = 'test-account@test-project.iam.gserviceaccount.com' config.project_id = 'my-gcp-project' # This is not needed if running on GCE config.location_id = 'us-central1' + config.scheduler_file_path = './custom_path/scheduler_jobs.yml' + config.scheduler_prefix_name = 'my-app-name' # Base url used by Cloud Tasks to reach your application and run the tasks config.host = 'https://myapplication.host.com' config.tasks_path = '/v2/tasks' # default: '/tasks' # Inject routes into application config.inject_routes end ``` +Check out the available configs and its usage description: + +| attribute | description | env support | app engine fallback | default value | +|----------------------- |------------------------------------------------------------------------------------------------------------- |--------------------- |-------------------- |-------------------------- | +| service_account_email | The app service account email. It''s used to impersonate an user on schedule job | GCP_SERVICE_ACCOUNT | ✓ | | +| project_id | The Project ID | GCP_PROJECT | ✓ | | +| location_id | The region where you app is running (eg: us-central1, us-east1...) | GCP_LOCATION | ✓ | | +| host | The app endpoint which the app is running. *Do not use custom domain* Use the generated domain by Cloud Run | GCP_APP_ENDPOINT | | | +| scheduler_file_path | Path which the scheduler file is located | 𐄂 | | './config/scheduler.yml' | +| scheduler_prefix_name | The prefix to be set into scheduler job name | 𐄂 | | 'rails-cloud' | +| tasks_path | The path to run tasks | 𐄂 | | '/tasks' | + + - Add a Job class: ```ruby # ./app/jobs/application_job.rb class ApplicationJob < ActiveJob::Base @@ -71,9 +87,37 @@ - Enqueue a job: ```ruby MyJob.perform_later(attrs) ``` + +### Scheduled Jobs + +We have support to Google Cloud Schedule. It's based on Cloud tasks, the jobs are scheduled with HTTP Target. We do not support Pub/Sub or App Engine HTTP for now. + +Check out the follow sample of config file: +```yaml +# config/scheduler.yml +- name: Users::SyncJob + schedule: 0 8 * * * + description: Sync user data + time_zone: "America/Los_Angeles" + args: + arg1: 100 + arg2: 200 +``` + +| attribute | description | required | +|------------- |---------------------------------------------------------------- |---------- | +| name | The Job class namespace | ✓ | +| schedule | The frequency to run your job. It should be a unix-cron format | ✓ | +| description | What this job does | ✓ | +| time_zone | Choose which one timezone your job must run | ✓ | +| args | What are the job's arguments | ✓ | + + + + ## Tests To run tests: ```