manager

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package manager provides the business logic layer for inventory management. It wraps the InventoryStore and provides a place for validation, caching, audit logging, and other business rules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ComponentDrift

type ComponentDrift = inventorystore.ComponentDrift

Re-export for convenience

type FieldDiff

type FieldDiff = inventorystore.FieldDiff

type Manager

type Manager interface {
	// Lifecycle
	Start(ctx context.Context) error
	Stop(ctx context.Context) error

	// Rack operations
	CreateExpectedRack(ctx context.Context, rack *rack.Rack) (uuid.UUID, error)
	GetRackByID(ctx context.Context, id uuid.UUID, withComponents bool) (*rack.Rack, error)
	GetRacksByIDs(ctx context.Context, ids []uuid.UUID, withComponents bool) ([]*rack.Rack, error)
	GetRackBySerial(ctx context.Context, manufacturer string, serial string, withComponents bool) (*rack.Rack, error)
	GetRackByIdentifier(ctx context.Context, identifier identifier.Identifier, withComponents bool) (*rack.Rack, error)
	PatchRack(ctx context.Context, rack *rack.Rack) (string, error)
	DeleteRack(ctx context.Context, id uuid.UUID) error
	PurgeRack(ctx context.Context, id uuid.UUID) error
	GetListOfRacks(ctx context.Context, info dbquery.StringQueryInfo, manufacturerFilter *dbquery.StringQueryInfo, modelFilter *dbquery.StringQueryInfo, pagination *dbquery.Pagination, orderBy *dbquery.OrderBy, withComponents bool) ([]*rack.Rack, int32, error)

	// Component operations
	GetComponentByID(ctx context.Context, id uuid.UUID) (*component.Component, error)
	GetComponentBySerial(ctx context.Context, manufacturer string, serial string, withRack bool) (*component.Component, error)
	GetComponentByBMCMAC(ctx context.Context, macAddress string) (*component.Component, error)
	GetComponentsByExternalIDs(ctx context.Context, externalIDs []string) ([]*component.Component, error)
	GetListOfComponents(ctx context.Context, info dbquery.StringQueryInfo, manufacturerFilter *dbquery.StringQueryInfo, modelFilter *dbquery.StringQueryInfo, componentTypes []devicetypes.ComponentType, pagination *dbquery.Pagination, orderBy *dbquery.OrderBy) ([]*component.Component, int32, error)
	AddComponent(ctx context.Context, comp *component.Component) (uuid.UUID, error)
	PatchComponent(ctx context.Context, comp *component.Component) error
	DeleteComponent(ctx context.Context, id uuid.UUID) error
	PurgeComponent(ctx context.Context, id uuid.UUID) error

	// Component drift operations
	GetDriftsByComponentIDs(ctx context.Context, componentIDs []uuid.UUID) ([]inventorystore.ComponentDrift, error)
	GetAllDrifts(ctx context.Context) ([]inventorystore.ComponentDrift, error)

	// NVL Domain operations
	CreateNVLDomain(ctx context.Context, nvlDomain *nvldomain.NVLDomain) (uuid.UUID, error)
	AttachRacksToNVLDomain(ctx context.Context, nvlDomainID identifier.Identifier, rackIDs []identifier.Identifier) error
	DetachRacksFromNVLDomain(ctx context.Context, rackIDs []identifier.Identifier) error
	GetListOfNVLDomains(ctx context.Context, info dbquery.StringQueryInfo, pagination *dbquery.Pagination) ([]*nvldomain.NVLDomain, int32, error)
	GetRacksForNVLDomain(ctx context.Context, nvlDomainID identifier.Identifier) ([]*rack.Rack, error)
}

Manager defines the interface for inventory management business logic. It wraps InventoryStore and provides a consistent API for the service layer.

type ManagerImpl

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

ManagerImpl implements the Manager interface. It currently delegates all operations to the underlying store, but provides a place to add business logic in the future.

func New

func New(store inventorystore.Store) *ManagerImpl

New creates a new inventory manager with the given store.

func (*ManagerImpl) AddComponent

func (m *ManagerImpl) AddComponent(ctx context.Context, comp *component.Component) (uuid.UUID, error)

AddComponent creates a single component in the database and returns its UUID.

func (*ManagerImpl) AttachRacksToNVLDomain

func (m *ManagerImpl) AttachRacksToNVLDomain(ctx context.Context, nvlDomainID identifier.Identifier, rackIDs []identifier.Identifier) error

AttachRacksToNVLDomain attaches racks to an NVL domain.

func (*ManagerImpl) CreateExpectedRack

func (m *ManagerImpl) CreateExpectedRack(ctx context.Context, rack *rack.Rack) (uuid.UUID, error)

CreateExpectedRack creates an expected rack configuration. Future: Add validation, audit logging, etc.

func (*ManagerImpl) CreateNVLDomain

func (m *ManagerImpl) CreateNVLDomain(ctx context.Context, nvlDomain *nvldomain.NVLDomain) (uuid.UUID, error)

CreateNVLDomain creates a new NVL domain.

func (*ManagerImpl) DeleteComponent

func (m *ManagerImpl) DeleteComponent(ctx context.Context, id uuid.UUID) error

DeleteComponent soft-deletes a component by UUID.

func (*ManagerImpl) DeleteRack

func (m *ManagerImpl) DeleteRack(ctx context.Context, id uuid.UUID) error

DeleteRack soft-deletes a rack and all its components.

