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:
- Map the resolved ServiceUnit contract to a domain ServiceUnit (Mapper).
- Derive the outcome directly from the mapped fields (deriveResult).
- Write the outcome back to the ServiceUnit CR status (StatusWriter).
- 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 (Mapper) MapResolvedToDomain ¶
func (Mapper) MapResolvedToDomain(rsu *serviceunitResolution.ResolvedServiceUnit) domain.ServiceUnit
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 ¶
func (s *ServiceUnitService) Reconcile(ctx context.Context, resolved *serviceunitResolution.ResolvedServiceUnit) error
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 ¶
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 ¶
func (w *StatusWriter) Write(ctx context.Context, su *environmentv1alpha1.ServiceUnit, conditions ...metav1.Condition) error
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.