Class: Garcon::Configuration
Overview
Configuration instance
Instance Attribute Summary collapse
-
#auto_terminate_all_executors ⇒ Boolean
Defines if global executors should be auto-terminated with an ‘at_exit` callback.
-
#auto_terminate_global_executors ⇒ Boolean
Defines if global executors should be auto-terminated with an ‘at_exit` callback.
-
#global_fast_executor ⇒ Object
readonly
Global thread pool optimized for short, fast operations.
-
#global_io_executor ⇒ Object
readonly
Global thread pool optimized for long, blocking (IO) tasks.
-
#global_timer_set ⇒ Object
readonly
Global thread pool user for global timers.
-
#max_threads ⇒ Object
Access the maximum number of threads setting for this instance.
-
#min_threads ⇒ Object
Access the minimum number of threads setting for this instance.
Instance Method Summary collapse
-
#crypto(&block) ⇒ Crypto
private
Access the crypto for this instance and optional configure a new crypto with the passed block.
-
#initialize(opts = {}) {|_self| ... } ⇒ undefined
constructor
private
Initialized a configuration instance.
-
#secret(&block) ⇒ Secret
private
Access the secret stash hash cash store for this instance and optional configure a new secret with the passed block.
- #to_h ⇒ Object private
Constructor Details
#initialize(opts = {}) {|_self| ... } ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialized a configuration instance.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/garcon/configuration.rb', line 68 def initialize(opts = {}) @min_threads = opts.fetch(:min_threads, [2, Garcon.processor_count].max) @max_threads = opts.fetch(:max_threads, Garcon.processor_count * 100) @crypto = Crypto::Configuration.new @secret = Secret::Configuration.new @auto_terminate_global_executors = AtomicBoolean.new(true) @auto_terminate_all_executors = AtomicBoolean.new(true) @global_fast_executor = Delay.new do Garcon.new_fast_executor( stop_on_exit: @auto_terminate_global_executors.value) end @global_io_executor = Delay.new do Garcon.new_io_executor( stop_on_exit: @auto_terminate_global_executors.value) end @global_timer_set = Delay.new do TimerSet.new(stop_on_exit: @auto_terminate_global_executors.value) end yield self if block_given? end |
Instance Attribute Details
#auto_terminate_all_executors ⇒ Boolean
Returns Defines if global executors should be auto-terminated with an ‘at_exit` callback. When set to `false` it will be the application programmer’s responsibility to ensure that the global thread pools are shutdown properly prior to application exit.
43 44 45 |
# File 'lib/garcon/configuration.rb', line 43 def auto_terminate_all_executors @auto_terminate_all_executors end |
#auto_terminate_global_executors ⇒ Boolean
Returns Defines if global executors should be auto-terminated with an ‘at_exit` callback. When set to `false` it will be the application programmer’s responsibility to ensure that the global thread pools are shutdown properly prior to application exit.
36 37 38 |
# File 'lib/garcon/configuration.rb', line 36 def auto_terminate_global_executors @auto_terminate_global_executors end |
#global_fast_executor ⇒ Object (readonly)
Global thread pool optimized for short, fast operations.
49 50 51 |
# File 'lib/garcon/configuration.rb', line 49 def global_fast_executor @global_fast_executor end |
#global_io_executor ⇒ Object (readonly)
Global thread pool optimized for long, blocking (IO) tasks.
55 56 57 |
# File 'lib/garcon/configuration.rb', line 55 def global_io_executor @global_io_executor end |
#global_timer_set ⇒ Object (readonly)
Global thread pool user for global timers.
61 62 63 |
# File 'lib/garcon/configuration.rb', line 61 def global_timer_set @global_timer_set end |
#max_threads ⇒ Object
Access the maximum number of threads setting for this instance.
29 30 31 |
# File 'lib/garcon/configuration.rb', line 29 def max_threads @max_threads end |
#min_threads ⇒ Object
Access the minimum number of threads setting for this instance.
26 27 28 |
# File 'lib/garcon/configuration.rb', line 26 def min_threads @min_threads end |
Instance Method Details
#crypto(&block) ⇒ Crypto
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Access the crypto for this instance and optional configure a new crypto with the passed block.
107 108 109 110 |
# File 'lib/garcon/configuration.rb', line 107 def crypto(&block) @crypto = Crypto::Configuration.new(&block) if block_given? @crypto end |
#secret(&block) ⇒ Secret
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Access the secret stash hash cash store for this instance and optional configure a new secret with the passed block.
118 119 120 121 |
# File 'lib/garcon/configuration.rb', line 118 def secret(&block) @secret = Secret::Configuration.new(&block) if block_given? @secret end |
#to_h ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/garcon/configuration.rb', line 124 def to_h { crypto: crypto, secret: secret, blender: blender, min_threads: min_threads, max_threads: max_threads, global_timer_set: global_timer_set, global_io_executor: global_io_executor, global_fast_executor: global_fast_executor, auto_terminate_all_executors: auto_terminate_all_executors, auto_terminate_global_executors: auto_terminate_global_executors }.freeze end |