module ActiveRecord::Core

def self.current_shard

end
ActiveRecord::Base.current_shard #=> :one
ActiveRecord::Base.connected_to(role: :writing, shard: :one) do

end
ActiveRecord::Base.current_shard #=> :default
ActiveRecord::Base.connected_to(role: :reading) do

Returns the symbol representing the current connected shard.
def self.current_shard
  connected_to_stack.reverse_each do |hash|
    return hash[:shard] if hash[:shard] && hash[:klasses].include?(Base)
    return hash[:shard] if hash[:shard] && hash[:klasses].include?(connection_class_for_self)
  end
  default_shard
end