checkout

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2026 License: MIT Imports: 3 Imported by: 0

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

View Source
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 Receipt

type Receipt struct {
	OrderID string `json:"orderId"`
	UserID  string `json:"userId"`
	Display string `json:"display"`
}

func NewSubmit

func NewSubmit(svc *Service, p nexus.Params[SubmitArgs]) (*Receipt, error)

NewSubmit fetches the user via the typed client (monolith: direct invoke; split: HTTP) and returns a receipt that includes the user's display name. The handler is unaware of which transport ran the users.Get call — this is the framework's contract.

type Service

type Service struct {
	*nexus.Service
	// contains filtered or unexported fields
}

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

type SubmitArgs

type SubmitArgs struct {
	UserID  string `json:"userId"`
	OrderID string `json:"orderId"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL