Documentation
¶
Index ¶
- Constants
- func InsertMetadata(ctx context.Context, db domain.TxnRunner, ...) error
- type State
- func (s *State) AllCloudImageMetadata(ctx context.Context) ([]cloudimagemetadata.Metadata, error)
- func (s *State) DeleteMetadataWithImageID(ctx context.Context, imageID string) error
- func (s *State) FindMetadata(ctx context.Context, criteria cloudimagemetadata.MetadataFilter) ([]cloudimagemetadata.Metadata, error)
- func (s *State) SaveMetadata(ctx context.Context, metadata []cloudimagemetadata.Metadata) error
- func (s *State) SupportedArchitectures(context.Context) set.Strings
Constants ¶
const ( // ExpirationDelay is the maximum time a metadata can live in the cache before being removed. ExpirationDelay = 5 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type State ¶
State encapsulates the state management, logging, and architecture data.
func NewState ¶
NewState creates a new State instance using the provided database transaction factory and logger.
func (*State) AllCloudImageMetadata ¶
AllCloudImageMetadata retrieves all cloud image metadata from the database without applying any filter criteria. Returns a slice of cloudimagemetadata.Metadata and any error encountered during the retrieval process.
func (*State) DeleteMetadataWithImageID ¶
DeleteMetadataWithImageID deletes all metadata associated with the given image ID from the database.
func (*State) FindMetadata ¶
func (s *State) FindMetadata(ctx context.Context, criteria cloudimagemetadata.MetadataFilter) ([]cloudimagemetadata.Metadata, error)
FindMetadata retrieves cloud image metadata from the database based on specified filter criteria. It constructs a dynamic SQL query using the supplied criteria and executes it to fetch matching records. Returns cloudmetadataerrors.NotFound if none are found with this criteria.
func (*State) SaveMetadata ¶
SaveMetadata stores the provided list of cloud image metadata into the database.
Returns any errors occurred during db transaction.
It also fires a cleanup for old images, if any.
cloudimagemetadata.Metadata are considered unique among a signature, composed of these fields:
- Stream
- Region
- Version
- Arch
- VirtType
- RootStorageType
- Source
Above behaviors applies for duplicated inserted metadata:
- If a metadata has the same signature than an existing one in the database, the imageID will be updated with the new value in the existing metadata
- If a several metadata have the same signature in the list, it will cause a unique constraint error from the database. It is likely a programmatic error.