Merge branch 'elasticsearch'

This commit is contained in:
Seth Call 2012-11-10 19:08:00 -06:00
commit 3c8761198e
4 changed files with 15 additions and 22 deletions

View File

@ -15,6 +15,8 @@ gem 'eventmachine'
gem 'amqp'
gem 'tire'
gem 'will_paginate'
gem 'actionmailer'
gem 'sendgrid'
group :test do
gem 'jam_db', :path=> "#{workspace}/jam-db/target/ruby_package"

View File

@ -6,13 +6,19 @@ require "logging"
require "tire"
require "will_paginate"
require "will_paginate/active_record"
require "action_mailer"
require "sendgrid"
require "jam_ruby/errors/permission_error"
require "jam_ruby/errors/state_error"
require "jam_ruby/errors/jam_argument_error"
require "jam_ruby/mq_router"
require "jam_ruby/base_manager"
require "jam_ruby/user_manager"
require "jam_ruby/connection_manager"
require "jam_ruby/version"
require "jam_ruby/environment"
require "jam_ruby/init"
require "jam_ruby/app/mailers/user_mailer"
require "jam_ruby/tire_tasks"
require "jam_ruby/message_factory"
require "jam_ruby/models/genre"

View File

@ -1,5 +1,5 @@
module JamRuby
# All writes should occur through the ConnectionManager
# All writes should occur through the ConnectionManager for the connection table
# Reads can occur freely elsewhere, though
# Because connections are tied to the websocket-connection and we bookkeep them in the database purely
# for 'SQL convenience', this is a obvious place we can go away from a database
@ -11,19 +11,15 @@ module JamRuby
# This may make sense in the short term if we are still managing connections in the database, but
# we move to the node-js in the websocket gateway (because the websocket gateway needs to call some of these methods).
# Or of course we could just port the relevant methods to node-js
class ConnectionManager
class ConnectionManager < BaseManager
attr_accessor :mq_router, :pg_conn
attr_accessor :mq_router
def initialize(options={})
super(options)
@log = Logging.logger[self]
@mq_router = MQRouter.new
@pg_conn = options[:conn]
@message_factory = MessageFactory.new
unless PG.threadsafe?
raise Exception, "a non-threadsafe build of libpq is present."
end
end
def update_staleness()
@ -248,20 +244,6 @@ module JamRuby
return friend_ids
end
# Creates a connection manager, and associates the connection created by active_record with ourselves
def self.active_record_transaction(&block)
connection_manager = ConnectionManager.new
ActiveRecord::Base.connection_pool.with_connection do |connection|
# create a transaction, and pass the current connection to ConnectionManager.
# this lets the entire operation work with the same transaction,
# across Rails ActiveRecord and the pg-gem based code in ConnectionManager.
connection_manager.pg_conn = connection.instance_variable_get("@connection")
connection.transaction do
block.call(connection_manager)
end
end
end
end
end

View File

@ -19,6 +19,9 @@ require 'factories'
include JamRuby
# put ActionMailer into test mode
ActionMailer::Base.delivery_method = :test
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'