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
-
.config ⇒ Configuration
The current Octave configuration.
Class Method Summary collapse
-
.configure {|config| ... } ⇒ Object
Configures Octave.
-
.dispatch(payload) ⇒ Object
Dispatches the payload to the current agent.
-
.logger ⇒ Object
Shortcut method to access
Octave.config.logger
. -
.measure(name, options = {}) ⇒ Object
Measure the performance of a block.
-
.reset_config ⇒ Object
Resets the configuration to the default.
-
.start ⇒ Object
Starts the agent.
-
.stop ⇒ Object
Stops the agent.
Class Attribute Details
.config ⇒ Configuration
Returns The current Octave configuration.
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
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 |
.logger ⇒ Object
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, = {}) payload = Payload.new(name, ) result = yield dispatch(payload.tap(&:done)) result end |
.reset_config ⇒ Object
Resets the configuration to the default
35 36 37 |
# File 'lib/octave.rb', line 35 def reset_config @config = nil end |
.start ⇒ Object
Starts the agent
64 65 66 |
# File 'lib/octave.rb', line 64 def start agent.start end |
.stop ⇒ Object
Stops the agent
69 70 71 72 |
# File 'lib/octave.rb', line 69 def stop agent.stop @agent = nil end |