Module: RightSharding
- Defined in:
- lib/right_sharding/shard_handler.rb,
lib/right_sharding.rb,
lib/right_sharding/routing.rb,
lib/right_sharding/base_proxy.rb,
lib/right_sharding/user_api_proxy.rb,
lib/right_sharding/current_account.rb,
lib/right_sharding/instance_api_proxy.rb
Overview
-- Copyright (c) 2012 RightScale, Inc, All Rights Reserved Worldwide.
THIS PROGRAM IS CONFIDENTIAL AND PROPRIETARY TO RIGHTSCALE AND CONSTITUTES A VALUABLE TRADE SECRET. Any unauthorized use, reproduction, modification, or disclosure of this program is strictly prohibited. Any use of this program by an authorized licensee is strictly subject to the terms and conditions, including confidentiality obligations, set forth in the applicable License Agreement between RightScale, Inc. and the licensee. ++
Defined Under Namespace
Modules: Rack, Routing, ShardHandler
Class Method Summary collapse
Class Method Details
.activate(config, options = {}) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/right_sharding.rb', line 14 def self.activate(config, = {}) # Ensure that this super-important module attribute is set before any init code attempts to use it! RightSharding::Routing.skip_shard_routing_callback = .delete(:skip_shard_routing_callback) # The library uses only the CurrentAccount middleware. current_account_only = .delete(:current_account_only) # Add middleware to update the global_session account based on received headers/params. # Must come after GlobalSession. config.middleware.insert_after ::Rack::MethodOverride, ::Rack::CurrentAccount, unless current_account_only # Add the middleware to intercept the requests and reroute users to the appropriate shards # It must come after GlobalSession and CurrentAccount; GlobalSession will be used for the # legacy path. config.middleware.insert_after ::Rack::CurrentAccount, ::Rack::ShardRouting, # Add the middleware to proxy the instance facing api to the appropriate shards config.middleware.insert_before ::Rack::ShardRouting, ::Rack::ShardInstanceApiProxy, # This will proxy the specific accounts passed in the options variable. config.middleware.insert_after(::Rack::ShardInstanceApiProxy, ::Rack::ShardUserApiProxy, ) end rescue NoMethodError => e raise NoMethodError, "GlobalSession must be used first." end |