Use new follower API added to Travis::Model

This commit is contained in:
Piotr Sarnacki 2013-09-04 16:22:32 +02:00
parent 130eaa7c3d
commit 2492d710e1
4 changed files with 4 additions and 33 deletions

View File

@ -22,8 +22,6 @@ gem 'memcachier'
gem 'pry'
gem 'metriks', '0.9.9.5'
gem 'ar-octopus', github: 'travis-ci/octopus', require: nil
group :test do
gem 'rspec', '~> 2.13'
gem 'factory_girl', '~> 2.4.0'

View File

@ -21,14 +21,6 @@ GIT
yard-sinatra (1.0.0)
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
remote: git://github.com/travis-ci/travis-core.git
revision: f3c2b689fd8ff1986501259f270eba2bc705a9ad
@ -282,7 +274,6 @@ PLATFORMS
ruby
DEPENDENCIES
ar-octopus!
bunny (~> 0.8.0)
dalli
database_cleaner (~> 0.8.0)

View File

@ -159,26 +159,8 @@ module Travis::Api
def self.setup_database_connections
Travis::Database.connect
return unless Travis.config.use_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
if Travis.config.database_follower
Travis::Model.establish_follower_connection(Travis.config.database_follower)
end
end

View File

@ -4,8 +4,8 @@ class Travis::Api::App
module Helpers
module DbFollower
def prefer_follower
if Travis.config.use_database_follower?
Octopus.using(:follower) do
if Travis::Features.feature_active?(:api_use_db_follower)
Travis::Model.using_follower do
yield
end
else