All Projects → esminc → activejob-google_cloud_tasks-http

esminc / activejob-google_cloud_tasks-http

Licence: MIT License
Active Job adapter for Google Cloud Tasks HTTP targets

Programming Languages

ruby
36898 projects - #4 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to activejob-google cloud tasks-http

Shoryuken
A super efficient Amazon SQS thread based message processor for Ruby
Stars: ✭ 1,837 (+11381.25%)
Mutual labels:  activejob
activejob-uniqueness
Unique jobs for ActiveJob. Ensure the uniqueness of jobs in the queue.
Stars: ✭ 194 (+1112.5%)
Mutual labels:  activejob
cloud-run-iap-terraform-demo
Deploy an IAP-secured application to Cloud Run using Terraform (e.g. an admin portal or internal company app)
Stars: ✭ 51 (+218.75%)
Mutual labels:  google-cloud-run
cloudrun-tutorial
A tutorial showing some of the features of Cloud Run
Stars: ✭ 79 (+393.75%)
Mutual labels:  google-cloud-run
laravel6-on-google-cloud-run
Laravel 6 on Google cloud run for a demo
Stars: ✭ 25 (+56.25%)
Mutual labels:  google-cloud-run
kube queue
Run processing background job on Kubernetes for Ruby
Stars: ✭ 26 (+62.5%)
Mutual labels:  activejob
Cloud Run Faq
Unofficial FAQ and everything you've been wondering about Google Cloud Run.
Stars: ✭ 1,921 (+11906.25%)
Mutual labels:  google-cloud-run
serverless-url-redirect
Simple click-to-deploy serverless URL redirect service
Stars: ✭ 39 (+143.75%)
Mutual labels:  google-cloud-run
KittyEvents
Super simple event system on top of ActiveJob
Stars: ✭ 20 (+25%)
Mutual labels:  activejob
cloud-run-node-16
Latest Node.js on Cloud Run
Stars: ✭ 14 (-12.5%)
Mutual labels:  google-cloud-run
taskinator
A simple orchestration library for running complex processes or workflows in Ruby
Stars: ✭ 25 (+56.25%)
Mutual labels:  activejob
maintenance job
Mechanism to run testable one-off jobs in Rails at deploy time to manipulate data
Stars: ✭ 27 (+68.75%)
Mutual labels:  activejob
deploy-cloudrun
This action deploys your container image to Cloud Run.
Stars: ✭ 238 (+1387.5%)
Mutual labels:  google-cloud-run
Rails
Ruby on Rails
Stars: ✭ 49,693 (+310481.25%)
Mutual labels:  activejob
souls
SOULs 🔥 Build Serverless Apps faster like Rails. Powered by Ruby GraphQL, RBS/Steep, Active Record, RSpec, RuboCop, and Google Cloud.
Stars: ✭ 327 (+1943.75%)
Mutual labels:  google-cloud-run
active scheduler
Resque Scheduling for ActiveJob
Stars: ✭ 72 (+350%)
Mutual labels:  activejob
advanced-sneakers-activejob
Advanced Sneakers adapter for ActiveJob
Stars: ✭ 34 (+112.5%)
Mutual labels:  activejob
cloud-run-hello
Demo container for Google Cloud Run
Stars: ✭ 54 (+237.5%)
Mutual labels:  google-cloud-run
cloudrun-fastapi
FastAPI on Google Cloud Run
Stars: ✭ 112 (+600%)
Mutual labels:  google-cloud-run
lambdakiq
ActiveJob on SQS & Lambda
Stars: ✭ 131 (+718.75%)
Mutual labels:  activejob

ActiveJob::GoogleCloudTasks::HTTP

ActiveJob::GoogleCloudTasks::HTTP is an ActiveJob adapter for running jobs via Google Cloud Tasks. As the name suggests it only supports HTTP targets.

Installation

Add this line to your application's Gemfile:

gem 'activejob-google_cloud_tasks-http'

And then execute:

$ bundle

Or install it yourself as:

$ gem install activejob-google_cloud_tasks-http

Usage

Setup

Configure an adapter instance and pass it to Active Job:

Rails.application.config.active_job.queue_adapter = ActiveJob::GoogleCloudTasks::HTTP::Adapter.new(
  project: 'a-gcp-project-name',
  location: 'asia-northeast1',
  url: 'https://an-endpoint-to-perform-jobs.a.run.app/_jobs',
  client: Google::Cloud::Tasks.cloud_tasks(version: :v2beta3), # optional
  task_options: { # optional
    oidc_token: {
      service_account_email: '[email protected]'
    }
  }
)

A name passed to queue_as will be used to identify which Cloud Tasks queue will be used by the job:

class GoodJob < ApplicationJob
  queue_as :a_queue_name

  # ...
end

Mount the Rack application to set up an endpoint for performing jobs:

# in config/routes.rb
mount ActiveJob::GoogleCloudTasks::HTTP::Rack.new, at: '/_jobs'

Note that this rack app itself does not have any authentication mechanism.

Testing

Requiring active_job/google_cloud_tasks/http/inline makes the adapter skip enqueueing jobs to Google Cloud Tasks. Once a job is enqueued, it will perform the job immediately.

require 'active_job/google_cloud_tasks/http/inline' unless Rails.env.production?

Error when calling assets:precompile?

When you call assets:precompile, all configs and initializers are loaded. If you load your credentials via environment variables they may not be available and the adapter initialization will cause errors. To solve this, wrap the queue_adapter config in a unless ARGV.include?("assets:precompile") condition. e.g.:

unless ARGV.include?("assets:precompile") # prevents running on assets:precompile
  Rails.application.config.active_job.queue_adapter = ActiveJob::GoogleCloudTasks::HTTP::Adapter.new(
    project: 'my-project',
    location: 'europe-west2',
    url: 'https://www.example.com/jobs',
    client: Google::Cloud::Tasks.cloud_tasks(
      version: :v2beta3,
      credentials: JSON.parse(ENV["GOOGLE_CLOUD_PRODUCTION_KEYFILE"]) # this will cause an error if the environment variable does not exist
    )
  )
end

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/esminc/activejob-google_cloud_tasks-http.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the ActiveJob::GoogleCloudTasks::HTTP project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].