Class: Karafka::Web::Pro::Ui::Controllers::Topics::ConfigsController
- Inherits:
-
BaseController
- Object
- Ui::Controllers::BaseController
- 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
Constant Summary
Constants inherited from Ui::Controllers::BaseController
Ui::Controllers::BaseController::Models
Instance Attribute Summary
Attributes inherited from Ui::Controllers::BaseController
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.
Methods inherited from Ui::Controllers::BaseController
Methods included from Ui::Controllers::Requests::Hookable
included, #run_after_hooks, #run_before_hooks
Constructor Details
This class inherits a constructor from Karafka::Web::Ui::Controllers::BaseController
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
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/karafka/web/pro/ui/controllers/topics/configs_controller.rb', line 62 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
50 51 52 53 54 55 56 |
# File 'lib/karafka/web/pro/ui/controllers/topics/configs_controller.rb', line 50 def index(topic_name) @topic = Models::Topic.find(topic_name) @configs = refine(@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
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/karafka/web/pro/ui/controllers/topics/configs_controller.rb', line 81 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 |