solver

package
v1.14.1 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDatastructure = errors.New("installation data structure is invalid")

ErrDatastructure indicates that the overall data structure of an Installation is invalid.

Functions

func InstallationAsVariables

func InstallationAsVariables[IM InstallationData, SM ScopeData, CM CandidateData](
	installation Installation[IM, SM, CM],
) []deppy.Variable

Types

type Candidate

type Candidate[IM InstallationData, SM ScopeData, CM CandidateData] struct {

	// Data contains arbitrary meta data.
	Data CM

	// Constrainers are called on this Candidate to generate [SolverConstraint].
	Constrainers []CandidateConstrainer[IM, SM, CM]
	// contains filtered or unexported fields
}

Candidate represents a specific version of a package that can be installed.

func Solve

func Solve[IM InstallationData, SM ScopeData, CM CandidateData](
	installation Installation[IM, SM, CM],
) ([]Candidate[IM, SM, CM], error)

Solve the given Installation and return a list of Candidate that need to be installed. Calls [Prepare] on the given Installation before solving. If the Installation does not have required packages no candidates and no error is returned.

func (Candidate[_, _, CM]) CandidateData

func (c Candidate[_, _, CM]) CandidateData() CM

func (Candidate[IM, SM, CM]) CandidateScopeAccessor

func (c Candidate[IM, SM, CM]) CandidateScopeAccessor() ScopeAccessor[IM, SM, CM]

func (Candidate) Constraints

func (v Candidate) Constraints() []deppy.Constraint

func (Candidate) Identifier

func (v Candidate) Identifier() deppy.Identifier

type CandidateAccessor

type CandidateAccessor[IM InstallationData, SM ScopeData, CM CandidateData] interface {
	// CandidateScopeAccessor returns a [ScopeAccessor] for the [Scope] that contains this [Candidate].
	CandidateScopeAccessor() ScopeAccessor[IM, SM, CM]
	// CandidateMetadata returns the meta data of the [Candidate].
	CandidateData() CM
}

CandidateAccessor is used to access a Candidate read only.

type CandidateConstrainer

type CandidateConstrainer[IM InstallationData, SM ScopeData, CM CandidateData] func(
	c CandidateAccessor[IM, SM, CM],
) []deppy.Constraint

CandidateConstrainer is used to generate constraints for a Candidate.

type CandidateData

type CandidateData interface {
	CandidateIdentifier() deppy.Identifier
}

type Installation

type Installation[IM InstallationData, SM ScopeData, CM CandidateData] struct {

	// Scopes defines all scopes of this installation.
	Scopes []Scope[IM, SM, CM]
	// Data contains arbitrary meta data.
	Data IM

	// Constrainers are called to generate solver constraints.
	Constrainers []InstallationConstrainer[IM, SM, CM]
	// contains filtered or unexported fields
}

Installation defines an installation problem that is to be resolved.

func (Installation) Constraints

func (v Installation) Constraints() []deppy.Constraint

func (Installation) Identifier

func (v Installation) Identifier() deppy.Identifier

func (Installation[IM, _, _]) InstallationData

func (i Installation[IM, _, _]) InstallationData() IM

func (Installation[IM, SM, CM]) InstallationScopes

func (i Installation[IM, SM, CM]) InstallationScopes() []ScopeAccessor[IM, SM, CM]

type InstallationAccessor

type InstallationAccessor[IM InstallationData, SM ScopeData, CM CandidateData] interface {
	// InstallationScopes returns all [Scope] of the [Installation].
	// Returned slice may be modified.
	InstallationScopes() []ScopeAccessor[IM, SM, CM]
	// InstallationMetadata returns the meta data of the [Installation].
	InstallationData() IM
}

InstallationAccessor is used to access a Installation read only.

type InstallationConstrainer

type InstallationConstrainer[IM InstallationData, SM ScopeData, CM CandidateData] func(
	i InstallationAccessor[IM, SM, CM],
) []deppy.Constraint

InstallationConstrainer is used to generate constraints for an Installation.

type InstallationData

type InstallationData any

type MockCandidateData

type MockCandidateData struct {
	ID string
}

func (MockCandidateData) CandidateIdentifier

func (c MockCandidateData) CandidateIdentifier() deppy.Identifier

type MockScopeData

type MockScopeData struct {
	ID string
}

func (MockScopeData) ScopeIdentifier

func (s MockScopeData) ScopeIdentifier() deppy.Identifier

type Scope

type Scope[IM InstallationData, SM ScopeData, CM CandidateData] struct {

	// Constrainers are called to generate solver constraints.
	Constrainers []ScopeConstrainer[IM, SM, CM]
	// Data contains arbitrary meta data.
	Data SM

	// Candidates defines all installation candidates in this scope.
	Candidates []Candidate[IM, SM, CM]
	// contains filtered or unexported fields
}

Scope represents a scope in an Installation.

func (Scope) Constraints

func (v Scope) Constraints() []deppy.Constraint

func (Scope) Identifier

func (v Scope) Identifier() deppy.Identifier

func (Scope[IM, SM, CM]) ScopeCandidateAccessors

func (s Scope[IM, SM, CM]) ScopeCandidateAccessors() []CandidateAccessor[IM, SM, CM]

func (Scope[_, SM, _]) ScopeData

func (s Scope[_, SM, _]) ScopeData() SM

func (Scope[IM, SM, CM]) ScopeInstallationAccessor

func (s Scope[IM, SM, CM]) ScopeInstallationAccessor() InstallationAccessor[IM, SM, CM]

type ScopeAccessor

type ScopeAccessor[IM InstallationData, SM ScopeData, CM CandidateData] interface {
	// ScopeMetadata returns the meta data of this [Scope].
	ScopeData() SM
	// ScopeCandidateAccessors returns all [Candidate] of the [Scope].
	// Returned slice may be modified.
	ScopeCandidateAccessors() []CandidateAccessor[IM, SM, CM]
	// ScopeInstallationAccessor returns the [InstallationAccessor] to
	// the [Installation] this [Scope] belongs to.
	ScopeInstallationAccessor() InstallationAccessor[IM, SM, CM]
}

ScopeAccessor is used to generate constraints for an Scope.

type ScopeConstrainer

type ScopeConstrainer[IM InstallationData, SM ScopeData, CM CandidateData] func(
	s ScopeAccessor[IM, SM, CM],
) []deppy.Constraint

ScopeConstrainer is used to generate constraints for a Scope.

type ScopeData

type ScopeData interface {
	ScopeIdentifier() deppy.Identifier
}

Jump to

Keyboard shortcuts

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