Class: Ocular::Inputs::Cron::Input

Inherits:
Base
  • Object
show all
Defined in:
lib/ocular/inputs/cron_input.rb

Defined Under Namespace

Classes: DSLProxy

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(settings_factory) ⇒ Input

Returns a new instance of Input.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/ocular/inputs/cron_input.rb', line 31

def initialize(settings_factory)
    settings = settings_factory[:cron]
    @cron_enabled = true

    if settings[:lock]
        @cron_enabled = false
    end

    @scheduler = ::Rufus::Scheduler.new
    ::Ocular.logger.debug "Starting Rufus cron scheduler"

    if settings[:lock]
        @scheduler.every(settings[:lock_delay] || "10s", :overlap => false) do
            etcd = ::Ocular::DSL::Etcd.etcd()

            ret = etcd.get(settings[:lock])
            pp ret
        end
    end
end

Instance Attribute Details

#cron_enabledObject (readonly)

Returns the value of attribute cron_enabled.



29
30
31
# File 'lib/ocular/inputs/cron_input.rb', line 29

def cron_enabled
  @cron_enabled
end

#routesObject (readonly)

Returns the value of attribute routes.



27
28
29
# File 'lib/ocular/inputs/cron_input.rb', line 27

def routes
  @routes
end

#schedulerObject (readonly)

Returns the value of attribute scheduler.



28
29
30
# File 'lib/ocular/inputs/cron_input.rb', line 28

def scheduler
  @scheduler
end

Instance Method Details

#disableObject



60
61
62
# File 'lib/ocular/inputs/cron_input.rb', line 60

def disable()
    @cron_enabled = false
end

#enableObject



64
65
66
# File 'lib/ocular/inputs/cron_input.rb', line 64

def enable()
    @cron_enabled = true
end

#startObject



52
53
54
# File 'lib/ocular/inputs/cron_input.rb', line 52

def start()

end

#stopObject



56
57
58
# File 'lib/ocular/inputs/cron_input.rb', line 56

def stop()
    @scheduler.shutdown
end