-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
191 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
6.26.0 | ||
6.26.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,3 @@ | ||
require 'pg' | ||
require 'que' | ||
require 'socket' | ||
require 'bugsnag' | ||
require 'active_record' | ||
require_relative "setup-que" | ||
|
||
QUE_VERSION = ENV.fetch("QUE_VERSION") | ||
|
||
Bugsnag.configure do |config| | ||
puts "Configuring `api_key` to #{ENV['BUGSNAG_API_KEY']}" | ||
config.api_key = ENV['BUGSNAG_API_KEY'] | ||
puts "Configuring `endpoint` to #{ENV['BUGSNAG_ENDPOINT']}" | ||
config.endpoint = ENV['BUGSNAG_ENDPOINT'] | ||
end | ||
|
||
postgres_ready = false | ||
attempts = 0 | ||
MAX_ATTEMPTS = 10 | ||
|
||
until postgres_ready || attempts >= MAX_ATTEMPTS | ||
begin | ||
Timeout::timeout(5) { TCPSocket.new('postgres', 5432).close } | ||
|
||
postgres_ready = true | ||
rescue Exception | ||
attempts += 1 | ||
sleep 1 | ||
end | ||
end | ||
|
||
raise 'postgres was not ready in time!' unless postgres_ready | ||
|
||
ActiveRecord::Base.establish_connection( | ||
adapter: 'postgresql', | ||
database: 'postgres', | ||
username: 'postgres', | ||
password: 'test_password', | ||
host: 'postgres' | ||
) | ||
|
||
Que.connection = ActiveRecord | ||
Que.migrate!(version: Que::Migrations::CURRENT_VERSION) | ||
|
||
# Workaround a bug in que/pg | ||
# see https://github.com/que-rb/que/issues/247 | ||
if QUE_VERSION == '0.14' | ||
Que::Adapters::Base::CAST_PROCS[1184] = lambda do |value| | ||
case value | ||
when Time then value | ||
when String then Time.parse(value) | ||
else raise "Unexpected time class: #{value.class} (#{value.inspect})" | ||
end | ||
end | ||
end | ||
|
||
class UnhandledJob < Que::Job | ||
def run | ||
raise RuntimeError.new("Unhandled error") | ||
end | ||
|
||
def handle_error(error) | ||
destroy | ||
end | ||
end | ||
|
||
class HandledJob < Que::Job | ||
def run | ||
raise RuntimeError.new("Handled error") | ||
rescue => exception | ||
Bugsnag.notify(exception) | ||
end | ||
end | ||
|
||
case ARGV[0] | ||
when "unhandled" | ||
UnhandledJob.enqueue | ||
when "handled" | ||
HandledJob.enqueue | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require_relative "setup-que" | ||
|
||
query = <<-SQL | ||
SELECT EXISTS ( | ||
SELECT FROM pg_tables WHERE tablename = 'que_jobs' | ||
) AS que_jobs_exists | ||
SQL | ||
|
||
Timeout::timeout(10) do | ||
loop do | ||
break if $connection.exec(query)[0]["que_jobs_exists"] == "t" | ||
|
||
sleep 0.1 | ||
end | ||
end | ||
|
||
case ARGV[0] | ||
when "unhandled" | ||
UnhandledJob.enqueue | ||
when "handled" | ||
HandledJob.enqueue | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
require 'pg' | ||
require 'que' | ||
require 'socket' | ||
require 'bugsnag' | ||
|
||
QUE_VERSION = ENV.fetch("QUE_VERSION") | ||
|
||
Bugsnag.configure do |config| | ||
puts "Configuring `api_key` to #{ENV['BUGSNAG_API_KEY']}" | ||
config.api_key = ENV['BUGSNAG_API_KEY'] | ||
puts "Configuring `endpoint` to #{ENV['BUGSNAG_ENDPOINT']}" | ||
config.endpoint = ENV['BUGSNAG_ENDPOINT'] | ||
end | ||
|
||
postgres_ready = false | ||
attempts = 0 | ||
MAX_ATTEMPTS = 10 | ||
|
||
until postgres_ready || attempts >= MAX_ATTEMPTS | ||
begin | ||
Timeout::timeout(5) { TCPSocket.new('postgres', 5432).close } | ||
|
||
postgres_ready = true | ||
rescue Exception | ||
attempts += 1 | ||
sleep 1 | ||
end | ||
end | ||
|
||
raise 'postgres was not ready in time!' unless postgres_ready | ||
|
||
$connection = PG::Connection.open( | ||
host: 'postgres', | ||
user: 'postgres', | ||
password: 'test_password', | ||
dbname: 'postgres' | ||
) | ||
|
||
if QUE_VERSION == '0.14' | ||
Que.connection = $connection | ||
|
||
# Workaround a bug in que/pg | ||
# see https://github.com/que-rb/que/issues/247 | ||
Que::Adapters::Base::CAST_PROCS[1184] = lambda do |value| | ||
case value | ||
when Time then value | ||
when String then Time.parse(value) | ||
else raise "Unexpected time class: #{value.class} (#{value.inspect})" | ||
end | ||
end | ||
else | ||
Que.connection_proc = ->(&block) { block.call($connection) } | ||
end | ||
|
||
class UnhandledJob < Que::Job | ||
def run | ||
raise RuntimeError.new("Unhandled error") | ||
end | ||
|
||
def handle_error(error) | ||
destroy | ||
end | ||
end | ||
|
||
class HandledJob < Que::Job | ||
def run | ||
raise RuntimeError.new("Handled error") | ||
rescue => exception | ||
Bugsnag.notify(exception) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
features/fixtures/rails_integrations/app/config/application.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.