Class: Async::Runner::Command

Inherits:
Samovar::Command
  • Object
show all
Defined in:
lib/async/runner/command.rb

Constant Summary collapse

MAX_FIBERS =
1000

Instance Method Summary collapse

Instance Method Details

#callObject

Prepare the environment and invoke the sub-command.



66
67
68
69
70
71
72
73
74
# File 'lib/async/runner/command.rb', line 66

def call
  if @options[:version]
    puts "#{self.name} v#{Async::Runner::VERSION}"
  elsif @options[:help]
    self.print_usage
  else
    run
  end
end

#container_classObject

The container class to use.



77
78
79
80
81
82
83
84
85
86
# File 'lib/async/runner/command.rb', line 77

def container_class
  case @options[:container]
  when :threaded
    return Async::Container::Threaded
  when :forked
    return Async::Container::Forked
  when :hybrid
    return Async::Container::Hybrid
  end
end

#container_optionsObject



88
89
90
91
92
93
94
# File 'lib/async/runner/command.rb', line 88

def container_options
  if @options[:container] == :hybrid
    options.slice(:count, :forks, :threads, :name, :restart, :key)
  else
    options.slice(:count, :name, :restart, :key)
  end
end

#job_classObject



96
97
98
# File 'lib/async/runner/command.rb', line 96

def job_class
  Async::Runner::Job
end

#quiet?Boolean

Whether quiet logging was enabled.

Returns:

  • (Boolean)


61
62
63
# File 'lib/async/runner/command.rb', line 61

def quiet?
  @options[:logging] == :quiet
end

#verbose?Boolean

Whether verbose logging is enabled.

Returns:

  • (Boolean)


55
56
57
# File 'lib/async/runner/command.rb', line 55

def verbose?
  @options[:logging] == :verbose
end