hardware

package
v0.0.0-...-0346462 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

The hardware package provides an in memory database that contains all of the hardware info.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Hardware

type Hardware struct {
	// contains filtered or unexported fields
}

Hardware is the interface to the in memory DB of hardware objects.

func New

func New(options ...Option) *Hardware

New will return an initialized Hardware struct.

func (*Hardware) Add

func (h *Hardware) Add(j string) (string, error)

Add inserts a new hardware object into the database, overriding any pre-existing values. If state == deleted Add will delete the the object from the db. API currently has a bug where it sends invalid ip_address objects where the address (and others) is missing, we log this case (if logger is configured) and continue processing.

func (*Hardware) All

func (h *Hardware) All(fn func(string) error) error

All returns each entry stored in memory.

func (*Hardware) ByID

func (h *Hardware) ByID(v string) (string, error)

ByID returns the hardware with the given id.

func (*Hardware) ByIP

func (h *Hardware) ByIP(v string) (string, error)

ByID returns the hardware with the given ip address.

func (*Hardware) ByMAC

func (h *Hardware) ByMAC(v string) (string, error)

ByID returns the hardware with the given mac address.

type Option

type Option func(*Hardware)

The Option type describes functions that operate on Hardeare during New. It is a convenience type to make it easier for callers to configure options for Hardware.

func Gauge

func Gauge(g prometheus.Gauge) Option

Gauge will set the gauge used to track db size metric.

func Logger

func Logger(l log.Logger) Option

Logger will set the logger used to log non-error but exceptional things.

Jump to

Keyboard shortcuts

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