Skip to content

Commit

Permalink
Merge branch 'que-rb:master' into activerecord_deprecation_warning
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgi authored Sep 4, 2024
2 parents dcdbe94 + 51403c0 commit 03c85b2
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

<!-- MarkdownTOC autolink=true -->

- [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)
Expand Down Expand Up @@ -58,7 +59,18 @@

<!-- /MarkdownTOC -->

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

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion lib/que.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib/que/version.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module Que
VERSION = '2.3.0'
VERSION = '2.4.0'

def self.job_schema_version
2
Expand Down
4 changes: 2 additions & 2 deletions lib/que/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand All @@ -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,
Expand Down
5 changes: 3 additions & 2 deletions spec/que/worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 03c85b2

Please sign in to comment.