initial sharding stubs

test plan: n/a

Change-Id: I0d2d28f4afad7988f340190947855f610ac56ad6
Reviewed-on: https://gerrit.instructure.com/7756
Tested-by: Hudson <hudson@instructure.com>
Reviewed-by: Bracken Mosbacker <bracken@instructure.com>
This commit is contained in:
Cody Cutrer 2011-12-29 15:03:03 -07:00
parent de92da47b0
commit cc8ef7941c
2 changed files with 60 additions and 0 deletions

View File

@ -0,0 +1,7 @@
# stubs go at the bottom of the autoload path so that a plugin's version will
# be found first
ActiveSupport::Dependencies.autoload_paths.unshift(Rails.root + 'lib/stubs')
# shard also makes modifications to AR, but those can't happen in our AR
# initializer, since it won't be able to find Shard until this initializer runs
Shard

53
lib/stubs/shard.rb Normal file
View File

@ -0,0 +1,53 @@
#
# Copyright (C) 2011 Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
class Shard
def self.stubbed?
true
end
def self.default
@default ||= Shard.new
end
def self.current
default
end
def self.partition_by_shard(array)
yield array
end
def activate
yield
end
def default?
true
end
end
ActiveRecord::Base.class_eval do
def shard
Shard.default
end
def global_id
id
end
end