Class: Async::MySQL::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/async/mysql/pool.rb

Instance Method Summary collapse

Constructor Details

#initialize(connection_string, task: Task.current) ⇒ Proxy

Returns a new instance of Proxy.



30
31
32
33
34
35
36
37
38
# File 'lib/async/mysql/pool.rb', line 30

def initialize(connection_string, task: Task.current)
	@connection_string = connection_string
	
	pools = task.reactor.mysql_pools ||= {}
	
	@pool = pools[@connection_string] ||= Pool.new do
		Connection.new(@connection_string)
	end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object



56
57
58
59
60
# File 'lib/async/mysql/pool.rb', line 56

def method_missing(*args, &block)
	@pool.acquire do |connection|
		connection.send(*args, &block)
	end
end

Instance Method Details

#async_exec(*args) ⇒ Object



44
45
46
47
48
# File 'lib/async/mysql/pool.rb', line 44

def async_exec(*args)
	@pool.acquire do |connection|
		connection.async_exec(*args)
	end
end

#closeObject



40
41
42
# File 'lib/async/mysql/pool.rb', line 40

def close
	@pool.close
end

#respond_to?(*args) ⇒ Boolean

Returns:

  • (Boolean)


50
51
52
53
54
# File 'lib/async/mysql/pool.rb', line 50

def respond_to?(*args)
	@pool.acquire do |connection|
		connection.respond_to?(*args)
	end
end