planner

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: MPL-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxGoroutines = uint64(100)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ModulePlan

type ModulePlan struct {
	Instruction map[string]interface{}

	// Which module is this execution plan generated for
	*module.Module

	// Scope at the module level
	ModuleScope *Scope

	// The execution plan of the submodule
	SubModulesPlan []*ModulePlan

	// The execution plan of the rule under this module
	RulesPlan []*RulePlan
}

ModulePlan Represents the execution plan of a module

func MakeModuleQueryPlan

func MakeModuleQueryPlan(ctx context.Context, options *ModulePlannerOptions) (*ModulePlan, *schema.Diagnostics)

MakeModuleQueryPlan Generate an execution plan for the module

type ModulePlanner

type ModulePlanner struct {
	// contains filtered or unexported fields
}

ModulePlanner Used to generate an execution plan for a module

func NewModulePlanner

func NewModulePlanner(options *ModulePlannerOptions) *ModulePlanner

func (*ModulePlanner) MakePlan

func (x *ModulePlanner) MakePlan(ctx context.Context) (*ModulePlan, *schema.Diagnostics)

func (*ModulePlanner) Name

func (x *ModulePlanner) Name() string

type ModulePlannerOptions

type ModulePlannerOptions struct {
	Instruction map[string]interface{}
	// make plan for which module
	Module *module.Module

	// Table to Provider mapping
	TableToProviderMap map[string]string
}

ModulePlannerOptions Options when creating the Module Planner

type Planner

type Planner[T any] interface {

	// Name The name of the planner
	Name() string

	// MakePlan Make a plan
	MakePlan(ctx context.Context) (T, *schema.Diagnostics)
}

Planner Represents a planner that can generate a plan

type ProviderContext

type ProviderContext struct {

	// Which provider is it?
	ProviderName string

	// Which version
	ProviderVersion string

	DSN string

	// The database stored to
	Schema string

	// A connection to a database instance
	Storage storage.Storage

	// The provider configuration block
	ProviderConfiguration *module.ProviderBlock
}

ProviderContext Ready execution strategy

type ProviderFetchPlan

type ProviderFetchPlan struct {
	*ProviderInstallPlan

	// provider Configuration information used for fetching
	ProviderConfigurationBlock *module.ProviderBlock

	// Which schema to write data to
	FetchToDatabaseSchema string

	// The name of the configuration block to be used, which is left blank if not configured using a configuration file
	ProviderConfigurationName string

	// What is the MD5 of the configuration block if the provider configuration is used
	ProviderConfigurationMD5 string
}

ProviderFetchPlan Indicates the pull plan of a provider

func NewProviderFetchPlan

func NewProviderFetchPlan(providerName, providerVersion string, providerBlock *module.ProviderBlock) *ProviderFetchPlan

func (*ProviderFetchPlan) GetMaxGoroutines

func (x *ProviderFetchPlan) GetMaxGoroutines() uint64

GetMaxGoroutines How many concurrency is used to pull the table data

func (*ProviderFetchPlan) GetNeedPullTablesName

func (x *ProviderFetchPlan) GetNeedPullTablesName() []string

GetNeedPullTablesName Gets which tables to pull when pulling

func (*ProviderFetchPlan) GetProvidersConfigYamlString

func (x *ProviderFetchPlan) GetProvidersConfigYamlString() string

GetProvidersConfigYamlString Obtain the configuration file for running the Provider

type ProviderFetchPlanner

type ProviderFetchPlanner struct {
	// contains filtered or unexported fields
}

func NewProviderFetchPlanner

func NewProviderFetchPlanner(options *ProviderFetchPlannerOptions) *ProviderFetchPlanner

func (*ProviderFetchPlanner) MakePlan

func (*ProviderFetchPlanner) Name

func (x *ProviderFetchPlanner) Name() string

type ProviderFetchPlannerOptions

