A bit more context on how we organise our #golang services at Pace.
Oto has a very simple definition format:
type Service interface {
Method(Request) Response
}
Which turns into:
func (s *Service) Method(context.Context, Request) (*Response, error) {
// todo: implementation
}
The pointer return is simply because I like returning nil in the error case:
return nil, errors.New("not today mate")
Of course we add the context too (which originally comes from the http.Request, but we add a timeout in middleware too).
We generate the actual Go interface from the Oto definition using a template... you can kind-of see the #golang interface being defined here: github.com/pacedotdev/oto…
Oto's parser package reads Go code and turns it into a data structure that we can use to generate code with templates.
github.com/pacedotdev/oto…
We generate the Go server plumbing, a Go client (which we use in our integration tests), a TypeScript client (which we use in the Pace.dev app), and we turn it into a JSON blob for the front-end #SvelteJS app to use when rendering the docs. pace.dev/docs/api/Comme…
Share this Scrolly Tale with your friends.
A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.
