Class: Karafka::Workers::Builder
- Inherits:
-
Object
- Object
- Karafka::Workers::Builder
- Defined in:
- lib/karafka/workers/builder.rb
Overview
Builder is used to check if there is a proper consumer with the same name as a consumer and if not, it will create a default one using Karafka::BaseWorker This is used as a building layer between consumers and workers. it will be only used when user does not provide his own worker that should perform consumer stuff
Instance Method Summary collapse
-
#build ⇒ Class
Sidekiq worker class that already exists or new build based on the provided consumer_class name.
-
#initialize(consumer_class) ⇒ Builder
constructor
A new instance of Builder.
Constructor Details
#initialize(consumer_class) ⇒ Builder
Returns a new instance of Builder.
14 15 16 |
# File 'lib/karafka/workers/builder.rb', line 14 def initialize(consumer_class) @consumer_class = consumer_class end |
Instance Method Details
#build ⇒ Class
Returns Sidekiq worker class that already exists or new build based on the provided consumer_class name.
24 25 26 27 28 29 |
# File 'lib/karafka/workers/builder.rb', line 24 def build return matcher.match if matcher.match klass = Class.new(Karafka::BaseWorker.base_worker) matcher.scope.const_set(matcher.name, klass) end |