I am working on an App that will read a list of rss feeds (stored in yaml file) and sends a message to Hipchat when there is a new item in that feed.
Here is the structure of my feeds.yml file.
feeds:
feed_name:
url:
poll_interval: 30 #in seconds
hipchat_room:
hipchat_color:
hipchat_from:
hipchat_nofiy:
I want each feed to have a different poll interval (the time that the system will check for new items.)
My question is: How do I handle the poll interval in the code. Each time that interval is reached I need to call the method to process the feed and that time can be different from feed to feed. Should I use something like rufus-scheduler gem?
I want my app to be simple and be able to run in the Heroku Free tier without problems.
Thank you.
Edit: I dont have much code yet. I am just planning the application. I am thinking like this:
app.rb
# reads the feeds
feeds_list = YAML.load(File.read("feeds.yml"))
# iterates each feed and creates a feed object.
feeds_list['feeds'].each do |f|
feed = HipchatRssNotify::Feed.new f
# calls some method to process that particular feed.
# The call should be called periodically based on the feed poll_interval.
feed_processor.process(feed)
end
I think I could rufus-scheduler gem but I am not sure how heroku will handle it if I have many feeds. The gem would create one thread for each feed if I understood correctly.