services

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ConditionValidationErrorMissing = "missing"
)

Condition validation error type

View Source
const MaxListSize = 65500

~65500 is the maximum number of parameters that can be provided to a postgres WHERE IN clause Use it as a sane max

Variables

View Source
var (
	SearchDisallowedFields = map[string]map[string]string{
		"Cluster": {
			"spec": "spec",
		},
		"NodePool": {
			"spec": "spec",
		},
	}
)

Functions

func AdapterObservedTime added in v0.2.0

func AdapterObservedTime(as *api.AdapterStatus) time.Time

AdapterObservedTime returns the adapter-reported observation instant used for ordering and aggregation.

func AggregateResourceStatus added in v0.2.0

func AggregateResourceStatus(ctx context.Context, in AggregateResourceStatusInput) (
	ready, available api.ResourceCondition, adapterConditions []api.ResourceCondition,
)

AggregateResourceStatus computes Ready, Available, and per-adapter conditions from stored adapter rows and previous conditions. It does not use wall clock.

The returned adapterConditions slice contains one entry per required adapter that has reported, with a type derived from the adapter name (e.g. "adapter1" → "Adapter1Successful").

func MapAdapterToConditionType

func MapAdapterToConditionType(adapterName string) string

MapAdapterToConditionType converts an adapter name to a semantic condition type (PascalCase + suffix). Used to derive the type name for per-adapter conditions mirrored into resource status (e.g. "adapter1" → "Adapter1Successful", "my-adapter" → "MyAdapterSuccessful").

func ValidateMandatoryConditions added in v0.1.1

func ValidateMandatoryConditions(conditions []api.AdapterCondition) (errorType, conditionName string)

ValidateMandatoryConditions checks if all mandatory conditions are present. Format validation (empty type, duplicates, invalid status) is done in the Handler layer.

Types

type AdapterStatusService

type AdapterStatusService interface {
	Get(ctx context.Context, id string) (*api.AdapterStatus, *errors.ServiceError)
	Create(ctx context.Context, adapterStatus *api.AdapterStatus) (*api.AdapterStatus, *errors.ServiceError)
	Replace(ctx context.Context, adapterStatus *api.AdapterStatus) (*api.AdapterStatus, *errors.ServiceError)
	Upsert(ctx context.Context, adapterStatus *api.AdapterStatus) (*api.AdapterStatus, *errors.ServiceError)
	Delete(ctx context.Context, id string) *errors.ServiceError
	FindByResource(
		ctx context.Context, resourceType, resourceID string,
	) (api.AdapterStatusList, *errors.ServiceError)
	FindByResourcePaginated(
		ctx context.Context, resourceType, resourceID string, listArgs *ListArguments,
	) (api.AdapterStatusList, int64, *errors.ServiceError)
	FindByResourceAndAdapter(
		ctx context.Context, resourceType, resourceID, adapter string,
	) (*api.AdapterStatus, *errors.ServiceError)
	All(ctx context.Context) (api.AdapterStatusList, *errors.ServiceError)
}

func NewAdapterStatusService

func NewAdapterStatusService(adapterStatusDao dao.AdapterStatusDao) AdapterStatusService

type AggregateResourceStatusInput added in v0.2.0

type AggregateResourceStatusInput struct {
	ResourceGeneration int32
	RefTime            time.Time
	PrevConditionsJSON []byte
	RequiredAdapters   []string
	AdapterStatuses    api.AdapterStatusList
}

AggregateResourceStatusInput carries everything needed to compute deterministic conditions. RefTime must be resource.updated_time (never time.Now) so results are reproducible.

type ClusterService

type ClusterService interface {
	Get(ctx context.Context, id string) (*api.Cluster, *errors.ServiceError)
	Create(ctx context.Context, cluster *api.Cluster) (*api.Cluster, *errors.ServiceError)
	Replace(ctx context.Context, cluster *api.Cluster) (*api.Cluster, *errors.ServiceError)
	Delete(ctx context.Context, id string) *errors.ServiceError
	All(ctx context.Context) (api.ClusterList, *errors.ServiceError)

	FindByIDs(ctx context.Context, ids []string) (api.ClusterList, *errors.ServiceError)

	// UpdateClusterStatusFromAdapters recomputes aggregated Ready and Available from stored adapter rows.
	UpdateClusterStatusFromAdapters(ctx context.Context, clusterID string) (*api.Cluster, *errors.ServiceError)

	// ProcessAdapterStatus validates mandatory conditions, applies discard rules, upserts adapter status,
	// and triggers aggregation when appropriate.
	ProcessAdapterStatus(
		ctx context.Context, clusterID string, adapterStatus *api.AdapterStatus,
	) (*api.AdapterStatus, *errors.ServiceError)

	// idempotent functions for the control plane, but can also be called synchronously by any actor
	OnUpsert(ctx context.Context, id string) error
	OnDelete(ctx context.Context, id string) error
}

func NewClusterService

func NewClusterService(
	clusterDao dao.ClusterDao,
	adapterStatusDao dao.AdapterStatusDao,
	adapterConfig *config.AdapterRequirementsConfig,
) ClusterService

type GenericService

type GenericService interface {
	List(
		ctx context.Context, username string, args *ListArguments, resourceList interface{},
	) (*api.PagingMeta, *errors.ServiceError)
}

func NewGenericService

func NewGenericService(genericDao dao.GenericDao) GenericService

type ListArguments

type ListArguments struct {
	Search   string
	Preloads []string
	OrderBy  []string
	Fields   []string
	Page     int
	Size     int64
}

ListArguments are arguments relevant for listing objects. This struct is common to all service List funcs in this package

func NewListArguments

func NewListArguments(params url.Values) *ListArguments

NewListArguments Create ListArguments from url query parameters with sane defaults

type NodePoolService

type NodePoolService interface {
	Get(ctx context.Context, id string) (*api.NodePool, *errors.ServiceError)
	Create(ctx context.Context, nodePool *api.NodePool) (*api.NodePool, *errors.ServiceError)
	Replace(ctx context.Context, nodePool *api.NodePool) (*api.NodePool, *errors.ServiceError)
	Delete(ctx context.Context, id string) *errors.ServiceError
	All(ctx context.Context) (api.NodePoolList, *errors.ServiceError)

	FindByIDs(ctx context.Context, ids []string) (api.NodePoolList, *errors.ServiceError)

	UpdateNodePoolStatusFromAdapters(ctx context.Context, nodePoolID string) (*api.NodePool, *errors.ServiceError)

	ProcessAdapterStatus(
		ctx context.Context, nodePoolID string, adapterStatus *api.AdapterStatus,
	) (*api.AdapterStatus, *errors.ServiceError)

	OnUpsert(ctx context.Context, id string) error
	OnDelete(ctx context.Context, id string) error
}

func NewNodePoolService

func NewNodePoolService(
	nodePoolDao dao.NodePoolDao,
	adapterStatusDao dao.AdapterStatusDao,
	adapterConfig *config.AdapterRequirementsConfig,
) NodePoolService

Jump to

Keyboard shortcuts

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