type ProviderFetchPlannerOptions struct {

	// Which module is the execution plan being generated for
	Module *module.Module

	// Provider version that wins the vote
	ProviderVersionVoteWinnerMap map[string]string

	// DSNS are used to connect to the database to determine which schema to use when using environment variables
	DSN string

	// A place to send messages to the outside world
	MessageChannel *message.Channel[*schema.Diagnostics]
}

ProviderFetchPlannerOptions This parameter is required when creating the provider execution plan

type ProviderInstallPlan

type ProviderInstallPlan struct {
	// Which version of which provider is to be used to pull data
	*registry.Provider
}

ProviderInstallPlan Indicates the installation plan of a provider

func NewProviderInstallPlan

func NewProviderInstallPlan(providerName, providerVersion string) *ProviderInstallPlan

NewProviderInstallPlan Create an installation plan based on the provider name and version number

type ProviderInstallPlanner

type ProviderInstallPlanner struct {
	// contains filtered or unexported fields
}

ProviderInstallPlanner This command is used to plan the provider installation for Module

func NewProviderInstallPlanner

func NewProviderInstallPlanner(module *module.Module) *ProviderInstallPlanner

func (*ProviderInstallPlanner) MakePlan

func (*ProviderInstallPlanner) Name

func (x *ProviderInstallPlanner) Name() string

type ProviderVersionVoteService

type ProviderVersionVoteService struct {
	// contains filtered or unexported fields
}

ProviderVersionVoteService When multiple versions of the same provider are available for a module, which version should be used? So take a vote!

func NewProviderVersionVoteService

func NewProviderVersionVoteService() *ProviderVersionVoteService

func (*ProviderVersionVoteService) Vote

Vote Vote on the module to see which version should be used

type ProviderVote

type ProviderVote struct {
	TotalVoteTimes      int
	ProviderName        string
	VersionVoteCountMap map[string]*VersionVoteSummary
	// contains filtered or unexported fields
}

func NewProviderVote

func NewProviderVote(ctx context.Context, requiredProviderBlock *module.RequireProviderBlock) (*ProviderVote, *schema.Diagnostics)

func (*ProviderVote) GetVoteVersions

func (x *ProviderVote) GetVoteVersions() []string

GetVoteVersions Get the versions that are voted on

func (*ProviderVote) GetWinnersVersionSlice

func (x *ProviderVote) GetWinnersVersionSlice() []string

GetWinnersVersionSlice Gets the version numbers of all versions that won the vote

func (*ProviderVote) GetWinnersVersionVoteSummary

func (x *ProviderVote) GetWinnersVersionVoteSummary() map[string]*VersionVoteSummary

GetWinnersVersionVoteSummary Get the version that wins the vote. There may be multiple versions that win at the same time

func (*ProviderVote) InitProviderVersionVoteCountMap

func (x *ProviderVote) InitProviderVersionVoteCountMap(ctx context.Context, block *module.RequireProviderBlock) *schema.Diagnostics

InitProviderVersionVoteCountMap Obtain the Provider versions from Registry and vote for these products later

func (*ProviderVote) ToModuleAllowProviderVersionMap

func (x *ProviderVote) ToModuleAllowProviderVersionMap() map[*module.Module][]string

ToModuleAllowProviderVersionMap Convert to which versions of this Provider are supported by the module

func (*ProviderVote) Vote

func (x *ProviderVote) Vote(voteModule *module.Module, requiredProviderBlock *module.RequireProviderBlock) *schema.Diagnostics

Vote Each module can participate in voting

type ProvidersFetchPlan

type ProvidersFetchPlan []*ProviderFetchPlan

ProvidersFetchPlan The installation plan of a batch of providers

func (ProvidersFetchPlan) BuildProviderContextMap

func (x ProvidersFetchPlan) BuildProviderContextMap(ctx context.Context, DSN string) (map[string][]*ProviderContext, *schema.Diagnostics)

