No commit activity in last 3 years
No release in over 3 years
Watch multiple URIs for appended content e.g log files
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 0.9.2
~> 2

Runtime

 Project Readme

Net::HTTP::FollowTail

Fulfils the same role as tail -f but for files over HTTP. That is to say if you have log files (e.g IRC logs) available at a URL you could follow them with this module.

Usage

require 'net/http/follow_tail'

Net::HTTP::FollowTail.follow(uri: 'http://example.com/irc.log') do |result, tailer|
  puts "Someone on IRC said: ", result.content
end

Interface

If you're desiring of a URI's tail then the simplest way of using this module is to use the follow class method on Net::HTTP::FollowTail. It's first argument should be a hash, or array of hashes, containing at least uri key with a value that's either a URI::HTTP instance or something that would URI.parse to one. It also expects a block which gets executed whenever new data appears at the tail at any of the URIs. That's demonstrated in the Usage example above.

Other data that can be passed in the hash argument(s) are:

  • wait_in_seconds: How long to wait in seconds between polls.
  • offset: An offset in Fixnum bytes to start at.
  • max_retries: The number of times to retry in the face of failure before giving up.
  • always_callback: A boolean indicating that the callback should be called even the tail request wasn't successful.

The callback is called with two arguments - a Net::HTTP::FollowTail::Result instance and a Net::HTTP::FollowTail::Tailer instance respectively. The former exposing the result of the most recent tail request at the latter the current tailing state. By default it is only called when the tail request was successful.

Example

This module can be seen put to use at:

https://github.com/broquaint/soup-stash/blob/master/script/keeping-up-with-the-logs

Author

Dan Brook <dan@broquaint.com>