Class: Ocular::DSL::RunContext
- Inherits:
-
Object
- Object
- Ocular::DSL::RunContext
- Includes:
- Cache, Etcd, File, Fog, Graphite, Logging, Mongo, MySQL, Orbit, Psql, RabbitMQ, SSH, Inputs::Cron::DSL
- Defined in:
- lib/ocular/dsl/runcontext.rb
Direct Known Subclasses
REPLRunContext, Inputs::HTTP::Input::WebRunContext, Inputs::RabbitMQ::Input::RabbitMQRunContext
Instance Attribute Summary collapse
-
#class_name ⇒ Object
Returns the value of attribute class_name.
-
#event_signature ⇒ Object
Returns the value of attribute event_signature.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#proxy ⇒ Object
Returns the value of attribute proxy.
-
#run_id ⇒ Object
Returns the value of attribute run_id.
Instance Method Summary collapse
- #after_fork ⇒ Object
- #cleanup ⇒ Object
-
#initialize(logger) ⇒ RunContext
constructor
A new instance of RunContext.
- #method_missing(method_sym, *arguments, &block) ⇒ Object
- #register_cleanup(&block) ⇒ Object
Methods included from Inputs::Cron::DSL
Methods included from File
Methods included from Cache
Methods included from Graphite
#graphite, #graphite_get_latests
Methods included from RabbitMQ
Methods included from Mongo
Methods included from Psql
Methods included from MySQL
Methods included from Orbit
Methods included from Etcd
#etcd, #locked?, #ttl_lock, #unlock
Methods included from Fog
#autoscaling, #aws, #find_server_by_id, #find_server_by_ip, #find_servers_in_autoscaling_groups, #get_servers_in_autoscaling_group
Methods included from SSH
Methods included from Logging
#debug, #error, #fatal, #info, #log_cause, #log_event, #log_timing, #warn
Constructor Details
#initialize(logger) ⇒ RunContext
Returns a new instance of RunContext.
29 30 31 32 33 |
# File 'lib/ocular/dsl/runcontext.rb', line 29 def initialize(logger) @run_id = SecureRandom.uuid() @logger = logger @cleanups = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *arguments, &block) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/ocular/dsl/runcontext.rb', line 35 def method_missing(method_sym, *arguments, &block) if self.proxy self.proxy.send(method_sym, *arguments, &block) else raise NoMethodError, "undefined method `#{method_sym}` in event #{self.class_name}" end end |
Instance Attribute Details
#class_name ⇒ Object
Returns the value of attribute class_name.
10 11 12 |
# File 'lib/ocular/dsl/runcontext.rb', line 10 def class_name @class_name end |
#event_signature ⇒ Object
Returns the value of attribute event_signature.
11 12 13 |
# File 'lib/ocular/dsl/runcontext.rb', line 11 def event_signature @event_signature end |
#logger ⇒ Object
Returns the value of attribute logger.
12 13 14 |
# File 'lib/ocular/dsl/runcontext.rb', line 12 def logger @logger end |
#proxy ⇒ Object
Returns the value of attribute proxy.
9 10 11 |
# File 'lib/ocular/dsl/runcontext.rb', line 9 def proxy @proxy end |
#run_id ⇒ Object
Returns the value of attribute run_id.
8 9 10 |
# File 'lib/ocular/dsl/runcontext.rb', line 8 def run_id @run_id end |
Instance Method Details
#after_fork ⇒ Object
53 54 55 |
# File 'lib/ocular/dsl/runcontext.rb', line 53 def after_fork() @logger.reconnect() end |
#cleanup ⇒ Object
47 48 49 50 51 |
# File 'lib/ocular/dsl/runcontext.rb', line 47 def cleanup() for i in @cleanups i.call() end end |
#register_cleanup(&block) ⇒ Object
43 44 45 |
# File 'lib/ocular/dsl/runcontext.rb', line 43 def register_cleanup(&block) @cleanups << block end |