BuildProviderContextMap Create an execution context for the provider installation plan

type ProvidersInstallPlan

type ProvidersInstallPlan []*ProviderInstallPlan

func MakeProviderInstallPlan

func MakeProviderInstallPlan(ctx context.Context, module *module.Module) (ProvidersInstallPlan, *schema.Diagnostics)

MakeProviderInstallPlan Plan the provider installation for the module

func (ProvidersInstallPlan) ToMap

func (x ProvidersInstallPlan) ToMap() map[string]string

type RulePlan

type RulePlan struct {
	// The execution plan of the module to which it is associated
	ModulePlan *ModulePlan

	// The module to which it is associated
	Module *module.Module

	// Is the execution plan for which block
	*module.RuleBlock

	// Which provider is the rule bound to? Currently, a rule can be bound to only one provider
	BindingProviderName string

	// Render a good rule - bound Query
	Query string

	// Which tables are used in this Query
	BindingTables []string

	RuleScope *Scope
}

func MakeRulePlan

func MakeRulePlan(ctx context.Context, options *RulePlannerOptions) (*RulePlan, *schema.Diagnostics)

MakeRulePlan Plan the execution of the rule

func (*RulePlan) String

func (x *RulePlan) String() string

type RulePlanner

type RulePlanner struct {
	// contains filtered or unexported fields
}

RulePlanner An enforcement plan for this rule

func NewRulePlanner

func NewRulePlanner(options *RulePlannerOptions) *RulePlanner

func (*RulePlanner) MakePlan

func (x *RulePlanner) MakePlan(ctx context.Context) (*RulePlan, *schema.Diagnostics)

MakePlan Develop an implementation plan for rule

func (*RulePlanner) Name

func (x *RulePlanner) Name() string

type RulePlannerOptions

type RulePlannerOptions struct {

	// The execution plan of the module to which it is associated
	ModulePlan *ModulePlan

	// The module to which it is associated
	Module *module.Module

	// The scope of the owning module
	ModuleScope *Scope

	// Is the execution plan for which block
	RuleBlock *module.RuleBlock

	// Mapping between the table and the provider
	TableToProviderMap map[string]string
}

RulePlannerOptions Parameters required when creating a module execution plan

type Scope

type Scope struct {
	// contains filtered or unexported fields
}

Scope Used to represent the scope of a module, scope have some variables can use

func ExtendScope

func ExtendScope(scope *Scope) *Scope

ExtendScope create scope from exists scope

func NewScope

func NewScope() *Scope

NewScope create new scope

func (*Scope) Clone

func (x *Scope) Clone() *Scope

Clone Make a copy of the current scope

func (*Scope) Extend

func (x *Scope) Extend(scope *Scope)

Extend current scope extend other scope

func (*Scope) GetVariable

func (x *Scope) GetVariable(variableName string) (any, bool)

GetVariable Gets the value of a variable

func (*Scope) RenderingTemplate

func (x *Scope) RenderingTemplate(templateName, templateString string) (string, error)

RenderingTemplate Rendering the template using the moduleScope of the current module

func (*Scope) SetVariable

func (x *Scope) SetVariable(variableName string, variableValue any) any

SetVariable Declare a variable

func (*Scope) SetVariableIfNotExists

func (x *Scope) SetVariableIfNotExists(variableName string, variableValue any) bool

SetVariableIfNotExists Declared only if the variable does not exist

func (*Scope) SetVariables

func (x *Scope) SetVariables(variablesMap map[string]any)

SetVariables Batch declaration variable

type VersionVoteSummary

type VersionVoteSummary struct {

	// Which version
	ProviderVersion *version.Version

	// How many votes did you get
	VoteSet map[*module.Module]struct{}
}

func NewVoteSummary

func NewVoteSummary(providerName, providerVersion string) (*VersionVoteSummary, *schema.Diagnostics)

Jump to

Keyboard shortcuts

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