Prototype two workers: blocking and multiplexing

This commit is contained in:
Thibault Jouan
2015-04-17 21:25:00 +00:00
parent 0164b52465
commit 0176ab0010
5 changed files with 89 additions and 0 deletions

21
lib/uh/wm/workers.rb Normal file
View 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