func (*ManagerImpl) DetachRacksFromNVLDomain

func (m *ManagerImpl) DetachRacksFromNVLDomain(ctx context.Context, rackIDs []identifier.Identifier) error

DetachRacksFromNVLDomain detaches racks from their NVL domain.

func (*ManagerImpl) GetAllDrifts

func (m *ManagerImpl) GetAllDrifts(ctx context.Context) ([]inventorystore.ComponentDrift, error)

GetAllDrifts retrieves all drift records.

func (*ManagerImpl) GetComponentByBMCMAC

func (m *ManagerImpl) GetComponentByBMCMAC(ctx context.Context, macAddress string) (*component.Component, error)

GetComponentByBMCMAC retrieves a component by its BMC MAC address.

func (*ManagerImpl) GetComponentByID

func (m *ManagerImpl) GetComponentByID(ctx context.Context, id uuid.UUID) (*component.Component, error)

GetComponentByID retrieves a component by its UUID.

func (*ManagerImpl) GetComponentBySerial

func (m *ManagerImpl) GetComponentBySerial(ctx context.Context, manufacturer string, serial string, withRack bool) (*component.Component, error)

GetComponentBySerial retrieves a component by its serial number and manufacturer.

func (*ManagerImpl) GetComponentsByExternalIDs

func (m *ManagerImpl) GetComponentsByExternalIDs(ctx context.Context, externalIDs []string) ([]*component.Component, error)

GetComponentsByExternalIDs retrieves components by their external IDs.

func (*ManagerImpl) GetDriftsByComponentIDs

func (m *ManagerImpl) GetDriftsByComponentIDs(ctx context.Context, componentIDs []uuid.UUID) ([]inventorystore.ComponentDrift, error)

GetDriftsByComponentIDs retrieves drift records for the given component UUIDs.

func (*ManagerImpl) GetListOfComponents

func (m *ManagerImpl) GetListOfComponents(ctx context.Context, info dbquery.StringQueryInfo, manufacturerFilter *dbquery.StringQueryInfo, modelFilter *dbquery.StringQueryInfo, componentTypes []devicetypes.ComponentType, pagination *dbquery.Pagination, orderBy *dbquery.OrderBy) ([]*component.Component, int32, error)

GetListOfComponents lists components matching the given criteria.

func (*ManagerImpl) GetListOfNVLDomains

func (m *ManagerImpl) GetListOfNVLDomains(ctx context.Context, info dbquery.StringQueryInfo, pagination *dbquery.Pagination) ([]*nvldomain.NVLDomain, int32, error)

GetListOfNVLDomains lists NVL domains matching the given criteria.

func (*ManagerImpl) GetListOfRacks

func (m *ManagerImpl) GetListOfRacks(ctx context.Context, info dbquery.StringQueryInfo, manufacturerFilter *dbquery.StringQueryInfo, modelFilter *dbquery.StringQueryInfo, pagination *dbquery.Pagination, orderBy *dbquery.OrderBy, withComponents bool) ([]*rack.Rack, int32, error)

GetListOfRacks lists racks matching the given criteria.

func (*ManagerImpl) GetRackByID

func (m *ManagerImpl) GetRackByID(ctx context.Context, id uuid.UUID, withComponents bool) (*rack.Rack, error)

GetRackByID retrieves a rack by its UUID.

func (*ManagerImpl) GetRackByIdentifier

func (m *ManagerImpl) GetRackByIdentifier(ctx context.Context, identifier identifier.Identifier, withComponents bool) (*rack.Rack, error)

GetRackByIdentifier retrieves a rack by its identifier (ID or name).

func (*ManagerImpl) GetRackBySerial

func (m *ManagerImpl) GetRackBySerial(ctx context.Context, manufacturer string, serial string, withComponents bool) (*rack.Rack, error)

GetRackBySerial retrieves a rack by its serial number and manufacturer.

func (*ManagerImpl) GetRacksByIDs

func (m *ManagerImpl) GetRacksByIDs(ctx context.Context, ids []uuid.UUID, withComponents bool) ([]*rack.Rack, error)

GetRacksByIDs retrieves multiple racks by their UUIDs.

func (*ManagerImpl) GetRacksForNVLDomain

func (m *ManagerImpl) GetRacksForNVLDomain(ctx context.Context, nvlDomainID identifier.Identifier) ([]*rack.Rack, error)

GetRacksForNVLDomain retrieves all racks belonging to an NVL domain.

func (*ManagerImpl) PatchComponent

func (m *ManagerImpl) PatchComponent(ctx context.Context, comp *component.Component) error

PatchComponent updates a single component's fields in the database.

func (*ManagerImpl) PatchRack

func (m *ManagerImpl) PatchRack(ctx context.Context, rack *rack.Rack) (string, error)

PatchRack updates an existing rack.

func (*ManagerImpl) PurgeComponent

func (m *ManagerImpl) PurgeComponent(ctx context.Context, id uuid.UUID) error

PurgeComponent permanently removes a soft-deleted component.

func (*ManagerImpl) PurgeRack

func (m *ManagerImpl) PurgeRack(ctx context.Context, id uuid.UUID) error

PurgeRack permanently removes a soft-deleted rack and its components.

func (*ManagerImpl) Start

func (m *ManagerImpl) Start(ctx context.Context) error

Start starts the manager.

func (*ManagerImpl) Stop

func (m *ManagerImpl) Stop(ctx context.Context) error

Stop stops the manager.

Jump to

Keyboard shortcuts

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