Class: Ocular::DSL::RunContext

Inherits:
Object
  • Object
show all
Includes:
Cache, Etcd, File, Fog, Graphite, Logging, Mongo, MySQL, Orbit, Psql, RabbitMQ, SSH, Inputs::Cron::DSL
Defined in:
lib/ocular/dsl/runcontext.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Inputs::Cron::DSL

#cron

Methods included from File

#getfullpath

Methods included from Cache

#cache_get, #cache_set

Methods included from Graphite

#graphite, #graphite_get_latests

Methods included from RabbitMQ

#amqp

Methods included from Mongo

#mongo

Methods included from Psql

#psql

Methods included from MySQL

#mysql

Methods included from Orbit

#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

#ssh_to

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_nameObject

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_signatureObject

Returns the value of attribute event_signature.



11
12
13
# File 'lib/ocular/dsl/runcontext.rb', line 11

def event_signature
  @event_signature
end

#loggerObject

Returns the value of attribute logger.



12
13
14
# File 'lib/ocular/dsl/runcontext.rb', line 12

def logger
  @logger
end

#proxyObject

Returns the value of attribute proxy.



9
10
11
# File 'lib/ocular/dsl/runcontext.rb', line 9

def proxy
  @proxy
end

#run_idObject

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_forkObject



53
54
55
# File 'lib/ocular/dsl/runcontext.rb', line 53

def after_fork()
    @logger.reconnect()
end

#cleanupObject



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