diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 41c814ef..77965ddc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -45,7 +45,7 @@ jobs: run: | sudo apt-get -yqq install libpq-dev postgresql-client createdb que-test - gem install bundler + gem install bundler --version '~> 2.4.22' bundle install --jobs 4 --retry 3 USE_RAILS=true bundle exec rake test bundle exec rake test diff --git a/CHANGELOG.md b/CHANGELOG.md index 68d4ee3e..0524328a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ -- [2.3.0 \(2023-10-10\)](#230-2023-10-16) +- [2.4.0 \(2024-08-21\)](#240-2024-08-21) +- [2.3.0 \(2023-10-16\)](#230-2023-10-16) - [2.2.1 \(2023-04-28\)](#221-2023-04-28) - [2.2.0 \(2022-08-29\)](#220-2022-08-29) - [2.1.0 \(2022-08-25\)](#210-2022-08-25) @@ -58,7 +59,18 @@ +## 2.4.0 (2024-08-21) + +- **Fixed**: + + Fixed `Que.server?` method returning the inverse of what was intended. This method can be used to determine whether Que is running as a server process (run from the Que CLI). [#426](https://github.com/que-rb/que/pull/426), context in [#382](https://github.com/que-rb/que/pull/382) +- **Added**: + + Added logging of full job details rather than just `job_id`. Note that the hash `Que.log_formatter` is called with no longer contains `:job_id`; instead it now has a `:job` hash including `:id`. [#428](https://github.com/que-rb/que/pull/428) +- **Documentation**: + + Improved wording of transaction recommendation in the readme for destroying a job. [#417](https://github.com/que-rb/que/pull/417) + + Added [que-view](https://github.com/kortirso/que-view) to the list of Que-compatible projects in the readme: "A Rails engine-based UI for inspecting your job queue". [#418](https://github.com/que-rb/que/pull/418) + ## 2.3.0 (2023-10-16) + - **Fixed**: + Don't clear `ActiveRecord` connections when `run_synchronously` is enabled [#393](https://github.com/que-rb/que/pull/393) diff --git a/Dockerfile b/Dockerfile index cc85d0da..f10a61f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ RUN apt-get update \ && apt-get install -y libpq-dev \ && rm -rf /var/lib/apt/lists/* -ENV RUBY_BUNDLER_VERSION 2.3.7 +ENV RUBY_BUNDLER_VERSION 2.4.22 RUN gem install bundler -v $RUBY_BUNDLER_VERSION ENV BUNDLE_PATH /usr/local/bundle diff --git a/README.md b/README.md index df843f13..91261691 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ class ChargeCreditCard < Que::Job # It's best to destroy the job in the same transaction as any other # changes you make. Que will mark the job as destroyed for you after the - # run method if you don't do it yourself, but if your job writes to the DB + # run method if you don't do it yourself; however if your job writes to the DB # but doesn't destroy the job in the same transaction, it's possible that # the job could be repeated in the event of a crash. destroy @@ -189,6 +189,7 @@ There are a couple ways to do testing. You may want to set `Que::Job.run_synchro These projects are tested to be compatible with Que 1.x: - [que-web](https://github.com/statianzo/que-web) is a Sinatra-based UI for inspecting your job queue. +- [que-view](https://github.com/kortirso/que-view) is a Rails engine-based UI for inspecting your job queue. - [que-scheduler](https://github.com/hlascelles/que-scheduler) lets you schedule tasks using a cron style config file. - [que-locks](https://github.com/airhorns/que-locks) lets you lock around job execution for so only one job runs at once for a set of arguments. - [que-unique](https://github.com/bambooengineering/que-unique) provides fast in-memory `enqueue` deduping. diff --git a/docs/README.md b/docs/README.md index 4b5e1f46..fef84b67 100644 --- a/docs/README.md +++ b/docs/README.md @@ -349,7 +349,7 @@ que --worker-count 1 By default, Que logs important information in JSON to either Rails' logger (when running in a Rails web process) or STDOUT (when running via the `que` executable). So, your logs will look something like: ``` -I, [2017-08-12T05:07:31.094201 #4687] INFO -- : {"lib":"que","hostname":"lovelace","pid":21626,"thread":21471100,"event":"job_worked","job_id":6157665,"elapsed":0.531411} +I, [2017-08-12T05:07:31.094201 #4687] INFO -- : {"lib":"que","hostname":"lovelace","pid":98240,"thread":42660,"event":"job_worked","job":{"priority":1,"run_at":"2024-07-24T11:07:10.056514Z","id":2869885284504751564,"job_class":"WorkerJob","error_count":0,"last_error_message":null,"queue":"default","last_error_backtrace":null,"finished_at":null,"expired_at":null,"args":[1],"data":{},"job_schema_version":2,"kwargs":{}},"elapsed":0.001356} ``` Of course you can have it log wherever you like: diff --git a/lib/que.rb b/lib/que.rb index 89459472..99c2686c 100644 --- a/lib/que.rb +++ b/lib/que.rb @@ -80,7 +80,7 @@ def default_queue end def server? - defined?(Que::CommandLineInterface).nil? + !defined?(Que::CommandLineInterface).nil? end # Support simple integration with many common connection pools. diff --git a/lib/que/version.rb b/lib/que/version.rb index ea6873f8..1da80ed9 100644 --- a/lib/que/version.rb +++ b/lib/que/version.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module Que - VERSION = '2.3.0' + VERSION = '2.4.0' def self.job_schema_version 2 diff --git a/lib/que/worker.rb b/lib/que/worker.rb index 91e7d02a..00ef19aa 100644 --- a/lib/que/worker.rb +++ b/lib/que/worker.rb @@ -114,7 +114,7 @@ def work_job(metajob) if VALID_LOG_LEVELS.include?(log_level) log_message = { level: log_level, - job_id: metajob.id, + job: metajob.job, elapsed: elapsed, } @@ -133,7 +133,7 @@ def work_job(metajob) Que.log( level: :debug, event: :job_errored, - job_id: metajob.id, + job: metajob.job, error: { class: error.class.to_s, message: error.message, diff --git a/spec/que/worker_spec.rb b/spec/que/worker_spec.rb index 435e213f..c5851701 100644 --- a/spec/que/worker_spec.rb +++ b/spec/que/worker_spec.rb @@ -74,7 +74,8 @@ def finished_job_ids events = logged_messages.select{|m| m[:event] == 'job_worked'} assert_equal 3, events.count - assert_equal job_ids, events.map{|m| m[:job_id]} + assert_equal [1, 2, 3], events.map{|m| m.dig(:job, :priority) } + assert_equal job_ids, events.map{|m| m.dig(:job, :id) } end it "should handle namespaced job subclasses" do @@ -228,7 +229,7 @@ def assert_retry_cadence( # Error should be logged. event = events.first - assert_equal job_ids.first, event[:job_id] + assert_equal job_ids.first, event.dig(:job, :id) assert_equal "RuntimeError: Error!", event[:error] # Errored job should still be in the DB.