Class: Loadrunner::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/loadrunner/runner.rb

Overview

Executes event hooks

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Runner

Returns a new instance of Runner.



8
9
10
11
# File 'lib/loadrunner/runner.rb', line 8

def initialize(opts)
  @hooks_dir = 'hooks'
  @opts = opts
end

Instance Attribute Details

#hooks_dirObject

Returns the value of attribute hooks_dir.



6
7
8
# File 'lib/loadrunner/runner.rb', line 6

def hooks_dir
  @hooks_dir
end

#optsObject (readonly)

Returns the value of attribute opts.



5
6
7
# File 'lib/loadrunner/runner.rb', line 5

def opts
  @opts
end

#responseObject

Returns the value of attribute response.



6
7
8
# File 'lib/loadrunner/runner.rb', line 6

def response
  @response
end

Instance Method Details

#executeObject

Execute all matching hooks based on the input payload. This method populates the ‘#response` object, and returns true on success.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/loadrunner/runner.rb', line 15

def execute
  set_environment_vars

  @response = opts.dup
  hooks = locate_hooks
  @response[:matching_hooks] = matching_hooks

  if hooks.empty?
    @response[:error] = "Could not find any hook to process this request. Please implement one of the 'matching_hooks'."
    return false
  else
    execute_all hooks
    @response[:executed_hooks] = hooks
    return true
  end
end