Class: Hive::Policy
- Inherits:
-
Object
show all
- Defined in:
- lib/hive/policy.rb
Constant Summary
collapse
- DEFAULTS =
{
pool_min_workers: 1,
pool_max_workers: 10,
worker_idle_max_sleep: 64.0,
worker_idle_min_sleep: 0.125,
worker_idle_spin_down: 900,
worker_none_spin_up: 86400,
worker_max_jobs: 100, worker_max_lifetime: 1000, worker_late: 10, worker_hung: 100, storage: :mock,
observers: []
}
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) ⇒ Policy
Returns a new instance of Policy.
20
21
22
23
|
# File 'lib/hive/policy.rb', line 20
def initialize( options = {} )
options = Hash[ options.map { |k,v| [ k.to_sym, v ] } ] @options = DEFAULTS.merge( options )
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *arguments) ⇒ Object
29
30
31
|
# File 'lib/hive/policy.rb', line 29
def method_missing( symbol, *arguments )
@options[symbol.to_sym]
end
|
Class Method Details
.resolve(options_or_policy = {}) ⇒ Object
53
54
55
56
|
# File 'lib/hive/policy.rb', line 53
def resolve( options_or_policy = {} )
options_or_policy.kind_of?(Hive::Policy) ? options_or_policy.dup : new(options_or_policy.dup)
end
|
Instance Method Details
#after_fork ⇒ Object
46
47
48
|
# File 'lib/hive/policy.rb', line 46
def after_fork
(after_forks || []).each { |f| f.call }
end
|
#before_fork ⇒ Object
42
43
44
|
# File 'lib/hive/policy.rb', line 42
def before_fork
(before_forks || []).each { |f| f.call }
end
|
#dup ⇒ Object
38
39
40
|
# File 'lib/hive/policy.rb', line 38
def dup
self.class.new( @options.dup )
end
|
#merge(options = {}) ⇒ Object
33
34
35
36
|
# File 'lib/hive/policy.rb', line 33
def merge( options = {} )
@options.merge!( options )
self
end
|