gateway

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 14 Imported by: 0

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

func Wire(gw *bastion.Gateway) (*admin.Service, error)

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

func WireDiscovery(gw *bastion.Gateway)

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

type Extension struct {
	*bastion.Gateway
	// contains filtered or unexported fields
}

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

func (e *Extension) Admin() *admin.Service

Admin returns the admin service, or nil before Register or when the gateway is disabled.

func (*Extension) Register

func (e *Extension) Register(app forge.App) error

Register registers the core gateway, then wires the proxy engine and the subsystems around it.

func (*Extension) Start

func (e *Extension) Start(ctx context.Context) error

Start wires discovery from the container, then starts the gateway.

Jump to

Keyboard shortcuts

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