Documentation
¶
Overview ¶
Package commerceinproc is the ONE seam that lets every cloud subsystem that speaks the commerce billing S2S surface (clients/{billing,account,admin, referrals,authors,affiliates,usage} + the request-edge metering gate in build.go) reach the co-resident, in-process commerce handler with a DIRECT Go call instead of an HTTP hop to the standalone commerce pod (CLOUD_COMMERCE_HTTP_URL, commerce.hanzo.svc:8001). This is what lets the standalone be RETIRED (task #111): once commerce is folded in-process (#114), every /v1/billing read/write + the metering debit routes to the same in-tree gin engine that /v1/commerce already does.
HOW. commerce.Mount registers the embedded commerce http.Handler here via SetHandler once, at boot. A subsystem builds its S2S HTTP request EXACTLY as before (same path, same `Authorization: Bearer <COMMERCE_SERVICE_TOKEN>`, same server-pinned `X-Org-Id`) and sends it through Transport(): when the handler is co-resident the request is dispatched to it in-process (httptest recorder — no socket, no network, no serialization change); when it is NOT (commerce staged / split-deploy) the request falls back to plain HTTP to its URL — the pre-#111 behavior, unchanged. So the SAME request, headers, body, status and body bytes flow either way — the transport swap is behaviour-preserving, which is exactly what the money-parity gate proves.
DE-COMPLECTED: subsystems keep their own request-building + subject-pinning (the tenant-isolation security boundary stays where it is); this package owns ONLY "where does the byte stream go", nothing about auth or scope.
Index ¶
Constants ¶
const PlaceholderBase = "http://commerce.inproc"
PlaceholderBase is the sentinel commerce base URL used when commerce is co-resident and CLOUD_COMMERCE_HTTP_URL is unset (the post-retirement steady state). The self-routing Transport ignores the host and dispatches by PATH, so the value only has to be a parseable absolute URL; it is never dialed.
Variables ¶
This section is empty.
Functions ¶
func Available ¶
func Available() bool
Available reports whether commerce is co-resident (a handler is published). A subsystem uses this to keep its "configured" gate true even when CLOUD_COMMERCE_HTTP_URL is unset — the standalone is gone but commerce still answers, in-process.
func BaseURL ¶
BaseURL returns env when non-empty, else — when commerce is co-resident — the in-process PlaceholderBase, else "". This lets a subsystem drop its dependence on CLOUD_COMMERCE_HTTP_URL: once the standalone is retired and the env is removed, the base becomes the placeholder and requests still route in-process.
func Client ¶
Client returns an *http.Client wired to the self-routing Transport with the given timeout (0 → no timeout; the in-process path is synchronous anyway). Drop-in for the &http.Client{Timeout: …} every commerce proxy builds today.
func SetApp ¶ added in v1.801.23
SetApp publishes the co-resident zip app commerce's routes live on (the SharedApp contract). The S2S dispatch enters the app's fasthttp pipeline directly; the http.Handler shape survives only inside this seam for the bridge-building subsystems that still speak *http.Request. Passing nil un-publishes.
func SetHandler ¶
SetHandler publishes the in-process commerce handler. SetApp is the production path; this remains the seam tests stub. Passing nil un-publishes (used by tests).
func Transport ¶
func Transport() http.RoundTripper
Transport returns the self-routing RoundTripper (in-process when co-resident, plain HTTP otherwise). Give it to any subsystem's *http.Client.Transport.
Types ¶
This section is empty.