markergen

package
v0.1.0-develop.2026060... Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package markergen scans cell.go marker comments (// +cell:listener, // +slice:route) and projects them into a per-cell WireBundle that drives cellgen wire generation.

Event subscriptions are no longer sourced from cell.go markers — they are read from slice.yaml contractUsages[role=subscribe] by cellgen directly (subscribe single-source flip, K05 W3). The slice:subscribe marker kind is removed from knownMarkers; any existing cell.go that still contains // +slice:subscribe: will produce an "unknown marker" error from Merge, prompting migration to slice.yaml.

CellMeta does NOT carry Listeners — wire is single-sourced in markers, projected into WireBundle, and consumed by cellgen + governance. This makes "wire single source = marker" hold at the type layer (K#05).

ref: kubernetes-sigs/controller-tools pkg/markers/parse.go

(splitMarker formal grammar adopted; Registry/Definition abstraction NOT
adopted — GoCell has a closed set of 2 marker kinds, switch dispatch
is sufficient and ~350 lines lighter than the controller-tools model)

ref: kubernetes-sigs/controller-tools pkg/markers/collect.go

(MaybeErrList non-fail-fast aggregation adopted)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectFromCellFile

func CollectFromCellFile(path string) ([]collectedMarker, error)

CollectFromCellFile parses the Go source at path and returns all GoCell marker comments found on type declarations and struct fields.

Only markers with known GoCell prefixes ("cell:" / "slice:") are returned; other "// +" markers (e.g. controller-gen, protoc) are silently skipped. Marker comments on func declarations are silently skipped; place markers on the struct field or type declaration only.

ref: kubernetes-sigs/controller-tools pkg/markers/collect.go@main

func Merge

func Merge(projectRoot string, project *metadata.ProjectMeta) (map[string]WireBundle, error)

Merge scans cell.go marker comments under projectRoot, extracts listener / route declarations, and projects them into a per-cell WireBundle map keyed by cell ID.

Cells whose cell.go is absent or declares no markers yield an empty WireBundle — the yaml fallback path has been removed (W2 cleanup). All five platform cells now declare markers; NO-WIRE-FIELDS-IN-YAML-01 archtest enforces yaml-side absence statically.

Types

type ListenerSpec

type ListenerSpec struct {
	Ref    string
	Prefix string
}

ListenerSpec mirrors a `// +cell:listener:ref=...,prefix=...` marker declared on the cell struct.

type RouteSpec

type RouteSpec struct {
	Slice        string
	Listener     string
	SubPath      string
	Method       string
	HandlerField string
}

RouteSpec mirrors a `// +slice:route:slice=...,listener=...,subPath=...,method=...` marker declared on a handler field. Listener defaults to "cell.PrimaryListener" when omitted (covers the 90% single-listener case); Method defaults to "RegisterRoutes". HandlerField is auto-derived from the AST field name on which the marker is declared — cellgen renders `c.<HandlerField>.<Method>(s)`. Multiple route markers on the same field are allowed (e.g. one for primary + one for internal listener).

type WireBundle

type WireBundle struct {
	Listeners []ListenerSpec
	Routes    []RouteSpec
}

WireBundle aggregates per-cell wire facts derived from cell.go marker comments. Subscribe entries are no longer carried here — subscriptions are derived from slice.yaml contractUsages[role=subscribe] by cellgen (K05 single-source flip).

Jump to

Keyboard shortcuts

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