mirror of
https://github.com/zap-proto/zip.git
synced 2026-10-19 15:38:57 +00:00
`Mount` meant two unrelated things across the fleet at once: zip/remote.go func Mount(prefix, addr string, decl ...Declaration) (*App, error) 112 subsystems func Mount(app cloud.Router, deps cloud.Deps) error The second is the fleet's registration contract, stated in hanzoai/cloud's package doc and checked by cloud.MountFunc. The first is a leftover: Mount was one of five composition verbs (Listen/Mount/Add/Graft/Use), the other four were dissolved into Use, and this one survived by being the only one that pointed at another process. A reader seeing `Mount` in a diff could not tell which was meant without counting arguments. Renamed to Proxy, which is what it BUILDS. Every route it registers runs the one handler this file calls `proxy`, whose whole body is forward() to the address given; "proxy" is the term of art for a local stand-in whose handlers hand the request to someone else, so it needs no gloss. It is also a noun, which a function returning a value should be — composition is Use's job now, and the doc has said so since the four verbs were dissolved. NOT Remote: [Remote] already exists here and is the CALLER's side, a client executing commands against a service elsewhere. This is the SERVER's side, a definition standing in for that service inside this program's routing table. Two sides of one wire are two things. Also renamed the tests that named it, and mount_test.go -> adapt_net_http_test.go with it: those pin AdaptNetHTTP, a THIRD sense of "mount", and TestMount_* named none of the three. Regression set empty: TestServePathAllocsAreChainDepthInvariant fails identically on the parent commit (an allocation bound, untouched here). Co-authored-by: Hanzo Dev <[email protected]>
18 lines
567 B
Go
18 lines
567 B
Go
package zip_test
|
|
|
|
import "github.com/zap-proto/zip"
|
|
|
|
// must unwraps a definition constructor's (*App, error) so it can be composed
|
|
// inline: app.Use(must(zip.Load(...))).
|
|
//
|
|
// zip.Load and zip.Proxy return an error because BUILDING a definition can fail
|
|
// — a binary that will not start, a scheme with no transport. Use cannot fail,
|
|
// because appending a reference to a program is not a fallible act. The error
|
|
// belongs at construction, and composition stays one verb.
|
|
func must(p *zip.App, err error) *zip.App {
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
return p
|
|
}
|