Documentation
¶
Overview ¶
Package store provides the storage layer for inventory management. It defines the InventoryStore interface for persisting and retrieving inventory data (racks, components, NVL domains).
Index ¶
- type ComponentDrift
- type FieldDiff
- type PostgresStore
- func (s *PostgresStore) AddComponent(ctx context.Context, comp *component.Component) (uuid.UUID, error)
- func (s *PostgresStore) AttachRacksToNVLDomain(ctx context.Context, nvlDomainID identifier.Identifier, ...) error
- func (s *PostgresStore) CreateExpectedRack(ctx context.Context, rack *rack.Rack) (uuid.UUID, error)
- func (s *PostgresStore) CreateNVLDomain(ctx context.Context, nvlDomain *nvldomain.NVLDomain) (uuid.UUID, error)
- func (s *PostgresStore) DeleteComponent(ctx context.Context, id uuid.UUID) error
- func (s *PostgresStore) DeleteRack(ctx context.Context, id uuid.UUID) error
- func (s *PostgresStore) DetachRacksFromNVLDomain(ctx context.Context, rackIDs []identifier.Identifier) error
- func (s *PostgresStore) GetAllDrifts(ctx context.Context) ([]ComponentDrift, error)
- func (s *PostgresStore) GetComponentByBMCMAC(ctx context.Context, macAddress string) (*component.Component, error)
- func (s *PostgresStore) GetComponentByID(ctx context.Context, id uuid.UUID) (*component.Component, error)
- func (s *PostgresStore) GetComponentBySerial(ctx context.Context, manufacturer string, serialNumber string, withRack bool) (*component.Component, error)
- func (s *PostgresStore) GetComponentsByExternalIDs(ctx context.Context, externalIDs []string) ([]*component.Component, error)
- func (s *PostgresStore) GetDriftsByComponentIDs(ctx context.Context, componentIDs []uuid.UUID) ([]ComponentDrift, error)
- func (s *PostgresStore) GetListOfComponents(ctx context.Context, info dbquery.StringQueryInfo, ...) ([]*component.Component, int32, error)
- func (s *PostgresStore) GetListOfNVLDomains(ctx context.Context, info dbquery.StringQueryInfo, ...) ([]*nvldomain.NVLDomain, int32, error)
- func (s *PostgresStore) GetListOfRacks(ctx context.Context, info dbquery.StringQueryInfo, ...) ([]*rack.Rack, int32, error)
- func (s *PostgresStore) GetRackByID(ctx context.Context, id uuid.UUID, withComponents bool) (*rack.Rack, error)
- func (s *PostgresStore) GetRackByIdentifier(ctx context.Context, identifier identifier.Identifier, withComponents bool) (*rack.Rack, error)
- func (s *PostgresStore) GetRackBySerial(ctx context.Context, manufacturer string, serialNumber string, ...) (*rack.Rack, error)
- func (s *PostgresStore) GetRacksByIDs(ctx context.Context, ids []uuid.UUID, withComponents bool) ([]*rack.Rack, error)
- func (s *PostgresStore) GetRacksForNVLDomain(ctx context.Context, nvlDomainID identifier.Identifier) ([]*rack.Rack, error)
- func (s *PostgresStore) PatchComponent(ctx context.Context, comp *component.Component) error
- func (s *PostgresStore) PatchRack(ctx context.Context, r *rack.Rack) (string, error)
- func (s *PostgresStore) PurgeComponent(ctx context.Context, id uuid.UUID) error
- func (s *PostgresStore) PurgeRack(ctx context.Context, id uuid.UUID) error
- func (s *PostgresStore) Start(ctx context.Context) error
- func (s *PostgresStore) Stop(ctx context.Context) error
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ComponentDrift ¶
type ComponentDrift struct {
ID uuid.UUID
ComponentID *uuid.UUID // NULL for missing_in_expected
ExternalID *string // Component ID from the component manager service; NULL for missing_in_actual
DriftType string // "missing_in_expected", "missing_in_actual", "mismatch"
Diffs []FieldDiff // Field-level differences (for mismatch type)
CheckedAt time.Time
}
ComponentDrift represents a drift detected between expected (local DB) and actual (source system) data.
type PostgresStore ¶
type PostgresStore struct {
// contains filtered or unexported fields
}
PostgresStore implements the Store interface using PostgreSQL.
func NewPostgres ¶
func NewPostgres(pg *cdb.Session) *PostgresStore
NewPostgres creates a new PostgreSQL-backed inventory store.
func (*PostgresStore) AddComponent ¶
func (s *PostgresStore) AddComponent(ctx context.Context, comp *component.Component) (uuid.UUID, error)
AddComponent creates a single component (with BMCs) in the database and returns its UUID.
func (*PostgresStore) AttachRacksToNVLDomain ¶
func (s *PostgresStore) AttachRacksToNVLDomain( ctx context.Context, nvlDomainID identifier.Identifier, rackIDs []identifier.Identifier, ) error
AttachRacksToNVLDomain attaches racks to an NVL domain.
func (*PostgresStore) CreateExpectedRack ¶
func (s *PostgresStore) CreateExpectedRack( ctx context.Context, rack *rack.Rack, ) (uuid.UUID, error)
CreateExpectedRack creates an expected rack in the database and returns its UUID.
func (*PostgresStore) CreateNVLDomain ¶
func (s *PostgresStore) CreateNVLDomain( ctx context.Context, nvlDomain *nvldomain.NVLDomain, ) (uuid.UUID, error)
CreateNVLDomain creates a new NVL domain.
func (*PostgresStore) DeleteComponent ¶
DeleteComponent soft-deletes a component by UUID.
func (*PostgresStore) DeleteRack ¶
DeleteRack soft-deletes a rack and all its components in a single transaction.
func (*PostgresStore) DetachRacksFromNVLDomain ¶
func (s *PostgresStore) DetachRacksFromNVLDomain( ctx context.Context, rackIDs []identifier.Identifier, ) error
DetachRacksFromNVLDomain detaches racks from their NVL domain.
func (*PostgresStore) GetAllDrifts ¶
func (s *PostgresStore) GetAllDrifts(ctx context.Context) ([]ComponentDrift, error)
GetAllDrifts retrieves all drift records.
func (*PostgresStore) GetComponentByBMCMAC ¶
func (s *PostgresStore) GetComponentByBMCMAC( ctx context.Context, macAddress string, ) (*component.Component, error)
GetComponentByBMCMAC retrieves a component by its BMC MAC address.
func (*PostgresStore) GetComponentByID ¶
func (s *PostgresStore) GetComponentByID( ctx context.Context, id uuid.UUID, ) (*component.Component, error)
GetComponentByID retrieves a component by its UUID.
func (*PostgresStore) GetComponentBySerial ¶
func (s *PostgresStore) GetComponentBySerial( ctx context.Context, manufacturer string, serialNumber string, withRack bool, ) (*component.Component, error)
GetComponentBySerial retrieves a component by its serial number and manufacturer.
func (*PostgresStore) GetComponentsByExternalIDs ¶
func (s *PostgresStore) GetComponentsByExternalIDs( ctx context.Context, externalIDs []string, ) ([]*component.Component, error)
GetComponentsByExternalIDs retrieves components by their external IDs.
func (*PostgresStore) GetDriftsByComponentIDs ¶
func (s *PostgresStore) GetDriftsByComponentIDs(ctx context.Context, componentIDs []uuid.UUID) ([]ComponentDrift, error)
GetDriftsByComponentIDs retrieves drift records for the given component UUIDs.
func (*PostgresStore) GetListOfComponents ¶
func (s *PostgresStore) 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 (*PostgresStore) GetListOfNVLDomains ¶
func (s *PostgresStore) GetListOfNVLDomains( ctx context.Context, info dbquery.StringQueryInfo, pagination *dbquery.Pagination, ) ([]*nvldomain.NVLDomain, int32, error)
GetListOfNVLDomains lists NVL domains matching the given criteria.
func (*PostgresStore) GetListOfRacks ¶
func (s *PostgresStore) 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 (*PostgresStore) GetRackByID ¶
func (s *PostgresStore) GetRackByID( ctx context.Context, id uuid.UUID, withComponents bool, ) (*rack.Rack, error)
GetRackByID retrieves a rack by its UUID, optionally with its components.
func (*PostgresStore) GetRackByIdentifier ¶
func (s *PostgresStore) GetRackByIdentifier( ctx context.Context, identifier identifier.Identifier, withComponents bool, ) (*rack.Rack, error)
GetRackByIdentifier retrieves a rack by its identifier (ID or name).
func (*PostgresStore) GetRackBySerial ¶
func (s *PostgresStore) GetRackBySerial( ctx context.Context, manufacturer string, serialNumber string, withComponents bool, ) (*rack.Rack, error)
GetRackBySerial retrieves a rack by its serial number and manufacturer.
func (*PostgresStore) GetRacksByIDs ¶
func (s *PostgresStore) GetRacksByIDs( ctx context.Context, ids []uuid.UUID, withComponents bool, ) ([]*rack.Rack, error)
GetRacksByIDs retrieves multiple racks by their UUIDs, optionally with their components.
func (*PostgresStore) GetRacksForNVLDomain ¶
func (s *PostgresStore) GetRacksForNVLDomain( ctx context.Context, nvlDomainID identifier.Identifier, ) ([]*rack.Rack, error)
GetRacksForNVLDomain retrieves all racks belonging to an NVL domain.
func (*PostgresStore) PatchComponent ¶
PatchComponent updates a single component's fields and reconciles BMCs in the database.
func (*PostgresStore) PurgeComponent ¶
PurgeComponent permanently removes a soft-deleted component.
func (*PostgresStore) PurgeRack ¶
PurgeRack permanently removes a soft-deleted rack and its components.
type Store ¶
type Store 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) ([]ComponentDrift, error)
GetAllDrifts(ctx context.Context) ([]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)
}
Store defines the interface for inventory data persistence. It provides operations for managing racks (with components) and NVL domains.