Class: KafkaConsumer::Generators::ConsumerGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Includes:
KafkaConsumer::Generators::Concerns::Configuration
Defined in:
lib/generators/kafka_consumer/consumer/consumer_generator.rb

Constant Summary

Constants included from KafkaConsumer::Generators::Concerns::Configuration

KafkaConsumer::Generators::Concerns::Configuration::CONFIG_PATH

Instance Method Summary collapse

Methods included from KafkaConsumer::Generators::Concerns::Configuration

#check_config_file!

Instance Method Details

#configure_consumer_groupObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/generators/kafka_consumer/consumer/consumer_generator.rb', line 18

def configure_consumer_group
  @group_key = ask "Would you also configure a consumer group?" \
              " Type the group's key (e.g. my_consumer_group) or press Enter to skip this action"
  return if @group_key.blank?

  check_config_file!

  @group_name = ask "Type the group's name (e.g. my.consumer.group)"
  @topic = ask "Type the group topic's name"
  insert_into_file CONFIG_PATH, group_template.result(binding), after: "consumer_groups:\n"
end

#insert_consumer_classObject



13
14
15
16
# File 'lib/generators/kafka_consumer/consumer/consumer_generator.rb', line 13

def insert_consumer_class
  @consumer_name = "#{name.classify}Consumer"
  template "consumer.rb.erb", "app/consumers/#{file_path}_consumer.rb"
end