filevar

package
v0.0.0-...-915478c Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package filevar provides a runtimevar driver implementation to read configurations and ability to detect changes and get updates on local configuration files.

User constructs a runtimevar.Variable object using NewConfig given a locally-accessible file.

User can update a configuration file using any commands (cp, mv) or tools/editors. This package does not guarantee read consistency since it does not have control over the writes. It is highly advisable to use this package only for local development or testing purposes and not in production applications/services.

Known Issues:

* On Mac OSX, if user copies an empty file into a configuration file, Watch will not be able to detect the change since event.Op is Chmod only.

* Saving a configuration file in vim using :w will incur events Rename and Create. When the Rename event occurs, the file is temporarily removed and hence Watch will return error. A follow-up Watch call will then detect the Create event.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewVariable

func NewVariable(file string, decoder *runtimevar.Decoder, opts *WatchOptions) (*runtimevar.Variable, error)

NewVariable constructs a runtimevar.Variable object with this package as the driver implementation. The decoder argument allows users to dictate the decoding function to parse the file as well as the type to unmarshal into. If WaitTime is not set the wait is set to 10 seconds.

Types

type WatchOptions

type WatchOptions struct {
	// WaitTime controls the frequency of making an HTTP call and checking for
	// updates by the Watch method. The smaller the value, the higher the frequency
	// of making calls, which also means a faster rate of hitting the API quota.
	// If this option is not set or set to 0, it uses a default value of 10 seconds.
	WaitTime time.Duration
}

WatchOptions allows the specification of various options to a watcher.

Directories

Path Synopsis
This binary demonstrates watching over a configuration file using the runtimevar package with the filevar package as the driver implementation.
This binary demonstrates watching over a configuration file using the runtimevar package with the filevar package as the driver implementation.

Jump to

Keyboard shortcuts

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