sqlitestore

package
v0.3.11 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetFlags

func SetFlags(fs *pflag.FlagSet, cfg *Config)

Types

type Config

type Config struct {
	Enabled               bool
	Directory             string
	URL                   string
	Filename              string
	MaxOpenConnections    int
	MaxIdleConnections    int
	ConnectionMaxLifetime time.Duration
	ConnectionMaxIdle     time.Duration
}

type Store

type Store struct {
	DB   *sqlite.Conn
	Pool *sqlitemigration.Pool
	// contains filtered or unexported fields
}

func New

func New(cfg *Config) (*Store, error)

func (*Store) AddDevice

func (cs *Store) AddDevice(ctx context.Context, newdevice model.Device) error

AddDevice adds a device to the store, will return error if the device already exists

func (*Store) AddNetflows

func (cs *Store) AddNetflows(ctx context.Context, flows []model.IpFlow) (err error)

AddNetflows adds a network to the store, will return error if the network already exists in the store

func (*Store) AddNetwork

func (cs *Store) AddNetwork(ctx context.Context, newnetwork model.Network) error

AddNetwork adds a network to the store, will return error if the network already exists in the store

func (*Store) Close

func (cs *Store) Close() error

func (*Store) CountDevices

func (cs *Store) CountDevices(ctx context.Context) int

CountDevices return the number of devices in the store

func (*Store) CountNetworks

func (cs *Store) CountNetworks(ctx context.Context) int

CountNetworks returns the number of networks in the store

func (*Store) FlowSummaryByCountry

func (cs *Store) FlowSummaryByCountry(
	ctx context.Context,
	addr model.Addr,
) ([]model.FlowSummaryForAddrByCountry, error)

func (*Store) FlowSummaryByIP

func (cs *Store) FlowSummaryByIP(
	ctx context.Context,
	addr model.Addr,
) ([]model.FlowSummaryForAddrByIP, error)

func (*Store) FlowSummaryByName

func (cs *Store) FlowSummaryByName(
	ctx context.Context,
	addr model.Addr,
) ([]model.FlowSummaryForAddrByName, error)

func (*Store) GetAsn

func (cs *Store) GetAsn(ctx context.Context, asn string) (am model.Asn, err error)

func (*Store) GetDeviceByAddr

func (cs *Store) GetDeviceByAddr(
	ctx context.Context,
	addr model.Addr,
) (model.Device, error)

GetDeviceByAddr returns the device with the matching Addr

func (*Store) GetFilteredDevices

func (cs *Store) GetFilteredDevices(
	ctx context.Context,
	filter model.DeviceFilter,
) []model.Device

GetFilteredDevices returns the devices which match the given GetFilteredDevices

func (*Store) GetFilteredNetworks

func (cs *Store) GetFilteredNetworks(
	ctx context.Context,
	filter model.NetworkFilter,
) []model.Network

GetFilteredNetworks returns the networks which match the given GetFilteredNetworks

func (*Store) GetNetflows

func (cs *Store) GetNetflows(
	ctx context.Context,
	addr model.Addr,
) (flows []model.IpFlow, err error)

func (*Store) GetNetworkByName

func (cs *Store) GetNetworkByName(ctx context.Context, name string) (model.Network, error)

GetNetworkByName returns a network with the given name

func (*Store) ListDevices

func (cs *Store) ListDevices(ctx context.Context) []model.Device

ListDevices returns all the stored devices

func (*Store) ListNetworks

func (cs *Store) ListNetworks(ctx context.Context) []model.Network

ListNetworks returns all stored networks

func (*Store) ReadPerformancePings

func (cs *Store) ReadPerformancePings(
	ctx context.Context,
	device model.Device,
	duration time.Duration,
) (points []pinger.Point, err error)

ReadPoints returns the points from Now() minus the duration for the given type

func (*Store) RemoveDeviceByAddr

func (cs *Store) RemoveDeviceByAddr(ctx context.Context, addr model.Addr) error

RemoveDeviceByAddr will remove the device with the given Addr from the store

func (*Store) RemoveNetworkByName

func (cs *Store) RemoveNetworkByName(ctx context.Context, name string) error

RemoveNetworkByName remove the named network from the store

func (*Store) StartAsnLoad added in v0.3.11

func (cs *Store) StartAsnLoad() func(*error)

func (*Store) UpdateDevice

func (cs *Store) UpdateDevice(
	ctx context.Context,
	newdevice model.Device,
) (enrich bool, err error)

UpdateDevice will fresnen up the device using the given device

func (*Store) UpdateNetwork

func (cs *Store) UpdateNetwork(ctx context.Context, newnetwork model.Network) error

UpdateNetwork will freshen up the network using the given network

func (*Store) UpsertAsn

func (cs *Store) UpsertAsn(ctx context.Context, asn model.Asn) error

func (*Store) UpsertNetwork

func (cs *Store) UpsertNetwork(ctx context.Context, newnetwork model.Network) (err error)

func (*Store) WritePerformancePing

func (cs *Store) WritePerformancePing(
	ctx context.Context,
	timestamp time.Time,
	device model.Device,
	point nettools.Icmp4EchoResponseStatistics,
) (err error)

WritePoint stores a given point for a device

Jump to

Keyboard shortcuts

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