Class: Karafka::Web::Installer

Inherits:
Object
  • Object
show all
Includes:
Helpers::Colorize
Defined in:
lib/karafka/web/installer.rb

Overview

Responsible for setup of the Web UI and Karafka Web-UI related components initialization.

Instance Method Summary collapse

Instance Method Details

#enable!Object

Enables the Web-UI in the karafka app. Sets up needed routes and listeners.



88
89
90
# File 'lib/karafka/web/installer.rb', line 88

def enable!
  Management::Actions::Enable.new.call
end

#install(replication_factor: 1) ⇒ Object

Creates needed topics and the initial zero state, so even if no ‘karafka server` processes are running, we can still display the empty UI. Also adds needed code to the `karafka.rb` file.

Parameters:

  • replication_factor (Integer) (defaults to: 1)

    replication factor we want to use (1 by default)



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/karafka/web/installer.rb', line 14

def install(replication_factor: 1)
  enable!
  puts
  puts "Installing Karafka Web UI..."
  puts
  Management::Actions::ExtendBootFile.new.call
  puts
  puts "Creating necessary topics and populating state data..."
  puts
  Management::Actions::CreateTopics.new.call(replication_factor)
  wait_for_topics
  Management::Actions::CreateInitialStates.new.call
  puts
  puts "Running data migrations..."
  Management::Actions::MigrateStatesData.new.call
  puts
  puts("Installation #{green("completed")}. Have fun!")
  puts
end

#migrate(replication_factor: 1) ⇒ Object

Creates missing topics and missing zero states. Needs to run for each environment where we want to use Web-UI

Parameters:

  • replication_factor (Integer) (defaults to: 1)

    replication factor we want to use (1 by default)



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/karafka/web/installer.rb', line 38

def migrate(replication_factor: 1)
  enable!
  puts
  puts "Creating necessary topics and populating state data..."
  puts
  Management::Actions::CreateTopics.new.call(replication_factor)
  wait_for_topics
  Management::Actions::CreateInitialStates.new.call
  puts
  puts "Running data migrations..."
  Management::Actions::MigrateStatesData.new.call
  puts
  puts("Migration #{green("completed")}. Have fun!")
  puts
end

#reset(replication_factor: 1) ⇒ Object

Removes all the Karafka topics and creates them again with the same replication factor

Parameters:

  • replication_factor (Integer) (defaults to: 1)

    replication factor we want to use (1 by default)



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/karafka/web/installer.rb', line 56

def reset(replication_factor: 1)
  enable!
  puts
  puts "Resetting Karafka Web UI..."
  puts
  Management::Actions::DeleteTopics.new.call
  puts
  Management::Actions::CreateTopics.new.call(replication_factor)
  wait_for_topics
  Management::Actions::CreateInitialStates.new.call
  puts
  puts "Running data migrations..."
  Management::Actions::MigrateStatesData.new.call
  puts
  puts("Resetting #{green("completed")}. Have fun!")
  puts
end

#uninstallObject

Removes all the Karafka Web topics and cleans after itself.



75
76
77
78
79
80
81
82
83
84
85
# File 'lib/karafka/web/installer.rb', line 75

def uninstall
  enable!
  puts
  puts "Uninstalling Karafka Web UI..."
  puts
  Management::Actions::DeleteTopics.new.call
  Management::Actions::CleanBootFile.new.call
  puts
  puts("Uninstalling #{green("completed")}. Goodbye!")
  puts
end