class Garcon::Configuration

Configuration instance

Attributes

auto_terminate_all_executors[RW]

@!attribute [rw] auto_terminate_all_executors

@return [Boolean] 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.
auto_terminate_global_executors[RW]

@!attribute [rw] auto_terminate_global_executors

@return [Boolean] 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.
global_fast_executor[R]

Global thread pool optimized for short, fast operations.

@!attribute [ro] global_fast_executor

@return [ThreadPoolExecutor] the thread pool
global_io_executor[R]

Global thread pool optimized for long, blocking (IO) tasks.

@!attribute [ro] global_io_executor

@return [ThreadPoolExecutor] the thread pool
global_timer_set[R]

Global thread pool user for global timers.

@!attribute [ro] global_timer_set

@return [Garcon::TimerSet] the thread pool
max_threads[RW]

Access the maximum number of threads setting for this instance.

min_threads[RW]

Access the minimum number of threads setting for this instance.

Public Class Methods

new(opts = {}) { |self| ... } click to toggle source

Initialized a configuration instance.

@return [undefined]

@api private

# 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

Public Instance Methods

crypto(&block) click to toggle source

Access the crypto for this instance and optional configure a new crypto with the passed block.

@example

Garcon.config do |c|
  c.crypto.password = "!mWh0!s@y!m"
  c.crypto.salt     = "9e5f851900cad8892ac8b737b7370cbe"
end

@return [Crypto]

@api private

# File lib/garcon/configuration.rb, line 107
def crypto(&block)
  @crypto = Crypto::Configuration.new(&block) if block_given?
  @crypto
end
secret(&block) click to toggle source

Access the secret stash hash cash store for this instance and optional configure a new secret with the passed block.

@return [Secret]

@api private

# File lib/garcon/configuration.rb, line 118
def secret(&block)
  @secret = Secret::Configuration.new(&block) if block_given?
  @secret
end
to_h() click to toggle source

@api private

# 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