samedi 30 décembre 2017

access all events from clockwork manager to controller

Am using gem clockwork for running scheduled jobs. I need to access all events defined in clock.rb for manually trigger the clockwork events when it fails.

For that I forked the clockwork gem by adding attr_reader: events in clockwork/manager.rb file.

clock.rb

module Clockwork
  every(10.seconds, 'job1') do
    p Clockwork.manager.events
  end
end

By using Clockwork.manager.events in clock.rb it returns all events that defined in clock.rb.

mycontroller.rb

module Admin
  class MyController < AdminController

    require 'clockwork'

    def index
      @events = Clockwork.manager.events
    end
  end
end

But while using it in controller it returns empty value.

How to get all clockwork events in controller?

Aucun commentaire:

Enregistrer un commentaire