Class: Bricolage::StreamingLoad::ChunkRouter
- Inherits:
-
Object
- Object
- Bricolage::StreamingLoad::ChunkRouter
- Defined in:
- lib/bricolage/streamingload/chunkrouter.rb
Defined Under Namespace
Classes: Route
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(routes) ⇒ ChunkRouter
constructor
A new instance of ChunkRouter.
- #route(msg) ⇒ Object
Constructor Details
#initialize(routes) ⇒ ChunkRouter
Returns a new instance of ChunkRouter.
18 19 20 |
# File 'lib/bricolage/streamingload/chunkrouter.rb', line 18 def initialize(routes) @routes = routes end |
Class Method Details
.for_config(configs) ⇒ Object
12 13 14 15 16 |
# File 'lib/bricolage/streamingload/chunkrouter.rb', line 12 def ChunkRouter.for_config(configs) new(configs.map {|c| Route.new(url: c.fetch('url'), schema: c.fetch('schema'), table: c.fetch('table')) }) end |
Instance Method Details
#route(msg) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/bricolage/streamingload/chunkrouter.rb', line 22 def route(msg) @routes.each do |route| stream_name = route.match(msg.url) return IncomingChunk.new(msg, stream_name) if stream_name end raise ChunkRoutingFailed, "could not detect stream name: #{url.inspect}" end |