Class: Karafka::Web::Pro::Ui::Controllers::Topics::ConfigsController
- Inherits:
-
BaseController
- Object
- Controllers::BaseController
- BaseController
- Karafka::Web::Pro::Ui::Controllers::Topics::ConfigsController
- Defined in:
- lib/karafka/web/pro/ui/controllers/topics/configs_controller.rb
Overview
Controller responsible for management of topics configs
Instance Method Summary collapse
-
#edit(topic_name, property_name) ⇒ Object
Allows for editing of a particular configuration setting To simplify things we do not allow for batch editing of multiple parameters.
-
#index(topic_name) ⇒ Object
Displays requested topic config details.
-
#update(topic_name, property_name) ⇒ Object
Tries to apply config change on a topic and either returns the error info or redirects if changed.
Instance Method Details
#edit(topic_name, property_name) ⇒ Object
Allows for editing of a particular configuration setting To simplify things we do not allow for batch editing of multiple parameters
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/karafka/web/pro/ui/controllers/topics/configs_controller.rb', line 67 def edit(topic_name, property_name) features.topics_management! # This will load all the configs so we can validate that a requested config exists # and we can get its current value for the form index(topic_name) @property = @configs.find { |config| config.name == property_name } raise(Errors::Ui::NotFoundError) unless @property raise(Errors::Ui::ForbiddenError) if @property.read_only? render end |
#index(topic_name) ⇒ Object
Displays requested topic config details
55 56 57 58 59 60 61 |
# File 'lib/karafka/web/pro/ui/controllers/topics/configs_controller.rb', line 55 def index(topic_name) @topic = Models::Topic.find(topic_name) @configs = filter(sort(@topic.configs)) render end |
#update(topic_name, property_name) ⇒ Object
Tries to apply config change on a topic and either returns the error info or redirects if changed
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/karafka/web/pro/ui/controllers/topics/configs_controller.rb', line 86 def update(topic_name, property_name) edit(topic_name, property_name) property_value = params[:property_value] begin resource = Karafka::Admin::Configs::Resource.new(type: :topic, name: topic_name) resource.set(property_name, property_value) Karafka::Admin::Configs.alter(resource) rescue Rdkafka::RdkafkaError => e @form_error = e end return edit(topic_name, property_name) if @form_error redirect( "topics/#{topic_name}/config", success: format_flash( "Topic ? property ? successfully altered", topic_name, property_name ) ) end |