Module: Shinq
- Defined in:
- lib/shinq.rb,
lib/shinq/cli.rb,
lib/shinq/rails.rb,
lib/shinq/client.rb,
lib/shinq/logger.rb,
lib/shinq/launcher.rb,
lib/shinq/statistics.rb,
lib/shinq/configuration.rb,
lib/generators/shinq/worker/worker_generator.rb
Defined Under Namespace
Modules: Generators, Launcher, Statistics
Classes: CLI, Client, Configuration, ConfigurationError, Logger, OptionParseError, Rails
Constant Summary
collapse
- VERSION =
Gem.loaded_specs['shinq'].version.to_s
Class Method Summary
collapse
Class Method Details
.clear_all_connections! ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/shinq.rb', line 35
def self.clear_all_connections!
return unless @connections
@connections.each do |_db_name, connection|
connection && connection.close
end
@connections = {}
end
|
.configuration ⇒ Object
17
18
19
|
# File 'lib/shinq.rb', line 17
def self.configuration
@configuration ||= Shinq::Configuration.new({})
end
|
.configuration=(config) ⇒ Object
.connection(db_name: self.default_db) ⇒ Object
30
31
32
33
|
# File 'lib/shinq.rb', line 30
def self.connection(db_name: self.default_db)
@connections ||= {}
@connections[db_name.to_sym] ||= setup_db_connection(db_name)
end
|
.default_db ⇒ Object
21
22
23
|
# File 'lib/shinq.rb', line 21
def self.default_db
self.configuration.default_db ||= ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development'
end
|
.logger ⇒ Object
43
44
45
|
# File 'lib/shinq.rb', line 43
def self.logger
@logger
end
|
.logger=(log) ⇒ Object
47
48
49
|
# File 'lib/shinq.rb', line 47
def self.logger=(log)
@logger = log
end
|
.setup_db_connection(db_name) ⇒ Object
25
26
27
28
|
# File 'lib/shinq.rb', line 25
def self.setup_db_connection(db_name)
raise Shinq::ConfigurationError unless self.configuration.db_defined?(db_name)
@connections[db_name.to_sym] = Mysql2::Client.new(self.configuration.db_config[db_name])
end
|