rsl

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRefreshInterval = 10 * time.Minute

DefaultRefreshInterval is the default duration after which the resolver should refresh its state from the reality checker. This is a balance between ensuring reasonably fresh state and avoiding excessive calls to the reality checker, which may be expensive or rate-limited.

View Source
const DefaultRefreshTimeout = 60 * time.Second

DefaultRefreshTimeout is the default timeout for state refresh operations, which may involve calls to external systems and should not be allowed to run indefinitely.

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockNodeRuntimeResolver

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

BlockNodeRuntimeResolver manages the current state of block-node related information, including configuration, user inputs, and reality-checked state.

Resolution strategy (highest -> lowest precedence): 1. Current state (automa.StrategyCurrent)

  • If `br.state != nil` and `br.state.ReleaseInfo.Status == release.StatusDeployed`, the resolver returns the value from `br.state`.
  • For string fields the deployed state is validated to be non-empty; an empty value for a deployed release results in an `errorx.IllegalState` error.

2. User inputs (automa.StrategyUserInput)

  • If no valid deployed current state is available and `br.inputs != nil` (and for strings the input is non-empty), the resolver returns the user-provided value.

3. Config defaults (automa.StrategyConfig)

  • If neither current state nor user inputs supply a value, the resolver returns the config default value.

Notes:

  • Returned values are `*automa.EffectiveValue[T]` carrying the chosen value and the strategy indicating its source.
  • Structured types (e.g. `models.BlockNodeStorage`) follow the same precedence but do not perform non-empty string validation.
  • Helper methods `WithUserInputs`, `WithConfig`, and `WithState` set the resolver's sources so resolution uses those values.
  • The resolver relies on the runtime base for reality checking, last-sync extraction, cloning and default state construction.

func (*BlockNodeRuntimeResolver) ChartName

func (*BlockNodeRuntimeResolver) ChartRef

func (*BlockNodeRuntimeResolver) ChartVersion

ChartVersion resolves the effective chart version for the block node based on the following precedence: 1. If the current state indicates a deployed release and the intent is an upgrade, the resolver checks for a user-provided chart version in the inputs. If provided, this takes precedence. 2. If no user input is provided for the chart version during an upgrade intent, but the current deployed state has a version, that version is used next. 3. If neither of the above provide a chart version during an upgrade intent, the resolver falls back to the config default. 4. For non-upgrade intents, if the current state indicates a deployed release, the chart version from the deployed state is used and cannot be overridden by user input or config. 5. If there is no deployed release, but user input provides a chart version, that is used next. 6. Finally, if none of the above sources provide a chart version, the resolver returns the config default.

This resolution strategy ensures that during an upgrade, user input can specify a new chart version, but if not provided, the system retains the currently deployed version. For non-upgrade actions, the deployed version is authoritative if it exists, preventing unintended changes to the chart version.

func (*BlockNodeRuntimeResolver) CurrentState

func (b *BlockNodeRuntimeResolver) CurrentState() (state.BlockNodeState, error)

func (*BlockNodeRuntimeResolver) Namespace

func (*BlockNodeRuntimeResolver) RefreshState

func (b *BlockNodeRuntimeResolver) RefreshState(ctx context.Context, force bool) error

func (*BlockNodeRuntimeResolver) ReleaseName

func (*BlockNodeRuntimeResolver) Storage

func (*BlockNodeRuntimeResolver) WithConfig

func (*BlockNodeRuntimeResolver) WithIntent

func (*BlockNodeRuntimeResolver) WithState

func (*BlockNodeRuntimeResolver) WithUserInputs

type ClusterRuntimeResolver

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

func (*ClusterRuntimeResolver) CurrentState

func (c *ClusterRuntimeResolver) CurrentState() (state.ClusterState, error)

func (*ClusterRuntimeResolver) RefreshState

func (c *ClusterRuntimeResolver) RefreshState(ctx context.Context, force bool) error

RefreshState refreshes the current state using the configured reality checker. It respects refreshInterval by comparing against the concrete ClusterState.LastSync field rather than using an injected helper.

func (*ClusterRuntimeResolver) WithConfig

func (*ClusterRuntimeResolver) WithIntent

func (*ClusterRuntimeResolver) WithState

func (*ClusterRuntimeResolver) WithUserInputs

