router

package
v2.0.0-pre1 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: Apache-2.0 Imports: 71 Imported by: 0

README

Ziti Router Components

This document describes the key components of the Ziti router architecture.

Core Components

NetworkControllers

Manages connections to Ziti controllers. Handles controller discovery, connection establishment, failover, and maintains heartbeats. Routes control plane messages between the router and controllers.

Maintains the registry of active links to other routers in the mesh. Tracks link states, manages link lifecycle, and provides link lookup capabilities for routing decisions.

Forwarder

The packet forwarding engine that routes data between xgress instances. Delivers payloads to links, xgress instances or edge forwarders.

Faulter

Monitors link health and detects failures. Automatically reports link faults to controllers and triggers link recovery processes when connectivity issues are detected.

Scanner

Continuously scans the forwarder's state to detect and clean up stale forwarding entries. Removes inactive circuits and performs periodic maintenance of the forwarding tables.

Data Plane Components

Xgress Components

Handle ingress and egress traffic for the router:

  • Xgress Listeners: Accept incoming connections from clients and services
  • Xgress Dialers: Establish outbound connections to services
  • Xgress Factories: Create protocol-specific xgress instances (edge, transport, proxy, tunnel)
  • Xgress Registry: Global registry managing all xgress factory types
Xgress Types
  • edge: Handles Ziti SDK connections
  • transport: Router-to-router communication
  • proxy: TCP/UDP proxy connections
  • tunnel: Intercepted traffic from tunneling clients

Metrics

Comprehensive metrics collection covering:

  • Link latency and throughput
  • Xgress connection statistics
  • Pool utilization (link dialer, egress dialer, rate limiter)

All metrics are reported to controllers and available via health check APIs.

Documentation

Index

Constants

View Source
const (
	AgentAppId      byte = 2
	DumpApiSessions byte = 128
)

Variables

View Source
var GlobalLifecycleNotifier = NewLifecycleNotifier()

GlobalLifecycleNotifier is the default lifecycle notifier instance used by the router. External components can register listeners with this global instance to receive router lifecycle events.

Example usage:

router.GlobalLifecycleNotifier.AddListener(myListener)

Functions

This section is empty.

Types

type LifecycleEvent

type LifecycleEvent int

LifecycleEvent represents different phases in the router's lifecycle. Events are fired during router startup and shutdown to allow external components to hook into the router's lifecycle.

const (
	// LifecycleEventConfigLoaded is fired when the router's Create() method is called,
	// before the router instance is created. This allows listeners to modify the
	// router configuration before the router is instantiated.
	LifecycleEventConfigLoaded LifecycleEvent = iota

	// LifecycleEventStart is fired when the router's Start() method is called,
	// before any initialization logic begins. This allows listeners to perform
	// setup operations or modify the router configuration before startup.
	LifecycleEventStart
)

type LifecycleListener

type LifecycleListener interface {
	// OnLifecycleEvent is called when a lifecycle event occurs.
	// The event parameter indicates which lifecycle phase is occurring.
	// The router parameter provides access to the router instance. This will be nil
	// for LifecycleEventConfigLoaded since the router has not been created yet.
	// The config parameter provides access to the router configuration.
	OnLifecycleEvent(event LifecycleEvent, router *Router, config *env.Config)
}

LifecycleListener defines the interface for components that want to receive notifications about router lifecycle events. Implementations should be thread-safe as they may be called concurrently.

type LifecycleNotifier

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

LifecycleNotifier manages a collection of lifecycle listeners and provides methods to notify them of router lifecycle events. It uses a thread-safe copy-on-write slice to store listeners, allowing concurrent access during event notification.

func NewLifecycleNotifier

func NewLifecycleNotifier() *LifecycleNotifier

NewLifecycleNotifier creates a new lifecycle notifier with an empty listener list.

func (*LifecycleNotifier) AddListener

func (ln *LifecycleNotifier) AddListener(listener LifecycleListener)

AddListener registers a new lifecycle listener. The listener will receive notifications for all future lifecycle events. This method is thread-safe and can be called concurrently with NotifyListeners.

func (*LifecycleNotifier) NotifyListeners

func (ln *LifecycleNotifier) NotifyListeners(event LifecycleEvent, router *Router, config *env.Config)

NotifyListeners sends a lifecycle event notification to all registered listeners. Listeners are called synchronously in the order they were registered. If a listener panics, the panic will propagate and prevent subsequent listeners from being notified.

type Router

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

func Create

func Create(cfg *env.Config, versionProvider versions.VersionProvider) *Router

func (*Router) DefaultRequestTimeout

func (self *Router) DefaultRequestTimeout() time.Duration

func (*Router) GetAlerter

func (self *Router) GetAlerter() env.Alerter

func (*Router) GetChannel

func (self *Router) GetChannel(controllerId string) channel.Channel

func (*Router) GetCloseNotify

func (self *Router) GetCloseNotify() <-chan struct{}

func (*Router) GetConfig

func (self *Router) GetConfig() *env.Config

func (*Router) GetConnectEventsConfig

func (self *Router) GetConnectEventsConfig() *env.ConnectEventsConfig

func (*Router) GetCtrlChannelBindHandler

