Use new follower API added to Travis::Model
This commit is contained in:
parent
130eaa7c3d
commit
2492d710e1
2
Gemfile
2
Gemfile
|
@ -22,8 +22,6 @@ gem 'memcachier'
|
||||||
gem 'pry'
|
gem 'pry'
|
||||||
gem 'metriks', '0.9.9.5'
|
gem 'metriks', '0.9.9.5'
|
||||||
|
|
||||||
gem 'ar-octopus', github: 'travis-ci/octopus', require: nil
|
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem 'rspec', '~> 2.13'
|
gem 'rspec', '~> 2.13'
|
||||||
gem 'factory_girl', '~> 2.4.0'
|
gem 'factory_girl', '~> 2.4.0'
|
||||||
|
|
|
@ -21,14 +21,6 @@ GIT
|
||||||
yard-sinatra (1.0.0)
|
yard-sinatra (1.0.0)
|
||||||
yard (~> 0.7)
|
yard (~> 0.7)
|
||||||
|
|
||||||
GIT
|
|
||||||
remote: git://github.com/travis-ci/octopus.git
|
|
||||||
revision: 6e68a6c112df4de4a8495a1058be3d7cdd7f9f3d
|
|
||||||
specs:
|
|
||||||
ar-octopus (0.6.0)
|
|
||||||
activerecord (>= 3.0.0, < 4.0)
|
|
||||||
activesupport (>= 3.0.0, < 4.0)
|
|
||||||
|
|
||||||
GIT
|
GIT
|
||||||
remote: git://github.com/travis-ci/travis-core.git
|
remote: git://github.com/travis-ci/travis-core.git
|
||||||
revision: f3c2b689fd8ff1986501259f270eba2bc705a9ad
|
revision: f3c2b689fd8ff1986501259f270eba2bc705a9ad
|
||||||
|
@ -282,7 +274,6 @@ PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
ar-octopus!
|
|
||||||
bunny (~> 0.8.0)
|
bunny (~> 0.8.0)
|
||||||
dalli
|
dalli
|
||||||
database_cleaner (~> 0.8.0)
|
database_cleaner (~> 0.8.0)
|
||||||
|
|
|
@ -159,26 +159,8 @@ module Travis::Api
|
||||||
|
|
||||||
def self.setup_database_connections
|
def self.setup_database_connections
|
||||||
Travis::Database.connect
|
Travis::Database.connect
|
||||||
|
if Travis.config.database_follower
|
||||||
return unless Travis.config.use_database_follower?
|
Travis::Model.establish_follower_connection(Travis.config.database_follower)
|
||||||
require 'octopus'
|
|
||||||
|
|
||||||
if Travis.env == 'production' || Travis.env == 'staging'
|
|
||||||
puts "Setting up the DB follower as a read slave"
|
|
||||||
|
|
||||||
# Octopus checks for Rails.env, just hardcode enabled?
|
|
||||||
Octopus.instance_eval do
|
|
||||||
def enabled?
|
|
||||||
true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
ActiveRecord::Base.custom_octopus_connection = false
|
|
||||||
|
|
||||||
::Octopus.setup do |config|
|
|
||||||
config.shards = { :follower => Travis.config.database_follower }
|
|
||||||
config.environments = ['production', 'staging']
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ class Travis::Api::App
|
||||||
module Helpers
|
module Helpers
|
||||||
module DbFollower
|
module DbFollower
|
||||||
def prefer_follower
|
def prefer_follower
|
||||||
if Travis.config.use_database_follower?
|
if Travis::Features.feature_active?(:api_use_db_follower)
|
||||||
Octopus.using(:follower) do
|
Travis::Model.using_follower do
|
||||||
yield
|
yield
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue
Block a user