Sha256: 5fa0ead88b75b464ffe4ef06b52cf6bcca4ceaed9412cd5a07666e03fbb0b326

Contents?: true

Size: 1.98 KB

Versions: 1

Compression:

Stored size: 1.98 KB

Contents

![Github CI](https://github.com/flamingo-run/rails-cloud-tasks/workflows/Github%20CI/badge.svg)
[![Maintainability](https://api.codeclimate.com/v1/badges/00d8532b0dd6a345474a/maintainability)](https://codeclimate.com/github/flamingo-run/rails-cloud-tasks/maintainability)
[![Test Coverage](https://api.codeclimate.com/v1/badges/00d8532b0dd6a345474a/test_coverage)](https://codeclimate.com/github/flamingo-run/rails-cloud-tasks/test_coverage)
[![ruby](https://img.shields.io/badge/ruby-2.7-red.svg)]()

# Rails Cloud Tasks

## APIs

The following APIs must be enabled in your project(s):

- [Cloud Tasks API](https://console.cloud.google.com/marketplace/product/google/cloudtasks.googleapis.com)
- [Admin SDK API](https://console.cloud.google.com/marketplace/product/google/admin.googleapis.com)

## Setup

### As an application (when contributing)

- Install packages:

```
  bundle install
```

### As a package (when inside another application)

- Add the gem to application's Gemfile:
```
gem 'rails-cloud-tasks'
```

- Add an initializer:
```ruby
# ./config/initializers/rails_cloud_tasks.rb

require 'rails-cloud-tasks'

RailsCloudTasks.configure do |config|
  config.project_id = 'my-gcp-project' # This is not needed if running on GCE
  config.location_id = 'us-central1'

  # 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
```

- Add a Job class:
```ruby
# ./app/jobs/application_job.rb

class ApplicationJob < ActiveJob::Base
  queue_as 'my-default-queue'
end


# ./app/jobs/my_first_job.rb

class MyFirstJob < ApplicationJob
  # Here you may override the queue, if needed
  queue_as 'some-other-queue'

  def perform(attrs)
    # Execute stuff
  end
end
```

- Enqueue a job:
```ruby
MyJob.perform_later(attrs)
```
## Tests

To run tests:

```
bundle exec rspec
```


## Version

Use [Semantic versioning](https://semver.org/).

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails-cloud-tasks-0.0.1 README.md