Module: Uh::WM::Workers

Defined in:
lib/uh/wm/workers.rb,
lib/uh/wm/workers/mux.rb,
lib/uh/wm/workers/base.rb,
lib/uh/wm/workers/kqueue.rb,
lib/uh/wm/workers/blocking.rb

Defined Under Namespace

Classes: Base, Blocking, KQueue, Mux

Constant Summary collapse

FACTORIES =
{
  block:  ->(options) { Blocking.new(**options) },
  kqueue: ->(options) { KQueue.new(**options) },
  mux:    ->(options) { Mux.new(**options) }
}.freeze

Class Method Summary collapse

Class Method Details

.build(type, options = {}) ⇒ Object



19
20
21
22
# File 'lib/uh/wm/workers.rb', line 19

def build type, options = {}
  (FACTORIES[type] or fail ArgumentError, "unknown worker: `#{type}'")
    .call options
end

.type?(type) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/uh/wm/workers.rb', line 15

def type? type
  FACTORIES.key? type
end

.typesObject



11
12
13
# File 'lib/uh/wm/workers.rb', line 11

def types
  FACTORIES.keys
end