Prototype two workers: blocking and multiplexing
This commit is contained in:
21
lib/uh/wm/workers.rb
Normal file
21
lib/uh/wm/workers.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
module Uh
|
||||
module WM
|
||||
module Workers
|
||||
FACTORIES = {
|
||||
block: ->(options) { Blocking.new(options) },
|
||||
mux: ->(options) { Mux.new(options) }
|
||||
}.freeze
|
||||
|
||||
class << self
|
||||
def types
|
||||
FACTORIES.keys
|
||||
end
|
||||
|
||||
def build type, **options
|
||||
(FACTORIES[type] or fail ArgumentError, "unknown worker: `#{type}'")
|
||||
.call options
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user