Giter Club home page Giter Club logo

activejob-google_cloud_tasks-http's People

Contributors

hibariya avatar jaredlt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

activejob-google_cloud_tasks-http's Issues

Authenticating Rack app

In the README, it states the following:

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

I am looking to add a simple HTTP Basic AUTH to the rack app, but can't see an obvious way to allow Google Tasks API to specify these credentials when posting to the jobs URL.

Unable to access standard rails logger from rack app

Hi @hibariya, great gem. Cloud Tasks look like they'll make my async tasks way simpler and cheaper to host!

I'm having trouble with some of my jobs failing however and don't seem to be seeing any output in the normal Rails log. I'm assuming that's because Rack is unable to access the Rails loggers, but I'm new to mounting Rack apps inside Rails ones so I apologize if I'm just confused.

Is there an easy way to expose the Rails logger to your Rack component? Alternately, would you be open to a PR which extracted the logic for running the jobs from your Rack component so I could mix it into a Rails controller?

Thank-you, and please let me know if you need more specific information to give an answer. I'm away from my code right now but can get you code samples later.

Cheers!

Getting errors with new API

I'm receiving the following:

ArgumentError (wrong number of arguments (given 3, expected 0; required keywords: project, location, queue))

This is when adapter tries to call queue_path. This is likely due to changes in Google's Ruby libraries.

Error when building app in Docker container and running assets:precompile

I build my app in a Docker container and use assets:precompile so the app has faster cold starts. When deploying this on production I hit an error because the environment variable I use for Google credentials was not available for the precompile step (assets:precompile runs all config and initializers).

Error in Docker build:

Step #1: Step 17/23 : RUN SECRET_KEY_BASE=1 bundle exec rake assets:precompile
Step #1:  ---> Running in c8abbe14a1b3
Step #1: rake aborted!
Step #1: TypeError: no implicit conversion of nil into String
Step #1: /usr/src/app/config/environments/production.rb:125:in `block in <top (required)>'

relevant production.rb snippet (with some sensitive data obscured):

    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.new(
        version: :v2beta3,
        credentials: JSON.parse(ENV["GOOGLE_CLOUD_PRODUCTION_KEYFILE"]) # production.rb:125
      )
    )

The environment variable does not exist yet, nor do I want to include it in the build steps. It's annoying because this is being called by assets:precompile which in no way affects Active Job or Google Cloud Tasks. Ideally it just wouldn't run this at all.

After a few too many hours of frustration I came across a reasonable workaround (via https://stackoverflow.com/a/58017606/3471900):

  unless ARGV.include?("assets:precompile") # wrap the config so it doesn't run when assets:precompile is called
    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.new(
        version: :v2beta3,
        credentials: JSON.parse(ENV["GOOGLE_CLOUD_PRODUCTION_KEYFILE"])
      )
    )
  end

Ideally this would be handled natively by the gem, but if not, perhaps adding a section to the readme or wiki would help others and future me :) Quick draft suggestion:

Error when calling assets:precompile?

If 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 will error. To solve this, wrap the queue_adapter config in a unless ARGV.include?("assets:precompile") condition. Eg.

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',
    # ...
  )
end

PS. Thank you for the gem! It works great and got me up and running with Cloud Tasks super quickly :)

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.