type MachineRuntimeResolver

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

func (*MachineRuntimeResolver) CurrentState

func (m *MachineRuntimeResolver) CurrentState() (state.MachineState, error)

func (*MachineRuntimeResolver) RefreshState

func (m *MachineRuntimeResolver) RefreshState(ctx context.Context, force bool) error

RefreshState refreshes the current machine state from the reality checker, using the concrete MachineState.LastSync to apply refresh interval checks.

func (*MachineRuntimeResolver) WithConfig

func (*MachineRuntimeResolver) WithIntent

func (*MachineRuntimeResolver) WithState

func (*MachineRuntimeResolver) WithUserInputs

type Resolver

type Resolver[S any, I any] interface {
	WithIntent(intent models.Intent) Resolver[S, I]
	WithUserInputs(inputs I) Resolver[S, I]
	WithConfig(cfg models.Config) Resolver[S, I]
	WithState(blockNodeState S) Resolver[S, I]
	RefreshState(ctx context.Context, force bool) error
	CurrentState() (S, error)
}

func NewBlockNodeRuntimeResolver

func NewBlockNodeRuntimeResolver(
	cfg models.Config,
	blockNodeState state.BlockNodeState,
	realityChecker reality.Checker[state.BlockNodeState],
	refreshInterval time.Duration,
) (Resolver[state.BlockNodeState, models.BlockNodeInputs], error)

func NewClusterRuntimeResolver

func NewClusterRuntimeResolver(
	cfg models.Config,
	clusterState state.ClusterState,
	realityChecker reality.Checker[state.ClusterState],
	refreshInterval time.Duration,
) (Resolver[state.ClusterState, models.ClusterInputs], error)

NewClusterRuntimeResolver creates a ClusterRuntime with the provided configuration, initial state, reality checker, and refresh interval. The caller is responsible for retaining and injecting the returned instance — no package-level singleton is used.

func NewMachineRuntimeResolver

func NewMachineRuntimeResolver(
	cfg models.Config,
	clusterState state.MachineState,
	realityChecker reality.Checker[state.MachineState],
	refreshInterval time.Duration,
) (Resolver[state.MachineState, models.MachineInputs], error)

NewMachineRuntimeResolver creates a MachineRuntimeResolver with the provided configuration, initial state, reality checker, and refresh interval. The caller is responsible for retaining and injecting the returned instance — no package-level singleton is used.

type RuntimeResolver

type RuntimeResolver struct {
	BlockNodeRuntime Resolver[state.BlockNodeState, models.BlockNodeInputs]
	ClusterRuntime   Resolver[state.ClusterState, models.ClusterInputs]
	MachineRuntime   Resolver[state.MachineState, models.MachineInputs]
	// contains filtered or unexported fields
}

RuntimeResolver holds the fully-initialised runtime components for all node types. It is constructed once at the composition root (main / command init) and injected into every layer that needs it, eliminating package-level singletons.

func NewRuntimeResolver

func NewRuntimeResolver(
	cfg models.Config,
	sm state.Manager,
	realityChecker reality.Checkers,
	refreshInterval time.Duration,
) (*RuntimeResolver, error)

NewRuntimeResolver creates a RuntimeResolver by constructing each runtime from the supplied configuration, current persisted state, reality checker, and refresh interval.

func (*RuntimeResolver) AddActionHistory

func (r *RuntimeResolver) AddActionHistory(entry state.ActionHistory) state.Writer

func (*RuntimeResolver) CurrentState

func (r *RuntimeResolver) CurrentState() (state.State, error)

CurrentState reads the current state from all runtimes and composes it into a single state.State struct. This is the single source of truth for all state reads in the CLI layer, ensuring that all reads are consistent and reflect the latest reality state (subject to each runtime's staleness checks). Ensure to call Refresh() before this to ensure that all runtimes have the latest reality state

func (*RuntimeResolver) FlushAll

func (r *RuntimeResolver) FlushAll(currentState state.State) error

func (*RuntimeResolver) Refresh

func (r *RuntimeResolver) Refresh(ctx context.Context, force bool) (state.State, error)

Refresh forces all runtimes to refresh their state from reality, bypassing any caching or staleness checks. This is useful after any user input that may have changed reality, to ensure that subsequent reads reflect the latest reality state.

Jump to

Keyboard shortcuts

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