Documentation
¶
Overview ¶
Package checkout demonstrates a module that *consumes* another module via its generated typed client. The same Go call — `users.Get(ctx, users.GetArgs{ID: ...})` — works in monolith mode (in-process LocalInvoker) and in split mode (HTTP RemoteCaller), with no edits to checkout's handler code when you decide to peel users out into its own binary.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Module = nexus.Module("checkout", nexus.DeployAs("checkout-svc"), nexus.Provide(NewService), nexus.Provide(users.NewUsersClient), nexus.AsRest("POST", "/checkout", NewSubmit), )
Module declares one POST endpoint. DeployAs makes checkout its own deployment unit so `nexus dev --split` boots it as a separate subprocess from users, exercising the real HTTP path between them via the codegen'd users.UsersClient.
Functions ¶
This section is empty.
Types ¶
type CheckoutClient ¶ added in v0.12.0
type CheckoutClient interface {
Submit(ctx context.Context, args SubmitArgs) (*Receipt, error)
}
CheckoutClient is the typed client surface for the "checkout" module. One method per AsRest handler in that module's declaration. The implementation is selected at construction time based on the running binary's deployment.
func NewCheckoutClient ¶ added in v0.12.0
func NewCheckoutClient(app *nexus.App) CheckoutClient
NewCheckoutClient returns the appropriate implementation for the running binary:
- In-process LocalInvoker when this binary owns the "checkout-svc" deployment, OR when no deployment is set (monolith mode).
- HTTP RemoteCaller reading CHECKOUT_SVC_URL otherwise. The local binary's version is threaded in so RemoteCaller can detect peer-version skew on the first call (single warning line, no fail-fast).
type Receipt ¶
type Receipt struct {
OrderID string `json:"orderId"`
UserID string `json:"userId"`
Display string `json:"display"`
}
type Service ¶
Service is checkout's service wrapper. Its constructor takes a users.UsersClient — the framework injects either the local or remote variant depending on the running binary's deployment, but the type the consumer sees is identical.
func NewService ¶
func NewService(app *nexus.App, u users.UsersClient) *Service