application

package
v0.8.8 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

This file owns Mapper — the translation layer between the resolved ServiceUnit contract and the domain ServiceUnit aggregate consumed by the application service.

The Mapper enforces the resolution contract: it panics on fields the resolver guarantees to be present or valid (a recognised Type) so that resolver bugs surface loudly rather than silently producing a mistyped aggregate. This mirrors pkg/apis/route/application/mapper.go's convention.

This file owns ServiceUnitService — the application service that orchestrates the ServiceUnit reconciliation pipeline.

ServiceUnitService is the single entry point called by the ServiceUnit controller after resolution. Unlike RouteService or BuildService, there is no BackendSelector/Provider dispatch step: a ServiceUnit does not materialize anything onto infrastructure itself (a Deployment CR does that). The pipeline is:

  1. Map the resolved ServiceUnit contract to a domain ServiceUnit (Mapper).
  2. Derive the outcome directly from the mapped fields (deriveResult).
  3. Write the outcome back to the ServiceUnit CR status (StatusWriter).
  4. Publish the resolved contract to the field-level cache (ServiceUnitCache), best-effort — a cache write failure costs queryability for downstream readers (e.g. a Deployment doing a fast-path lookup), never correctness of this reconcile. Never allowed to fail the Reconcile call.

This write is the authoritative signal downstream consumers (e.g. a Deployment CR referencing this unit) should read, rather than re-deriving ServiceUnit state inline from the raw resolved contract themselves.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mapper

type Mapper struct{}

Mapper translates a ResolvedServiceUnit into a domain.ServiceUnit.

func NewMapper

func NewMapper() *Mapper

NewMapper constructs a Mapper.

func (Mapper) MapResolvedToDomain

MapResolvedToDomain converts a fully resolved ServiceUnit into a domain ServiceUnit for consumption by the application service.

Panics on resolver invariant violations (unrecognised Type) — these indicate a resolver bug, not a user error, and must not be silently swallowed. All other fields are mapped verbatim.

type ServiceUnitService

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

ServiceUnitService orchestrates the ServiceUnit reconciliation pipeline. It is stateless beyond its collaborators and safe for concurrent use.

func NewServiceUnitService

func NewServiceUnitService(mapper *Mapper, status *StatusWriter, cache *serviceunitCache.ServiceUnitCache) *ServiceUnitService

NewServiceUnitService constructs a ServiceUnitService with the required collaborators.

func (*ServiceUnitService) Reconcile

Reconcile executes the full ServiceUnit pipeline for a resolved ServiceUnit CR. It maps, derives, writes status, and publishes to the field-level cache in sequence.

type StatusWriter

type StatusWriter struct {
	Client client.Client
	Log    logr.Logger
}

StatusWriter persists ServiceUnit conditions to the CR status. It does NOT derive conditions or manage contract state. Callers pass the ServiceUnit CR with conditions already set; this writer merges and persists.

func NewStatusWriter

func NewStatusWriter(c client.Client, log logr.Logger) *StatusWriter

NewStatusWriter constructs a StatusWriter.

func (*StatusWriter) Write

Write merges the provided conditions into the ServiceUnit CR status and persists. Uses RetryOnConflict + re-fetch on each attempt — concurrent writers may bump resourceVersion between the reconciler's initial fetch and this write. Re-fetching guarantees we always write to the latest version.

Jump to

Keyboard shortcuts

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