configwatch

package
v0.0.0-...-d8f7d12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package configwatch watches local or remote config files for changes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Watch

func Watch(url string, checkInterval time.Duration,
	decoder Decoder, logger log.DebugLogger) (<-chan interface{}, error)

Watch is designed to monitor configuration changes. Watch will monitor the provided URL for new data, calling the decoder and will send the decoded data to the channel that is returned. Decoded data are not sent if the checksum of the raw data has not changed since the last decoded data were sent to the channel. The URL is checked for changed data at least every checkInterval (for HTTP/HTTPS URLs) but may be checked more frequently (for local files).

func WatchWithCache

func WatchWithCache(url string, checkInterval time.Duration,
	decoder Decoder, cacheFilename string, initialTimeout time.Duration,
	logger log.DebugLogger) (<-chan interface{}, error)

WatchWithCache is similar to Watch, except that successfully decoded data are cached. A cached copy of the data is stored in the file named cacheFilename. This file is read at startup if the URL is not available before the initialTimeout.

Types

type Decoder

type Decoder func(reader io.Reader) (interface{}, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL