Documentation
¶
Index ¶
- type CircuitBreakerPolicy
- type CircuitBreakerState
- type Discovery
- func (d *Discovery) AddRoutingRule(rule RoutingRule) error
- func (d *Discovery) CheckCircuitBreaker(serviceName string, endpointIP string) (bool, error)
- func (d *Discovery) Close() error
- func (d *Discovery) ConfigureHealthCheck(serviceName string, config HealthCheckConfig) error
- func (d *Discovery) ConfigureLoadBalancing(serviceName string, strategy LoadBalancingStrategy) error
- func (d *Discovery) ConfigureServiceMesh(serviceName string, config ServiceMeshConfig) error
- func (d *Discovery) ConfigureTrafficSplit(config TrafficSplitConfig) error
- func (d *Discovery) DeregisterService(serviceName string, nodeID string, ipAddress string, port uint16) error
- func (d *Discovery) GetHealthCheckStatistics() map[string]float64
- func (d *Discovery) GetProxyMetrics() map[string]float64
- func (d *Discovery) GetServiceByDomain(domain string) (string, []ServiceEndpoint)
- func (d *Discovery) GetServiceEndpointWithOptions(serviceName string, clientIP string, sessionID string, preferredVersion string) *ServiceEndpoint
- func (d *Discovery) GetServiceEndpoints(serviceName string) []ServiceEndpoint
- func (d *Discovery) GetServiceURL(ctx context.Context, serviceName string) (string, error)
- func (d *Discovery) GetServiceURLSimple(serviceName string) string
- func (d *Discovery) GetTrafficSplit(serviceName string) *TrafficSplitConfig
- func (d *Discovery) HandleContainerCreated(containerID string, serviceName string, domain string, nodeID string, ...) error
- func (d *Discovery) HandleContainerRemoved(containerID string, serviceName string, nodeID string, ipAddress string, ...) error
- func (d *Discovery) HandleNodeJoined(nodeID string, nodeIP string) error
- func (d *Discovery) HandleNodeLeft(nodeID string) error
- func (d *Discovery) Initialize() error
- func (d *Discovery) ListRoutingRules() []RoutingRule
- func (d *Discovery) ListServices() map[string][]ServiceEndpoint
- func (d *Discovery) MarkEndpointUnhealthy(serviceName string, ipAddress string, port uint16) error
- func (d *Discovery) RecordCircuitBreakerResult(serviceName string, endpointIP string, success bool) error
- func (d *Discovery) RecordConnectionCompletion(serviceName string, ipAddress string, port uint16, durationMS float64, ...) error
- func (d *Discovery) RegisterService(serviceConfig *api.ServiceConfig, nodeID string, ipAddress string, port uint16) error
- func (d *Discovery) RegisterServiceWithVersion(serviceConfig *api.ServiceConfig, nodeID string, ipAddress string, port uint16, ...) error
- func (d *Discovery) RemoveRoutingRule(serviceName string, pathPrefix string) error
- func (d *Discovery) RemoveTrafficSplit(serviceName string) error
- func (d *Discovery) WithNetworkManager(networkManager interface{}) *Discovery
- func (d *Discovery) WithNodeManager(nodeManager interface{}) *Discovery
- type EndpointStats
- type HealthCheckConfig
- type HealthCheckProtocol
- type LoadBalancingStrategy
- type RetryPolicy
- type RoutingRule
- type ServiceEndpoint
- type ServiceHealth
- type ServiceInfo
- type ServiceMeshConfig
- type TrafficSplit
- type TrafficSplitConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CircuitBreakerPolicy ¶
type CircuitBreakerPolicy struct {
MaxConnections uint32
MaxPendingRequests uint32
MaxRequests uint32
MaxRetries uint32
ConsecutiveErrorsThreshold uint32
IntervalMS uint64
BaseEjectionTimeMS uint64
State CircuitBreakerState
LastStateChange int64
FailureCount uint32
SuccessCount uint32
HalfOpenAllowedCalls uint32
}
CircuitBreakerPolicy represents a circuit breaker policy
type CircuitBreakerState ¶
type CircuitBreakerState string
CircuitBreakerState represents the state of a circuit breaker
const ( // CircuitBreakerClosed indicates the circuit breaker is closed (normal operation) CircuitBreakerClosed CircuitBreakerState = "closed" // CircuitBreakerOpen indicates the circuit breaker is open (requests are rejected) CircuitBreakerOpen CircuitBreakerState = "open" // CircuitBreakerHalfOpen indicates the circuit breaker is half-open (testing if service is healthy) CircuitBreakerHalfOpen CircuitBreakerState = "half_open" )
type Discovery ¶
type Discovery struct {
// contains filtered or unexported fields
}
Discovery handles service discovery and health checking
func NewDiscovery ¶
NewDiscovery creates a new service discovery manager
func (*Discovery) AddRoutingRule ¶
func (d *Discovery) AddRoutingRule(rule RoutingRule) error
AddRoutingRule adds a routing rule
func (*Discovery) CheckCircuitBreaker ¶
CheckCircuitBreaker checks if a circuit breaker is open
func (*Discovery) ConfigureHealthCheck ¶
func (d *Discovery) ConfigureHealthCheck(serviceName string, config HealthCheckConfig) error
ConfigureHealthCheck configures health checks for a service
func (*Discovery) ConfigureLoadBalancing ¶
func (d *Discovery) ConfigureLoadBalancing(serviceName string, strategy LoadBalancingStrategy) error
ConfigureLoadBalancing configures load balancing for a service
func (*Discovery) ConfigureServiceMesh ¶
func (d *Discovery) ConfigureServiceMesh(serviceName string, config ServiceMeshConfig) error
ConfigureServiceMesh configures service mesh for a service
func (*Discovery) ConfigureTrafficSplit ¶
func (d *Discovery) ConfigureTrafficSplit(config TrafficSplitConfig) error
ConfigureTrafficSplit configures traffic splitting for a service
func (*Discovery) DeregisterService ¶
func (d *Discovery) DeregisterService( serviceName string, nodeID string, ipAddress string, port uint16, ) error
DeregisterService deregisters a service endpoint
func (*Discovery) GetHealthCheckStatistics ¶
GetHealthCheckStatistics returns statistics for health checks
func (*Discovery) GetProxyMetrics ¶
GetProxyMetrics returns metrics for the proxy
func (*Discovery) GetServiceByDomain ¶
func (d *Discovery) GetServiceByDomain(domain string) (string, []ServiceEndpoint)
GetServiceByDomain returns a service by domain
func (*Discovery) GetServiceEndpointWithOptions ¶
func (d *Discovery) GetServiceEndpointWithOptions( serviceName string, clientIP string, sessionID string, preferredVersion string, ) *ServiceEndpoint
GetServiceEndpointWithOptions returns a service endpoint with options
func (*Discovery) GetServiceEndpoints ¶
func (d *Discovery) GetServiceEndpoints(serviceName string) []ServiceEndpoint
GetServiceEndpoints returns the endpoints for a service
func (*Discovery) GetServiceURL ¶
GetServiceURL returns the URL for a service
func (*Discovery) GetServiceURLSimple ¶
GetServiceURLSimple is the original GetServiceURL method without context and error
func (*Discovery) GetTrafficSplit ¶
func (d *Discovery) GetTrafficSplit(serviceName string) *TrafficSplitConfig
GetTrafficSplit returns the traffic split configuration for a service
func (*Discovery) HandleContainerCreated ¶
func (d *Discovery) HandleContainerCreated( containerID string, serviceName string, domain string, nodeID string, ipAddress string, port uint16, ) error
HandleContainerCreated handles a new container being created
func (*Discovery) HandleContainerRemoved ¶
func (d *Discovery) HandleContainerRemoved( containerID string, serviceName string, nodeID string, ipAddress string, port uint16, ) error
HandleContainerRemoved handles a container being removed
func (*Discovery) HandleNodeJoined ¶
HandleNodeJoined handles a node joining the cluster
func (*Discovery) HandleNodeLeft ¶
HandleNodeLeft handles a node leaving the cluster
func (*Discovery) Initialize ¶
Initialize initializes the service discovery system
func (*Discovery) ListRoutingRules ¶
func (d *Discovery) ListRoutingRules() []RoutingRule
ListRoutingRules returns all routing rules
func (*Discovery) ListServices ¶
func (d *Discovery) ListServices() map[string][]ServiceEndpoint
ListServices returns a list of all services
func (*Discovery) MarkEndpointUnhealthy ¶
MarkEndpointUnhealthy marks an endpoint as unhealthy
func (*Discovery) RecordCircuitBreakerResult ¶
func (d *Discovery) RecordCircuitBreakerResult(serviceName string, endpointIP string, success bool) error
RecordCircuitBreakerResult records the result of a request for circuit breaking
func (*Discovery) RecordConnectionCompletion ¶
func (d *Discovery) RecordConnectionCompletion( serviceName string, ipAddress string, port uint16, durationMS float64, success bool, ) error
RecordConnectionCompletion records the completion of a connection
func (*Discovery) RegisterService ¶
func (d *Discovery) RegisterService( serviceConfig *api.ServiceConfig, nodeID string, ipAddress string, port uint16, ) error
RegisterService registers a service endpoint
func (*Discovery) RegisterServiceWithVersion ¶
func (d *Discovery) RegisterServiceWithVersion( serviceConfig *api.ServiceConfig, nodeID string, ipAddress string, port uint16, version string, weight uint32, ) error
RegisterServiceWithVersion registers a service with a specific version
func (*Discovery) RemoveRoutingRule ¶
RemoveRoutingRule removes a routing rule
func (*Discovery) RemoveTrafficSplit ¶
RemoveTrafficSplit removes traffic splitting for a service
func (*Discovery) WithNetworkManager ¶
WithNetworkManager sets the network manager
func (*Discovery) WithNodeManager ¶
WithNodeManager sets the node manager
type EndpointStats ¶
type EndpointStats struct {
ActiveConnections uint32
TotalRequests uint64
FailedRequests uint64
AvgResponseTimeMS float64
LastSelected int64
}
EndpointStats represents statistics for an endpoint
type HealthCheckConfig ¶
type HealthCheckConfig struct {
Protocol HealthCheckProtocol
Path string // For HTTP health checks
IntervalSeconds uint64
TimeoutSeconds uint64
HealthyThreshold uint32
UnhealthyThreshold uint32
}
HealthCheckConfig represents the configuration for health checks
type HealthCheckProtocol ¶
type HealthCheckProtocol string
HealthCheckProtocol represents the protocol for health checks
const ( // HealthCheckHTTP indicates HTTP health checks HealthCheckHTTP HealthCheckProtocol = "http" // HealthCheckHTTPS indicates HTTPS health checks HealthCheckHTTPS HealthCheckProtocol = "https" // HealthCheckTCP indicates TCP health checks HealthCheckTCP HealthCheckProtocol = "tcp" // HealthCheckCommand indicates command health checks HealthCheckCommand HealthCheckProtocol = "command" )
type LoadBalancingStrategy ¶
type LoadBalancingStrategy string
LoadBalancingStrategy represents the strategy for load balancing
const ( // LoadBalancingRoundRobin indicates round-robin load balancing LoadBalancingRoundRobin LoadBalancingStrategy = "round_robin" // LoadBalancingWeightedRoundRobin indicates weighted round-robin load balancing LoadBalancingWeightedRoundRobin LoadBalancingStrategy = "weighted_round_robin" // LoadBalancingLeastConnections indicates least connections load balancing LoadBalancingLeastConnections LoadBalancingStrategy = "least_connections" // LoadBalancingRandom indicates random load balancing LoadBalancingRandom LoadBalancingStrategy = "random" // LoadBalancingIPHash indicates IP hash load balancing LoadBalancingIPHash LoadBalancingStrategy = "ip_hash" )
type RetryPolicy ¶
RetryPolicy represents a retry policy
type RoutingRule ¶
type RoutingRule struct {
PathPrefix string
Headers map[string]string
ServiceName string
Weight uint32
}
RoutingRule represents a routing rule for a service
type ServiceEndpoint ¶
type ServiceEndpoint struct {
ServiceName string
Domain string
IPAddress string
Port uint16
NodeID string
HealthStatus ServiceHealth
LastHealthCheck int64
Version string
Weight uint32
Metadata map[string]string
}
ServiceEndpoint represents an endpoint for a service
type ServiceHealth ¶
type ServiceHealth string
ServiceHealth represents the health status of a service
const ( // ServiceHealthy indicates the service is healthy ServiceHealthy ServiceHealth = "healthy" // ServiceUnhealthy indicates the service is unhealthy ServiceUnhealthy ServiceHealth = "unhealthy" // ServiceUnknown indicates the service health is unknown ServiceUnknown ServiceHealth = "unknown" )
type ServiceInfo ¶
type ServiceInfo struct {
Name string
Namespace string
Version string
Endpoints []ServiceEndpoint
Labels map[string]string
Annotations map[string]string
CreatedAt time.Time
UpdatedAt time.Time
HealthStatus ServiceHealth
LastHealthCheck time.Time
Metadata map[string]string
}
ServiceInfo represents information about a service
type ServiceMeshConfig ¶
type ServiceMeshConfig struct {
Enabled bool
MTLSEnabled bool
TracingEnabled bool
RetryPolicy *RetryPolicy
TimeoutMS uint64
CircuitBreaker *CircuitBreakerPolicy
}
ServiceMeshConfig represents a service mesh configuration
type TrafficSplit ¶
TrafficSplit represents a traffic split
type TrafficSplitConfig ¶
type TrafficSplitConfig struct {
ServiceName string
Splits []TrafficSplit
}
TrafficSplitConfig represents a traffic split configuration