lib/evrone/ci/router/initializers/amqp.rb in evrone-ci-router-0.2.0.pre6 vs lib/evrone/ci/router/initializers/amqp.rb in evrone-ci-router-0.2.0.pre7
- old
+ new
@@ -1,64 +1,3 @@
-require 'evrone/common/amqp'
+require 'evrone/ci/common/amqp'
-module Evrone::CI::Router::AMQP
-
- Base = Struct.new("Subscribing", :app) do
- include Evrone::CI::Router::Helper::Logger
-
- def consumer_name
- Thread.current[:consumer_name]
- end
-
- def consumer_id
- Thread.current[:consumer_id]
- end
-
- def consumer_tag
- consumer_id ? "#{consumer_name.split('::').last} #{consumer_id}" : consumer_name
- end
- end
-
- class Subscribing < Base
- def call(env)
- logger.tagged(consumer_tag) do
- logger.warn "subsribing #{env[:exchange].name}"
- rs = app.call env
- logger.warn "shutdown"
- rs
- end
- end
- end
-
- class Recieving < Base
- def call(env)
- logger.warn "payload recieved #{env[:payload].inspect[0...60]}..."
- rs = app.call env
- logger.warn "commit message"
- rs
- end
- end
-
- class Publishing < Base
- def call(env)
- app.call env
- end
- end
-end
-
-Evrone::Common::AMQP.configure do |c|
- c.subscribing do
- use Evrone::CI::Router::AMQP::Subscribing
- end
-
- c.recieving do
- use Evrone::CI::Router::AMQP::Recieving
- end
-
- c.publishing do
- use Evrone::CI::Router::AMQP::Publishing
- end
-
- c.content_type = 'application/x-protobuf'
- c.logger = nil
- c.url = Evrone::CI::Router.config.amqp_url
-end
+Evrone::CI::Common::AMQP.setup(Evrone::CI::Router.logger, url: Evrone::CI::Router.config.amqp_url)