Module: Octave

Defined in:
lib/octave.rb,
lib/octave/agent.rb,
lib/octave/payload.rb,
lib/octave/railtie.rb,
lib/octave/version.rb,
lib/octave/configuration.rb,
lib/octave/dispatcher/base.rb,
lib/octave/dispatcher/logger.rb,
lib/octave/helpers/controller.rb

Overview

:nodoc:

Defined Under Namespace

Modules: Dispatcher, Helpers Classes: Agent, Configuration, Payload, Railtie

Constant Summary collapse

VERSION =
"0.1.1".freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configConfiguration

Returns The current Octave configuration.

Returns:



30
31
32
# File 'lib/octave.rb', line 30

def config
  @config ||= Configuration.new
end

Class Method Details

.configure {|config| ... } ⇒ Object

Configures Octave. See Octave::Configuration for configuration options.

Example

Octave.configure do |config|
  config.logger = Rails.logger
end

Yields:



24
25
26
27
# File 'lib/octave.rb', line 24

def configure
  self.config ||= Configuration.new
  yield(config)
end

.dispatch(payload) ⇒ Object

Dispatches the payload to the current agent



59
60
61
# File 'lib/octave.rb', line 59

def dispatch(payload)
  agent.dispatch(payload) if agent.running?
end

.loggerObject

Shortcut method to access Octave.config.logger.



40
41
42
# File 'lib/octave.rb', line 40

def logger
  Octave.config.logger
end

.measure(name, options = {}) ⇒ Object

Measure the performance of a block.

Example

Octave.measure("process-card") do
  process_credit_card
end


50
51
52
53
54
55
56
# File 'lib/octave.rb', line 50

def measure(name, options = {})
  payload = Payload.new(name, options)
  result  = yield

  dispatch(payload.tap(&:done))
  result
end

.reset_configObject

Resets the configuration to the default



35
36
37
# File 'lib/octave.rb', line 35

def reset_config
  @config = nil
end

.startObject

Starts the agent



64
65
66
# File 'lib/octave.rb', line 64

def start
  agent.start
end

.stopObject

Stops the agent



69
70
71
72
# File 'lib/octave.rb', line 69

def stop
  agent.stop
  @agent = nil
end