Documentation
¶
Overview ¶
Package resource coordinates long-lived system components and shared state. It manages the lifecycle of caches, metrics, health registries, and environment variables.
Package resource defines context structures for routing and traffic handling. It facilitates dependency injection for HTTP route and proxy handlers.
Index ¶
- type Env
- type Option
- func WithAuthCache(cache *mappo.Cache) Option
- func WithCacheSizes(routeMax, tcpMax, authMax, gzMax int) Option
- func WithCustomHTTPClient(client *http.Client) Option
- func WithCustomTransport(transport *http.Transport) Option
- func WithDoctor(doctor *jack.Doctor) Option
- func WithGzCache(cache *mappo.Cache) Option
- func WithHealth(registry *health.Registry) Option
- func WithKeeper(k *keeper.Keeper) Option
- func WithLifetime(l *jack.Lifetime) Option
- func WithLifetimeManager(lm *jack.Lifetime) Option
- func WithLogger(logger *ll.Logger) Option
- func WithMetrics(registry *metrics.Registry) Option
- func WithReaper(reapHandler func(context.Context, string)) Option
- func WithRouteCache(cache *mappo.Cache) Option
- func WithShutdown(shutdown *jack.Shutdown) Option
- func WithTCPCache(cache *mappo.Cache) Option
- type Patience
- type Proxy
- type Resource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Env ¶
type Env struct {
Global *mappo.Concurrent[string, expect.Value]
Route *mappo.Concurrent[string, expect.Value]
// contains filtered or unexported fields
}
type Option ¶
type Option func(*Resource)
func WithAuthCache ¶
WithAuthCache sets the cache used for storing successful authentication results. It reduces the load on external auth providers by caching tokens and session state.
func WithCacheSizes ¶
WithCacheSizes reinitializes internal caches with the specified maximum capacities. It clears existing data to ensure the new size constraints are applied immediately.
func WithCustomHTTPClient ¶
WithCustomHTTPClient assigns a pre-configured HTTP client to the resource manager. This client is used for all outgoing requests including auth and serverless REST.
func WithCustomTransport ¶
WithCustomTransport sets a specialized HTTP transport for backend proxying. It is primarily used to tune connection pooling and timeout behavior.
func WithDoctor ¶
WithDoctor attaches a health monitor to track the status of backend patients. It ensures that background health checks are executed according to their interval.
func WithGzCache ¶
WithGzCache sets the cache instance for pre-compressed static content. It allows the server to serve gzipped payloads without re-compressing them.
func WithHealth ¶
WithHealth replaces the current backend health registry. It allows for fresh health score tracking during configuration updates.
func WithKeeper ¶
WithKeeper sets the Keeper instance for the Resource, allowing it to manage and coordinate subsystem operations.
func WithLifetime ¶
WithLifetime sets the Lifetime field of a Resource to the provided Lifetime instance.
func WithLifetimeManager ¶
WithLifetimeManager configures the TTL manager for dynamic cluster resources. It tracks the expiration of temporary routes and security tokens.
func WithLogger ¶
WithLogger sets the system-wide logger for the resource manager. It allows for namespaced logging across all managed proxy components.
func WithMetrics ¶
WithMetrics replaces the current metrics registry with a new instance. This is used during reloads to reset or reconfigure telemetry collection.
func WithReaper ¶
WithReaper initializes the cache reaper with a custom cleanup handler. It automatically removes expired entries from the route and auth caches.
func WithRouteCache ¶
WithRouteCache sets a specific cache instance for HTTP route lookup results. It ensures that high-frequency route matching remains performant under load.
func WithShutdown ¶
WithShutdown configures the global shutdown manager for the resource. It ensures that all registered cleanup functions are executed on exit.
func WithTCPCache ¶
WithTCPCache sets a specific cache instance for TCP stream mapping results. This provides rapid lookup for SNI and port-based connection routing.
type Proxy ¶
type Proxy struct {
Resource *Resource
Global *alaye.Global
Host *alaye.Host
CookMgr *cook.Manager
IPMgr *zulu.IPManager
Orch *orchestrator.Manager
}
type Resource ¶
type Resource struct {
Metrics *metrics.Registry
Health *health.Registry
RouteCache *mappo.Cache
TCPCache *mappo.Cache
AuthCache *mappo.Cache
GzCache *mappo.Cache
TimeStore *mappo.Concurrent[string, time.Time]
Transport *http.Transport
HTTPClient *http.Client
Logger *ll.Logger
Doctor *jack.Doctor
Reaper *jack.Reaper
Shutdown *jack.Shutdown
Lifetime *jack.Lifetime
Keeper *keeper.Keeper
Janitor *jack.Pool
Background *jack.Pool
Env *Env
// contains filtered or unexported fields
}
func New ¶
New constructs a Resource manager and initializes all core sub-systems. It sets up thread-safe registries and default networking transports.
func (*Resource) Apply ¶
Apply executes a list of configuration options on the Resource instance. This is used for both initial setup and dynamic runtime re-configuration.
func (*Resource) Close ¶
func (m *Resource) Close()
Close gracefully terminates all background processes and clears internal registries. It ensures that idle connections are closed and cache entries are properly disposed of.
func (*Resource) Counter ¶
Counter returns the current global sequence value from the resource manager. This value is used for generating unique IDs across various server sub-systems.
func (*Resource) NextID ¶
NextID increments and returns the global counter to provide a unique identifier. It is used for tracking requests, tasks, and backend patient registration.
func (*Resource) UpdateGlobal ¶
UpdateGlobal creates a new concurrent map, populates it, and safely swaps the pointer so readers never see partial state.