func (self *Router) GetCtrlChannelBindHandler() channel.BindHandler

func (*Router) GetCtrlRateLimiter

func (self *Router) GetCtrlRateLimiter() rate.AdaptiveRateLimitTracker

func (*Router) GetDialHeaders

func (self *Router) GetDialHeaders() (channel.Headers, error)

func (*Router) GetDialerCfg

func (self *Router) GetDialerCfg() map[string]xgress.OptionsData

func (*Router) GetForwarder

func (self *Router) GetForwarder() env.Forwarder

func (*Router) GetHeartbeatOptions

func (self *Router) GetHeartbeatOptions() env.HeartbeatOptions

func (*Router) GetIndexWatchers

func (self *Router) GetIndexWatchers() env.IndexWatchers

func (*Router) GetLinkDialerPool

func (self *Router) GetLinkDialerPool() goroutines.Pool

func (*Router) GetMetricsRegistry

func (self *Router) GetMetricsRegistry() metrics.UsageRegistry

func (*Router) GetNetworkControllers

func (self *Router) GetNetworkControllers() env.NetworkControllers

func (*Router) GetRateLimiterPool

func (self *Router) GetRateLimiterPool() goroutines.Pool

func (*Router) GetRouterDataModel

func (self *Router) GetRouterDataModel() *common.RouterDataModel

func (*Router) GetRouterId

func (self *Router) GetRouterId() *identity.TokenId

func (*Router) GetStateManager

func (self *Router) GetStateManager() state.Manager

func (*Router) GetTraceHandler

func (self *Router) GetTraceHandler() *channel.TraceHandler

func (*Router) GetVersionInfo

func (self *Router) GetVersionInfo() versions.VersionProvider

func (*Router) GetXLinkRegistry

func (self *Router) GetXLinkRegistry() xlink.Registry

func (*Router) GetXgressBindHandler

func (self *Router) GetXgressBindHandler() xgress.BindHandler

func (*Router) GetXgressListeners

func (self *Router) GetXgressListeners() []xgress_router.Listener

func (*Router) GetXgressMetrics

func (self *Router) GetXgressMetrics() env.XgressMetrics

func (*Router) GetXgressRegistry

func (self *Router) GetXgressRegistry() *env.Registry

func (*Router) GetXlinkDialers

func (self *Router) GetXlinkDialers() []xlink.Dialer

func (*Router) GetXlinkRegistry

func (self *Router) GetXlinkRegistry() xlink.Registry

func (*Router) GetXrctrls

func (self *Router) GetXrctrls() []env.Xrctrl

func (*Router) HandleAgentAsyncOp

func (self *Router) HandleAgentAsyncOp(conn net.Conn) error

func (*Router) HandleAgentOp

func (self *Router) HandleAgentOp(conn net.Conn) error

func (*Router) IsRouterDataModelRequired

func (self *Router) IsRouterDataModelRequired() bool

func (*Router) ListenForShutdownSignal

func (self *Router) ListenForShutdownSignal(ctx context.Context)

func (*Router) MarkRouterDataModelRequired

func (self *Router) MarkRouterDataModelRequired()

func (*Router) NotifyCertsUpdated

func (self *Router) NotifyCertsUpdated()

func (*Router) NotifyOfReconnect

func (self *Router) NotifyOfReconnect(ch ctrlchan.CtrlChannel)

func (*Router) RegisterAgentBindHandler

func (self *Router) RegisterAgentBindHandler(bindHandler channel.BindHandler)

func (*Router) RegisterAgentOp

func (self *Router) RegisterAgentOp(opId byte, f func(c *bufio.ReadWriter) error)

func (*Router) RegisterDefaultAgentOps

func (self *Router) RegisterDefaultAgentOps(debugEnabled bool)

func (*Router) RegisterXWebHandlerFactory

func (self *Router) RegisterXWebHandlerFactory(x xweb.ApiHandlerFactory) error

func (*Router) RegisterXrctrl

func (self *Router) RegisterXrctrl(x env.Xrctrl) error

func (*Router) RegisterXweb

func (self *Router) RegisterXweb(x xweb.Instance) error

func (*Router) RenderJsonConfig

func (self *Router) RenderJsonConfig() (string, error)

func (*Router) Run

func (self *Router) Run() error

func (*Router) RunCliAgent

func (self *Router) RunCliAgent(agentAddr, appAlias string)

func (*Router) Shutdown

func (self *Router) Shutdown() error

func (*Router) Start

func (self *Router) Start() error

func (*Router) UpdateCtrlEndpoints

func (self *Router) UpdateCtrlEndpoints(endpoints []string)

func (*Router) UpdateLeader

func (self *Router) UpdateLeader(leaderId string)

func (*Router) WithRouterDataModel

func (self *Router) WithRouterDataModel(f func(*common.RouterDataModel) error) error

WithRouterDataModel passes the current router data model into the provide function

type RouterMonitor

type RouterMonitor interface {
	Monitor()
}

Directories

Path Synopsis
Package env provides the router environment registry for managing xgress protocol factories.
Package env provides the router environment registry for managing xgress protocol factories.
internal

Jump to

Keyboard shortcuts

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