codegen

package
v0.1.0-rc.77 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const ClusterErrorDomain = "cluster.w17"

ClusterErrorDomain is the google.rpc.ErrorInfo domain the relay and the worker put on a refusal that a new placement can cure.

View Source
const DefaultRetries = 1

DefaultRetries is how many times a run that lost its connection mid-stream is placed and run again. One: a lost relay or worker is usually a deploy or a crash, and one fresh placement lands on a healthy one; a second loss in a row is a pattern worth reporting rather than hiding.

Variables

View Source
var ErrSdkFloor = errors.New("sdk/go pin predates this client")

ErrSdkFloor marks the one failure in resolveSdkGoPins that is a REFUSAL rather than a hiccup, so the caller can stop instead of warning.

It has to be distinguishable, and a consumer proved why: the caller treats every error from that function as non-fatal, because the original ones were proxy outages where the files were already written. So the floor check — shipped as "codegen REFUSES a stale pin", in a release and in two letters — came out as one warning among nine with exit 0, and the tree was left with the stale pin in place. A refusal that does not refuse is worse than no refusal: it is a promise the reader acts on.

Functions

func ConnectionDomain

func ConnectionDomain(name string) string

ConnectionDomain returns the segment before the first `-` in a `<domain>-<role>` connection name (e.g. "forge-postgres" → "forge"). Used for the PG init-dir mount path + the default user/db credentials in the dev compose.

func DialectFromConnectionName

func DialectFromConnectionName(name string) (string, bool)

DialectFromConnectionName picks the dialect from the connection-name `<domain>-<dialect>` suffix — the same convention the connection name follows everywhere (the dialect itself is declared in proto's (w17.module).connection, never stored in the lock). Excludes nats / s3, which don't appear in compose.w17.yaml as per-connection services (nats has its own block, s3 is versionless managed infrastructure).

func GenerateClientViaConsole

func GenerateClientViaConsole(root, console, protoDir, lockPath string) error

GenerateClientViaConsole renders the FE client tree(s) and writes them under each client's output_root. The console describes the lock and PLACES the run (PLACEMENT_OP_GENERATE_CLIENT); the generation itself runs on a codegen worker, like `codegen` — the console serves no generating RPC. The worker is sent the lock the console signed at placement: the FE generator verifies the lock it stages, and a worker holds no key to sign one.

func GuideViaConsole

func GuideViaConsole(root, console string) error

GuideViaConsole fetches the w17 PLATFORM self-description (w17/specs/*) from the console's Guide RPC and writes it under the project root. The content is generated SERVER-SIDE from the compiler's own vocabulary, so it always matches the running compiler — a thin client of any version gets a current description. Takes no project input.

func PinFingerprintOf

func PinFingerprintOf(path string) string

PinFingerprintOf exposes the go.mod stamp reader to the verify package, which runs the release gate. Same file read, same "" for a pre-stamp bundle; exported rather than duplicated so the two readers cannot drift on what the stamp looks like.

func ProtoLines

func ProtoLines(files []*codegenpb.ProtoFile) int64

ProtoLines is the size a placement is admitted against: the proto source lines the run will upload.

func ReadDepVersions

func ReadDepVersions(root, genDir string) (*codegenpb.DepVersions, error)

ReadDepVersions exposes the project's own go.mod pins. The release gate sends them so the console can compute the fingerprint a render WOULD produce: a bundle's pin set is a merge of these and the compiler's, and an expectation built from the compiler's alone would refuse every project that pins anything itself.

func Run

func Run(console string, force bool, adoptGitignore bool, gofmt string, retries int) error

Run is the package-level codegen entrypoint (invoked by the cmd/codegen kong command + stack build): it gathers the project's LOCAL inputs (proto tree, lock, go.module, go.mod dep-versions, the current gen Go tree, the co-dev env), has the console PLACE the run on the codegen cluster, and streams the inputs to the granted worker's GenerateProject, which owns ALL codegen orchestration server-side (surface detection, target derivation, composition, per-generator sequencing, file routing, the supersede-sweep). The client applies each streamed op under the project root with no derivation: write / write-if-missing / delete, plus the LOCAL-disk merges it still owns (generated-go.mod replace preservation) and go.work sync — and writes the lock the console signed when it placed the run.

retries is how many times a run that lost its connection mid-stream is placed and run again (DefaultRetries; see cluster.go for the whole failure classification).

func RunOnWorker

func RunOnWorker(placer core.Placer, start *codegenpb.PlaceGenerateStart, out io.Writer,
	run func(ctx context.Context, worker codegenpb.CodegenServiceClient, signedLock []byte) error) error

RunOnWorker runs one generating RPC other than GenerateProject on a codegen worker: GenerateClient (`target client generate`) and GeneratePluginPb (`plugin gen-pb`). The console serves neither — it only places them.

It places `start` (polling the queue), dials the granted worker exactly as `codegen` does (the relay's certificate pinned, the one-time ticket), and calls `run` with that worker and the lock the console signed at placement (nil for a plugin-pb run, which has no project). The retry rules are GenerateProject's (placeAndRun), with one re-run after a lost worker.

`run` streams and writes. An error it returns that is not a gRPC status — a file it could not write — is this machine's, reported as is and never retried.

Types

This section is empty.

Jump to

Keyboard shortcuts

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