Documentation
¶
Overview ¶
* SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
* SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
* SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
* SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License.
Index ¶
- type Config
- type MemRegistry
- func (ms *MemRegistry) GetAllPmcs(ctx context.Context) ([]*pmc.PMC, error)
- func (ms *MemRegistry) GetPmc(ctx context.Context, mac net.HardwareAddr) (*pmc.PMC, error)
- func (ms *MemRegistry) IsPmcRegistered(ctx context.Context, mac net.HardwareAddr) (bool, error)
- func (ms *MemRegistry) RegisterPmc(ctx context.Context, pmc *pmc.PMC) error
- func (ms *MemRegistry) Start(ctx context.Context) error
- func (ms *MemRegistry) Stop(ctx context.Context) error
- type PmcRegisterType
- type PmcRegistry
- type PostgresPmcRegistry
- func (ps *PostgresPmcRegistry) GetAllPmcs(ctx context.Context) ([]*pmc.PMC, error)
- func (ps *PostgresPmcRegistry) GetPmc(ctx context.Context, mac net.HardwareAddr) (*pmc.PMC, error)
- func (ps *PostgresPmcRegistry) IsPmcRegistered(ctx context.Context, mac net.HardwareAddr) (bool, error)
- func (ps *PostgresPmcRegistry) RegisterPmc(ctx context.Context, pmc *pmc.PMC) error
- func (ps *PostgresPmcRegistry) Start(ctx context.Context) error
- func (ps *PostgresPmcRegistry) Stop(ctx context.Context) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
DSType PmcRegisterType
DSConf cdb.Config
}
Config holds the selected backend type and DB configuration.
type MemRegistry ¶
type MemRegistry struct {
// contains filtered or unexported fields
}
MemRegistry is an in-memory implementation of PmcRegistry, safe for concurrent access.
func NewMemRegistry ¶
func NewMemRegistry() *MemRegistry
NewMemRegistry creates a new in-memory PMC registry.
func (*MemRegistry) GetAllPmcs ¶
GetAllPmcs returns all registered PMCs.
func (*MemRegistry) GetPmc ¶
func (ms *MemRegistry) GetPmc(ctx context.Context, mac net.HardwareAddr) (*pmc.PMC, error)
GetPmc returns the PMC by MAC or an error if not found.
func (*MemRegistry) IsPmcRegistered ¶
func (ms *MemRegistry) IsPmcRegistered(ctx context.Context, mac net.HardwareAddr) (bool, error)
IsPmcRegistered checks if a PMC has been registered with the specified MAC.
func (*MemRegistry) RegisterPmc ¶
RegisterPmc creates or updates a PMC entry keyed by MAC.
type PmcRegisterType ¶
type PmcRegisterType string
PmcRegisterType enumerates registry backends.
const ( RegisterTypePostgres PmcRegisterType = "Postgres" RegisterTypeInMemory PmcRegisterType = "InMemory" )
func StringToDSType ¶
func StringToDSType(s string) (PmcRegisterType, bool)
StringToDSType converts a string to a PmcRegisterType.
type PmcRegistry ¶
type PmcRegistry interface {
Start(ctx context.Context) error
Stop(ctx context.Context) error
RegisterPmc(ctx context.Context, pmc *pmc.PMC) error
IsPmcRegistered(ctx context.Context, mac net.HardwareAddr) (bool, error)
GetPmc(ctx context.Context, mac net.HardwareAddr) (*pmc.PMC, error)
GetAllPmcs(ctx context.Context) ([]*pmc.PMC, error)
}
PmcRegistry stores non-sensitive PMC identity (MAC, IP, vendor) and supports CRUD queries.
type PostgresPmcRegistry ¶
type PostgresPmcRegistry struct {
// contains filtered or unexported fields
}
PostgresPmcRegistry implements the PmcRegister interface and it uses PostgresQL as the datastore.
func NewPostgresRegistryFromDB ¶
func NewPostgresRegistryFromDB(session *cdb.Session) *PostgresPmcRegistry
NewPostgresRegistryFromDB creates a PostgresPmcRegistry from an existing database connection. This is useful for tests where migrations have already been applied.
func (*PostgresPmcRegistry) GetAllPmcs ¶
GetAllPmcs returns all PMCs mapped to domain objects.
func (*PostgresPmcRegistry) GetPmc ¶
func (ps *PostgresPmcRegistry) GetPmc( ctx context.Context, mac net.HardwareAddr, ) (*pmc.PMC, error)
GetPmc queries by MAC and maps DAO → domain.
func (*PostgresPmcRegistry) IsPmcRegistered ¶
func (ps *PostgresPmcRegistry) IsPmcRegistered(ctx context.Context, mac net.HardwareAddr) (bool, error)
IsPmcRegistered returns true if a PMC exists.
func (*PostgresPmcRegistry) RegisterPmc ¶
RegisterPmc creates or updates a PMC row via INSERT … ON CONFLICT upsert, which is safe under concurrent registrations of the same MAC.