Class: Mode::Commands::Connect

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/mode/commands/connect.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#config_dir, #config_exists?, #config_path, #configure_api_requests!, #connect_config_exists?, #require_config!, #require_connect_config!, #require_credentials!, #timer_block

Constructor Details

#initialize(command, options = {}) ⇒ Connect

Returns a new instance of Connect.



10
11
12
13
# File 'lib/mode/commands/connect.rb', line 10

def initialize(command, options = {})
  @command = command
  @concurrency = options[:concurrency] || 4
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



7
8
9
# File 'lib/mode/commands/connect.rb', line 7

def command
  @command
end

#concurrencyObject (readonly)

Returns the value of attribute concurrency.



8
9
10
# File 'lib/mode/commands/connect.rb', line 8

def concurrency
  @concurrency
end

Instance Method Details

#executeObject



15
16
17
18
19
# File 'lib/mode/commands/connect.rb', line 15

def execute
  validate_config!
  register! if ['start', 'restart'].include?(command)
  spawn!
end

#verify!Object



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mode/commands/connect.rb', line 21

def verify!
  validate_config!
  configuration.data_sources.each do |data_source|
    begin
      unless data_source.connection.test_connection
        raise StandardError.new("Unknown connection error")
      end
    rescue => err
      raise "Error: Cannot connect to #{data_source.name}. #{err.message}"
    end
  end
end