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) AddEdge(e Edge) bool
- func (d *DAG) AddVertex(v Vertex) bool
- func (d *DAG) Connect(from, to Vertex) bool
- 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) Vertices() []Vertex
- func (d *DAG) WalkReverseTopoOrder(walkFunc WalkFunc) error
- func (d *DAG) WalkTopoOrder(walkFunc WalkFunc) error
- type Edge
- type Plan
- type PlanBuilder
- type TransformContext
- type Transformer
- type TransformerChain
- type Vertex
- type WalkFunc
Constants ¶
This section is empty.
Variables ¶
var ErrNoops = errors.New("No-Ops")
ErrNoops 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) RemoveVertex ¶
RemoveVertex delete 'v' from 'd' the in&out edges are also deleted
func (*DAG) Root ¶
Root return root vertex that has no in adjacent. our DAG should have one and only one root vertex
func (*DAG) WalkReverseTopoOrder ¶
WalkReverseTopoOrder walk the DAG 'd' in reverse topology order
func (*DAG) WalkTopoOrder ¶
WalkTopoOrder walk the DAG 'd' in 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.ReadonlyClient 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