file

package
v0.0.0-...-2cc43cd Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package file watches a file for changes and updates the in memory DHCP data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Watcher

type Watcher struct {

	// FilePath is the path to the file to watch.
	FilePath string

	// Log is the logger to be used in the File backend.
	Log logr.Logger
	// contains filtered or unexported fields
}

Watcher represents the backend for watching a file for changes and updating the in memory DHCP data.

func NewWatcher

func NewWatcher(l logr.Logger, f string) (*Watcher, error)

NewWatcher creates a new file watcher.

func (*Watcher) GetByIP

func (w *Watcher) GetByIP(ctx context.Context, ip net.IP) (*data.DHCP, *data.Netboot, error)

GetByIP is the implementation of the Backend interface. It reads a given file from the in memory data (w.data).

func (*Watcher) GetByMac

func (w *Watcher) GetByMac(ctx context.Context, mac net.HardwareAddr) (*data.DHCP, *data.Netboot, error)

GetByMac is the implementation of the Backend interface. It reads a given file from the in memory data (w.data).

func (*Watcher) Start

func (w *Watcher) Start(ctx context.Context)

Start starts watching a file for changes and updates the in memory data (w.data) on changes. Start is a blocking method. Use a context cancellation to exit.

Jump to

Keyboard shortcuts

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