Documentation
¶
Overview ¶
Package gateway builds a Bastion gateway that proxies on its own.
bastion.New returns the core gateway. The proxy engine, route manager, circuit breakers, retry policy, stats and admin API live in subpackages that import the core, so the core can't build them itself, and on its own it registers no catch-all route and forwards nothing ("proxy handler not set"). New here wires every one of them, and picks up Forge's discovery extension when it is registered:
app.RegisterExtension(gateway.New(
bastion.WithRoute(bastion.RouteConfig{
Path: "/docs/*",
Targets: []bastion.TargetConfig{{URL: "http://docs:8080"}},
}),
))
It imports no store package, so you don't pull in the Mongo, Postgres or SQLite drivers. Routes created through the admin API then live in memory only. If you want them persisted in a grove database, use the extension package, which is this plus the store wiring.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDiscoveryAdapter ¶
func NewDiscoveryAdapter(svc *discovery.Service) bastion.DiscoveryService
NewDiscoveryAdapter creates a bastion.DiscoveryService from a discovery.Service.
func Wire ¶
Wire builds the route manager, circuit breakers, retry executor, traffic splitter, stats collector, load balancer and proxy engine for gw, and sets up its admin API. Call it after gw.Register and before gw.Start. It returns the admin service the routes were built on.
New and the extension package both call it; you only need it yourself if you embed *bastion.Gateway in your own extension.
func WireDiscovery ¶
WireDiscovery hands gw the discovery service from the app's container, if the discovery extension registered one. Call it before gw.Start. Without it, a gateway with discovery enabled logs a warning at start and serves only its configured and admin-created routes.
Types ¶
type Extension ¶
Extension is a Bastion gateway with its runtime subsystems wired. It embeds *bastion.Gateway, so everything the core gateway exposes is available on it.
func New ¶
func New(opts ...bastion.ConfigOption) *Extension
New creates a gateway that proxies once registered with a Forge app.
func (*Extension) Admin ¶
Admin returns the admin service, or nil before Register or when the gateway is disabled.