Module: Langis::Dsl
- Defined in:
- lib/langis/dsl.rb
Overview
Module that implements the Domain Specific Language which is used to define Langis publish-subscribe routes.
Defined Under Namespace
Classes: IntakeConfig, PipesConfig, PipingConfigError, RackishConfig
Class Method Summary collapse
-
.langis_plumbing(&block) ⇒ PipesConfig
Method to parse the configuration of the routes.
Class Method Details
.langis_plumbing(&block) ⇒ PipesConfig
Method to parse the configuration of the routes.
config = Langis::Dsl.langis_plumbing do
intake :inbound_name do
flow_to :sink_name, :when => [:message_type1, :message_type2]
flow_to :catch_all
end
intake :inbound_name do
# NOTE that we have a second intake block with the same
# :inbound_name name. The configuration in this block
# will be merged with the previously declared block.
# NOTE that the above :catch_all flow to sink can be overwritten
# if we declare a `flow_to :catch_all, :when => [...]`. The
# catch all will be restricted to the types declared in this
# second flow_to.
# NOTE that if we add a `flow_to :sink_name, :when => :type_3`,
# it will add :type_3 to the list of message types already
# declared in the prior block.
end
for_sink :sink_name do
use SinkSpecificMiddlewareApp, :argument1, :argument2
run MyRealApp.new(:argument1, :argument2)
end
for_sink :catch_all do
run lambda { |env| puts Rails.logger.info(env.inspect) }
end
check_valve do
use GlobalMiddlewareApp, :argument1, :argument2
end
end
engine = Langis::Engine::EventMachineEngine.new config.build_pipes
engine.pump MyMessage.new(:someinfo), :inbound_name
51 52 53 54 55 |
# File 'lib/langis/dsl.rb', line 51 def langis_plumbing(&block) config = PipesConfig.new Blockenspiel.invoke block, config return config end |