Module: HotTub

Defined in:
lib/hot_tub.rb,
lib/hot_tub/pool.rb,
lib/hot_tub/reaper.rb,
lib/hot_tub/version.rb,
lib/hot_tub/sessions.rb,
lib/hot_tub/known_clients.rb

Defined Under Namespace

Modules: KnownClients Classes: Pool, Reaper, Sessions

Constant Summary collapse

GLOBAL_SESSIONS =
Sessions.new(:name => "Global Sessions")
VERSION =
"1.1.0"
@@logger =
nil
@@trace =
false
@@log_trace =
false

Class Method Summary collapse

Class Method Details

.add(url, opts = {}, &client_block) ⇒ Object



72
73
74
# File 'lib/hot_tub.rb', line 72

def self.add(url,opts={}, &client_block)
  self.get_or_set(url,opts, &client_block)
end

.get_or_set(url, opts = {}, &client_block) ⇒ Object

Gets or sets a new Pool in the global sessions



63
64
65
# File 'lib/hot_tub.rb', line 63

def self.get_or_set(url,opts={}, &client_block)
  GLOBAL_SESSIONS.get_or_set(url, opts, &client_block)
end

.jruby?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/hot_tub.rb', line 42

def self.jruby?
  (defined?(JRUBY_VERSION))
end

.log_trace?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/hot_tub.rb', line 34

def self.log_trace?
  @@log_trace
end

.loggerObject



15
16
17
# File 'lib/hot_tub.rb', line 15

def self.logger
  @@logger
end

.logger=(logger) ⇒ Object



19
20
21
22
# File 'lib/hot_tub.rb', line 19

def self.logger=logger
  @@logger = logger
  set_log_trace
end

.new(opts = {}, &client_block) ⇒ Object



81
82
83
84
# File 'lib/hot_tub.rb', line 81

def self.new(opts={}, &client_block)
  warn "[DEPRECATION] `HotTub.new` is deprecated.  Please use `HotTub::Pool.new` instead."
  Pool.new(opts,&client_block)
end

.rbx?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/hot_tub.rb', line 46

def self.rbx?
  (defined?(RUBY_ENGINE) and RUBY_ENGINE == 'rbx')
end

.reset!Object

Resets global sessions, useful in forked environments Does not reset one-off pools or one-off sessions



52
53
54
# File 'lib/hot_tub.rb', line 52

def self.reset!
  GLOBAL_SESSIONS.reset!
end

.run(url, &run_block) ⇒ Object



76
77
78
79
# File 'lib/hot_tub.rb', line 76

def self.run(url ,&run_block)
  pool = GLOBAL_SESSIONS.fetch(url)
  pool.run(&run_block)
end

.sessionsObject



38
39
40
# File 'lib/hot_tub.rb', line 38

def self.sessions
  GLOBAL_SESSIONS
end

.set_log_traceObject



30
31
32
# File 'lib/hot_tub.rb', line 30

def self.set_log_trace
  @@log_trace = (!@@logger.nil? && @@trace)
end

.shutdown!Object

Shuts down global sessions, useful in forked environments Does not shutdown one-off pools or one-off sessions



58
59
60
# File 'lib/hot_tub.rb', line 58

def self.shutdown!
  GLOBAL_SESSIONS.shutdown!
end

.stage(url, opts = {}, &client_block) ⇒ Object

Sets a options for new pool for lazy loading



68
69
70
# File 'lib/hot_tub.rb', line 68

def self.stage(url,opts={}, &client_block)
  GLOBAL_SESSIONS.stage(url, opts, &client_block)
end

.trace=(trace) ⇒ Object

Set to true for more detail logs



25
26
27
28
# File 'lib/hot_tub.rb', line 25

def self.trace=trace
  @@trace = trace
  set_log_trace
end