Part of dagger/dagger#13805
Context
A generated client binds one module. The schema it sees is core plus that module, and it generates Go types for all of it.
Problem
Core is regenerated into every client, about 20,000 lines each. Generating two clients produced two copies that differed by one line.
Size is the smaller half. Each copy declares its own types, so clidev.File and enginedev.File are different Go types describing the same object. Nothing passes between two generated clients, and nothing passes between a generated client and hand-written dagger.io/dagger code. Crossing means a round trip through the object's ID:
id, _ := cli.Binary().ID(ctx)
file := enginedev.Ref[*enginedev.File](engine, enginedev.ID(id))
With one package per module, that cost is paid by every program that binds more than one.
Solution
Do not generate core. Refer to dagger.io/dagger, which the client already depends on:
func (r *EngineDev) Container(...) *dagger.Container
A generated client shrinks to its own module's surface. Core exists once, in the package named for it, and every client interoperates with every other client and with hand-written code.
Part of dagger/dagger#13805
Context
A generated client binds one module. The schema it sees is core plus that module, and it generates Go types for all of it.
Problem
Core is regenerated into every client, about 20,000 lines each. Generating two clients produced two copies that differed by one line.
Size is the smaller half. Each copy declares its own types, so
clidev.Fileandenginedev.Fileare different Go types describing the same object. Nothing passes between two generated clients, and nothing passes between a generated client and hand-writtendagger.io/daggercode. Crossing means a round trip through the object's ID:With one package per module, that cost is paid by every program that binds more than one.
Solution
Do not generate core. Refer to
dagger.io/dagger, which the client already depends on:A generated client shrinks to its own module's surface. Core exists once, in the package named for it, and every client interoperates with every other client and with hand-written code.