Repository navigation
refactor(rpc): services take the api options object - #919
Merged
Merged
Conversation
Every routed service method now has the shape of the method api declares, func(context.Context, api.XOptions) (Result, error), and every route hands it over as s.Method: internal/routes holds no adapter closure any more, so a service and its wire shape can no longer drift apart behind one. - A method that cannot fail keeps its body as an unexported method its own package calls; the exported one is the RPC shape around it. Callers in other packages handle the error like any other call; where there is nowhere to return it (relay's ticket sweep and merge audience, the tray title, the window-failed dialog, the rage report) it is logged and the safe answer taken. - Interfaces over these services (terminal.Store, relay.Terminal, spawn.Sessions, themes.Settings, ...) and their fakes moved with them. - terminal.spawnSession takes the StartOptions instead of ten positional arguments; godocs name opts fields instead of parameters that are gone. - The profiles route test registers typed nil services: a route reads its method value when it is registered, which a nil interface does not have. The test assumed something the contract never promised. The wire did not move: api/ and contract.golden are untouched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #917. Every service method a route exposes now has the shape of the method
apideclares,func(context.Context, api.XOptions) (Result, error), and every route isrpc.Handle(d, api.X, s.Method).internal/routesholds no adapter closure: a service and its wire shape can no longer drift apart behind one.Live,Exists,Verify,Status) keep their body as an unexported method their own package calls; the exported method is the RPC shape around it.terminal.Store,relay.Terminal,spawn.Sessions,themes.Settings, ...) and their fakes moved with them.terminal.spawnSessiontakes theStartOptionsinstead of ten positional arguments; godocs nameoptsfields instead of parameters that are gone.CLAUDE.md's RPC rule says the routed method has this shape.The wire did not move:
api/andapi/testdata/contract.goldenare untouched, andnative/is unchanged.Test changed
TestHandleProfilesCoverEveryProfileMethodregisters typed nil services instead of a nil interface: a route now reads its method value when it is registered, which a nil interface does not have. The test assumed something the contract never promised. Every other test change follows the new signatures, no assertion loosened.Test plan
gofmt,go vet ./...,go test ./...(3927 passed, coverage 91.1%)-tags installer_e2elist_sessions