route

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	Host string
	Port int
}

type Gateway added in v0.1.4

type Gateway struct {
	// contains filtered or unexported fields
}

Gateway keeps route-to-backend mapping for the in-process gateway. It is database-backed so mappings survive process restarts.

func NewGateway added in v0.1.4

func NewGateway(db *gorm.DB) (*Gateway, error)

func (*Gateway) DeleteRoute added in v0.1.4

func (r *Gateway) DeleteRoute(ctx context.Context, routeKey string) error

func (*Gateway) DeleteRouteByContainerInstanceID added in v0.1.4

func (r *Gateway) DeleteRouteByContainerInstanceID(ctx context.Context, containerInstanceID int64) error

func (*Gateway) ResolveByPath added in v0.1.4

func (r *Gateway) ResolveByPath(path string) (Registration, string, bool)

func (*Gateway) UpsertRoute added in v0.1.4

func (r *Gateway) UpsertRoute(ctx context.Context, route Registration) error

type K8sIngressRegistry

type K8sIngressRegistry struct {
	// contains filtered or unexported fields
}

func NewK8sIngressRegistry

func NewK8sIngressRegistry(cfg K8sIngressRegistryConfig) (*K8sIngressRegistry, error)

func (*K8sIngressRegistry) DeleteRoute

func (r *K8sIngressRegistry) DeleteRoute(ctx context.Context, routeKey string) error

func (*K8sIngressRegistry) DeleteRouteByContainerInstanceID added in v0.1.4

func (r *K8sIngressRegistry) DeleteRouteByContainerInstanceID(ctx context.Context, containerInstanceID int64) error

func (*K8sIngressRegistry) UpsertRoute

func (r *K8sIngressRegistry) UpsertRoute(ctx context.Context, route Registration) error

type K8sIngressRegistryConfig

type K8sIngressRegistryConfig struct {
	Namespace        string
	Kubeconfig       string
	InCluster        bool
	IngressClassName string
	Host             string
	PathType         string
	Annotations      map[string]string
}

type PathRouteResolver

type PathRouteResolver interface {
	ResolveByPath(path string) (route Registration, matchedPrefix string, ok bool)
}

PathRouteResolver resolves an incoming request path to a registered route. matchedPrefix is the path prefix bound to the resolved backend.

type Registration

type Registration struct {
	RouteKey            string
	ContainerInstanceID int64
	IsTrimPrefix        bool
	PathPrefix          string
	Backend             Backend
	Metadata            map[string]string
}

Registration describes one app-session route bound to a concrete backend.

type Registry added in v0.1.4

type Registry struct {
	// contains filtered or unexported fields
}

Registry is the route registration factory. It holds named RouteRegistry implementations and resolves them by name at startup / runtime.

func NewRegistry added in v0.1.4

func NewRegistry() *Registry

NewRegistry creates an empty Registry.

func NewRegistryFromConfig added in v0.1.4

func NewRegistryFromConfig(cfg *config.Config) (*Registry, error)

NewRegistryFromConfig builds a Registry populated with the external route registries selected by cfg.Route.Registrys, in declaration order. The in-process gateway is managed separately and is not part of this registry.

func (*Registry) Get added in v0.1.4

func (r *Registry) Get(name string) RouteRegistry

Get returns the RouteRegistry registered under the given name, or nil.

func (*Registry) Has added in v0.1.4

func (r *Registry) Has(name string) bool

Has reports whether a RouteRegistry is registered under the given name.

func (*Registry) List added in v0.1.4

func (r *Registry) List() []RouteRegistry

List returns all registered RouteRegistry instances.

func (*Registry) Names added in v0.1.4

func (r *Registry) Names() []string

Names returns the normalized names of registered registries, sorted.

func (*Registry) Register added in v0.1.4

func (r *Registry) Register(name string, reg RouteRegistry)

Register registers a RouteRegistry under a normalized name; same-name registrations overwrite the previous one.

type RouteRegistry

type RouteRegistry interface {
	UpsertRoute(ctx context.Context, route Registration) error
	DeleteRoute(ctx context.Context, routeKey string) error
	DeleteRouteByContainerInstanceID(ctx context.Context, containerInstanceID int64) error
}

RouteRegistry is the abstraction for route management backends such as Traefik API/File, in-process gateway, or a composite implementation.

type RouteRegistryHandler

type RouteRegistryHandler struct {
	// contains filtered or unexported fields
}

func NewRouteRegistryHandler

func NewRouteRegistryHandler(repo interfaces.ContainerRepository, registry *Registry, gateway *Gateway, cfg *config.Config) *RouteRegistryHandler

func (*RouteRegistryHandler) Handle

func (h *RouteRegistryHandler) Handle(evt event.Event)

type TraefikRegistry

type TraefikRegistry struct {
	// contains filtered or unexported fields
}

func NewTraefikRegistry

func NewTraefikRegistry(cfg TraefikRegistryConfig) (*TraefikRegistry, error)

func (*TraefikRegistry) DeleteRoute

func (r *TraefikRegistry) DeleteRoute(ctx context.Context, routeKey string) error

func (*TraefikRegistry) DeleteRouteByContainerInstanceID added in v0.1.4

func (r *TraefikRegistry) DeleteRouteByContainerInstanceID(ctx context.Context, containerInstanceID int64) error

func (*TraefikRegistry) UpsertRoute

func (r *TraefikRegistry) UpsertRoute(ctx context.Context, route Registration) error

type TraefikRegistryConfig

type TraefikRegistryConfig struct {
	Provider   string
	BaseURL    string
	UpsertPath string
	DeletePath string
	AuthToken  string
	Timeout    time.Duration
	FilePath   string
}

Jump to

Keyboard shortcuts

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