Documentation ¶
Overview ¶
Package graph tries to model the controller reconciliation loop in a more structured way. It structures the reconciliation loop to 3 stage: Init, Build and Execute.
Initialization Stage ¶
the Init stage is for meta loading, object query etc. Try loading infos that used in the following stages.
Building Stage ¶
## Validation
The first part of Building is Validation, which Validates everything (object spec is legal, resources in K8s cluster are enough etc.) to make sure the following Build and Execute parts can go well.
## Building The Building part's target is to generate an execution plan. The plan is composed by a DAG which represents the actions that should be taken on all K8s native objects owned by the controller, a group of Transformers which transform the initial DAG to the final one, and a WalkFunc which does the real action when the final DAG is walked through.
Execution Stage ¶
The plan is executed in this stage, all the object manipulations(create/update/delete) are committed.
Index ¶
- Variables
- type DAG
- func (d *DAG) AddConnect(from, to Vertex) bool
- func (d *DAG) AddConnectRoot(v Vertex) bool
- func (d *DAG) AddEdge(e Edge) bool
- func (d *DAG) AddVertex(v Vertex) bool
- func (d *DAG) Connect(from, to Vertex) bool
- func (d *DAG) Equals(other *DAG, less func(v1, v2 Vertex) bool) bool
- func (d *DAG) Merge(subDag *DAG)
- func (d *DAG) RemoveEdge(e Edge) bool
- func (d *DAG) RemoveVertex(v Vertex) bool
- func (d *DAG) Root() Vertex
- func (d *DAG) String() string
- func (d *DAG) Validate() error
- func (d *DAG) Vertices() []Vertex
- func (d *DAG) WalkBFS(walkFunc WalkFunc) error
- func (d *DAG) WalkReverseTopoOrder(walkFunc WalkFunc, less func(v1, v2 Vertex) bool) error
- func (d *DAG) WalkTopoOrder(walkFunc WalkFunc, less func(v1, v2 Vertex) bool) error
- type Edge
- type Plan
- type PlanBuilder
- type TransformContext
- type Transformer
- type TransformerChain
- type Vertex
- type WalkFunc
Constants ¶
This section is empty.
Variables ¶
var ErrPrematureStop = errors.New("Premature-Stop")
ErrPrematureStop is used to stop the Transformer chain for some purpose. Use it in Transformer.Transform when all jobs have done and no need to run following transformers
Functions ¶
This section is empty.
Types ¶
type DAG ¶
type DAG struct {
// contains filtered or unexported fields
}
func (*DAG) AddConnect ¶
AddConnect add 'to' to the DAG 'd' and connect 'from' to 'to'
func (*DAG) AddConnectRoot ¶
AddConnectRoot add 'v' to the DAG 'd' and connect root to 'v'
func (*DAG) Equals ¶
Equals tells whether two DAGs are equal `less` tells whether vertex 'v1' is less than vertex 'v2'. `less` should return false if 'v1' equals to 'v2'.
func (*DAG) RemoveVertex ¶
RemoveVertex deletes 'v' from 'd' the in&out edges are also deleted
func (*DAG) Root ¶
Root returns root vertex that has no in adjacent. our DAG should have one and only one root vertex
func (*DAG) WalkReverseTopoOrder ¶
WalkReverseTopoOrder walks the DAG 'd' in reverse topology order
type Plan ¶
type Plan interface { // Execute the plan Execute() error }
Plan defines the final actions should be executed.
type PlanBuilder ¶
type PlanBuilder interface { // Init loads the primary object to be reconciled, and does meta initialization Init() error // AddTransformer adds transformers to the builder in sequence order. // And the transformers will be executed in the add order. AddTransformer(transformer ...Transformer) PlanBuilder // AddParallelTransformer adds transformers to the builder. // And the transformers will be executed in parallel. AddParallelTransformer(transformer ...Transformer) PlanBuilder // Build runs all the transformers added by AddTransformer and/or AddParallelTransformer. Build() (Plan, error) }
PlanBuilder builds a Plan by applying a group of Transformer to an empty DAG.
type TransformContext ¶
type TransformContext interface { GetContext() context.Context GetClient() client.Reader GetRecorder() record.EventRecorder GetLogger() logr.Logger }
TransformContext is used by Transformer.Transform
type Transformer ¶
type Transformer interface {
Transform(ctx TransformContext, dag *DAG) error
}
Transformer transforms a DAG to a new version
type TransformerChain ¶
type TransformerChain []Transformer
TransformerChain chains a group Transformer together
func (TransformerChain) ApplyTo ¶
func (r TransformerChain) ApplyTo(ctx TransformContext, dag *DAG) error
ApplyTo applies TransformerChain t to dag