endpoints

package
v0.0.0-...-ca72162 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package endpoints provides configuration types and utilities for routing in the firelynx server.

This package defines the domain model for endpoint configurations, which map requests from listeners to applications through routes. It handles validation, protocol buffer conversion, and provides helper methods for accessing routes.

The main types include: - Endpoint: Maps from listener IDs to routes, enabling request routing to apps - EndpointCollection: A slice of Endpoint objects with validation and conversion methods - Routes are defined in the routes sub-package

Thread Safety: The endpoint configuration objects are not thread-safe and should be protected when accessed concurrently. These objects are typically loaded during startup or configuration reload operations, which should be synchronized.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Validation specific errors
	ErrEmptyID              = errz.ErrEmptyID
	ErrMissingRequiredField = errz.ErrMissingRequiredField
	ErrRouteConflict        = errz.ErrRouteConflict
	ErrInvalidRouteType     = errz.ErrInvalidRouteType
)

Re-export errors for this package

Functions

This section is empty.

Types

type Endpoint

type Endpoint struct {
	ID          string
	ListenerID  string // Single listener ID instead of an array
	Routes      routes.RouteCollection
	Middlewares middleware.MiddlewareCollection
}

Endpoint represents a routing configuration for incoming requests

func (*Endpoint) GetStructuredHTTPRoutes

func (e *Endpoint) GetStructuredHTTPRoutes() []routes.HTTPRoute

GetStructuredHTTPRoutes returns all HTTP routes for this endpoint in a structured format. It extracts routes with HTTP conditions and returns them as the more type-safe HTTPRoute structure with path, app ID, static data, and merged middleware explicitly defined.

func (*Endpoint) String

func (e *Endpoint) String() string

String returns a string representation of an Endpoint

func (*Endpoint) ToProto

func (e *Endpoint) ToProto() *pb.Endpoint

ToProto converts an Endpoint to a protobuf Endpoint

func (*Endpoint) ToTree

func (e *Endpoint) ToTree() *fancy.ComponentTree

ToTree returns a tree visualization of this Endpoint

func (*Endpoint) Validate

func (e *Endpoint) Validate() error

Validate performs validation for an Endpoint

type EndpointCollection

type EndpointCollection []Endpoint

EndpointCollection is a collection of Endpoint objects

func FromProto

func FromProto(pbEndpoints []*pb.Endpoint) (EndpointCollection, error)

FromProto converts protobuf Endpoint messages to a domain Endpoints collection. If no endpoints are provided, it returns nil. Returns an error if any endpoint validation fails (like missing ID or empty listener ID).

func NewEndpointCollection

func NewEndpointCollection(endpoints ...Endpoint) EndpointCollection

NewEndpointCollection creates a new EndpointCollection with the given endpoints.

func (EndpointCollection) All

func (ec EndpointCollection) All() iter.Seq[Endpoint]

All returns an iterator over all endpoints in the collection.

func (EndpointCollection) FindByID

func (ec EndpointCollection) FindByID(id string) (Endpoint, bool)

FindByID finds an endpoint by ID, returning (Endpoint, bool)

func (EndpointCollection) FindByListenerID

func (ec EndpointCollection) FindByListenerID(listenerID string) iter.Seq[Endpoint]

FindByListenerID returns an iterator over endpoints attached to a specific listener ID.

func (EndpointCollection) GetIDsForListener

func (ec EndpointCollection) GetIDsForListener(listenerID string) iter.Seq[string]

GetIDsForListener returns an iterator over endpoint IDs attached to a listener ID

func (EndpointCollection) GetListenerIDMapping

func (ec EndpointCollection) GetListenerIDMapping() map[string]string

GetListenerIDMapping creates a mapping from endpoint IDs to their listener IDs.

func (EndpointCollection) String

func (endpoints EndpointCollection) String() string

String returns a string representation of the Endpoints collection

func (EndpointCollection) ToProto

func (endpoints EndpointCollection) ToProto() []*pb.Endpoint

ToProto converts an Endpoints collection to a slice of protobuf Endpoints

Directories

Path Synopsis
Package middleware provides types and functionality for middleware configuration in the firelynx server.
Package middleware provides types and functionality for middleware configuration in the firelynx server.
Package routes provides configuration types and utilities for request routing in the firelynx server.
Package routes provides configuration types and utilities for request routing in the firelynx server.

Jump to

Keyboard shortcuts

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