Git Product home page Git Product logo

activejob-google_cloud_tasks's Introduction

Activejob::GoogleCloudTasks

Build Status Gem Version

Google Cloud Tasks adapter for ActiveJob

Prerequisites

Installation

Add this line to your application's Gemfile:

gem 'activejob-google_cloud_tasks', '>= 0.1.2'

Usage

First, change the ActiveJob backend.

Rails.application.config.active_job.queue_adapter = Activejob::GoogleCloudTasks::Adapter.new(
  project: 'MY_GOOGLE_CLOUD_TASKS_PROJECT',
  location: 'MY_GOOGLE_CLOUD_TASKS_LOCATION'
)

Second, mount the rack application.

Rails.application.routes.draw do
  mount Activejob::GoogleCloudTasks::Rack, at: Activejob::GoogleCloudTasks::Config.path
end

Write the Job class and code to use it.

Note: perform argument is one and it must be hash.

class SampleJob < ApplicationJob
  queue_as :default
  def perform(args)
    puts "hello, #{args[:name]}!"
  end
end
class SampleController < ApplicationController
  def job
    SampleJob.perform_later({name: 'ken'})
  end
end

kawabatas/rails_activejob_sample is rails example.

Configuration

Adapter

Rails.application.config.active_job.queue_adapter = Activejob::GoogleCloudTasks::Adapter.new(
  project: 'MY_GOOGLE_CLOUD_TASKS_PROJECT',
  location: 'MY_GOOGLE_CLOUD_TASKS_LOCATION',

  cloud_tasks_client: Google::Cloud::Tasks.new(
    version: :v2beta3,
    credentials: 'path/to/keyfile.json'
  )
)

Argument Reference

  • project - (Required) The ID of the Google Cloud project in which the Cloud Tasks belongs.

  • location - (Required) The Location of the Cloud Tasks.

  • cloud_tasks_client - (Optional) The instance of Google::Cloud::Tasks. Please see Google::Cloud::Tasks.new for details. Default: Google::Cloud::Tasks.new(version: :v2beta3)

Config

Activejob::GoogleCloudTasks::Config.path = '/foo'
  • path - (Optional) The path which the Cloud Tasks service forwards the task request to the worker. Default: /activejobs

Development

$ bundle exec rake spec

Contributing

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

License

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

activejob-google_cloud_tasks's People

Contributors

kawabatas avatar dependabot-support avatar satococoa avatar dependabot-preview[bot] avatar

Stargazers

Dmytro Budnyk avatar Luca D'Alessandro avatar  avatar  avatar Shoei Takamaru avatar Kiyoaki Yoshioka avatar Tiago Guedes avatar Giovanni Kock Bonetti avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.