Class: CC::Analyzer::Engine
- Inherits:
-
Object
- Object
- CC::Analyzer::Engine
- Defined in:
- lib/cc/analyzer/engine.rb
Constant Summary collapse
- EngineFailure =
Class.new(StandardError)
- EngineTimeout =
Class.new(StandardError)
- DEFAULT_MEMORY_LIMIT =
512_000_000.freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, metadata, code_path, config, label) ⇒ Engine
constructor
A new instance of Engine.
- #run(stdout_io, container_listener) ⇒ Object
Constructor Details
#initialize(name, metadata, code_path, config, label) ⇒ Engine
Returns a new instance of Engine.
13 14 15 16 17 18 19 |
# File 'lib/cc/analyzer/engine.rb', line 13 def initialize(name, , code_path, config, label) @name = name = @code_path = code_path @config = config @label = label.to_s end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/cc/analyzer/engine.rb', line 9 def name @name end |
Instance Method Details
#run(stdout_io, container_listener) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/cc/analyzer/engine.rb', line 21 def run(stdout_io, container_listener) composite_listener = CompositeContainerListener.new( container_listener, LoggingContainerListener.new(name, Analyzer.logger), StatsdContainerListener.new(name, Analyzer.statsd), RaisingContainerListener.new(name, EngineFailure, EngineTimeout), ) container = Container.new( image: ["image"], command: ["command"], name: container_name, listener: composite_listener, ) container.on_output("\0") do |raw_output| CLI.debug "engine output: #{raw_output.inspect}" output = EngineOutput.new(raw_output) unless output_filter.filter?(output) stdout_io.write(output.to_json) || container.stop end end write_config_file CLI.debug "engine config: #{File.read(config_file).inspect}" container.run() ensure delete_config_file end |