Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Open ¶
func Open(url string) (io.ReadCloser, error)
Open will open the URL given by url. A io.ReadCloser is returned, which must be closed.
func WatchUrl ¶
func WatchUrl(url string, checkInterval time.Duration, logger log.Logger) (<-chan io.ReadCloser, error)
WatchUrl watches the URL given by url and yields a new io.ReadCloser periodically. If the URL is a local file, a new io.ReadCloser is yielded when a new inode is found and it is a regular file. If url is a HTTP/HTTPS URL a new io.ReadCloser is yielded every checkInterval. Each yielded io.ReadCloser must be closed after use. Any errors are logged to the logger.
func WatchUrlWithCache ¶
func WatchUrlWithCache(url string, checkInterval time.Duration, cacheFilename string, initialTimeout time.Duration, logger log.Logger) (<-chan *CachedReadCloser, error)
WatchUrlWithCache is similar to WatchUrl, except that data are cached. A cached copy of the data is stored in the file named cacheFilename when the SaveCache method is called. This file is read at startup if the URL is not available before the initialTimeout. Any errors are logged to the logger.
Types ¶
type CachedReadCloser ¶
type CachedReadCloser struct {
// contains filtered or unexported fields
}
func (*CachedReadCloser) Close ¶
func (rc *CachedReadCloser) Close() error
func (*CachedReadCloser) SaveCache ¶
func (rc *CachedReadCloser) SaveCache() error