Documentation
¶
Index ¶
- func HTTPClientMiddleware(config SecureHTTPClientConfig) func(*http.Client) *http.Client
- func NewSecureHTTPClient(config SecureHTTPClientConfig) *http.Client
- func SecureHTTPClientExample() *http.Client
- func ServiceClientMiddleware(client *ServiceClient) lift.Middleware
- func ValidateHTTPClientSecurity(client *http.Client) []string
- type CacheStats
- type CheckResult
- type CircuitBreaker
- type CircuitBreakerState
- type CircuitBreakerStats
- type Counter
- type CreateUserRequest
- type DefaultLoadBalancer
- func (lb *DefaultLoadBalancer) GetStats() LoadBalancerStats
- func (lb *DefaultLoadBalancer) ReleaseConnection(instanceID string)
- func (lb *DefaultLoadBalancer) Reset()
- func (lb *DefaultLoadBalancer) Select(instances []*ServiceInstance, strategy LoadBalanceStrategy) *ServiceInstance
- func (lb *DefaultLoadBalancer) UpdateWeights(instances []*ServiceInstance) error
- type DiscoveryOptions
- type Gauge
- type HTTPClient
- type HealthAwareLoadBalancer
- type HealthCheckConfig
- type HealthStatus
- type Histogram
- type LoadBalanceStrategy
- type LoadBalancer
- type LoadBalancerMetrics
- type LoadBalancerStats
- type MemoryServiceCache
- type MetricsCollector
- type MultiTierServiceCache
- func (m *MultiTierServiceCache) Clear()
- func (m *MultiTierServiceCache) Delete(key string)
- func (m *MultiTierServiceCache) Get(key string) ([]*ServiceInstance, bool)
- func (m *MultiTierServiceCache) Set(key string, instances []*ServiceInstance, ttl time.Duration)
- func (m *MultiTierServiceCache) Stats() CacheStats
- type RegistryConfig
- type RegistryStats
- type RetryPolicy
- type SecureHTTPClientConfig
- type ServiceCache
- type ServiceClient
- type ServiceClientConfig
- type ServiceConfig
- type ServiceDiscovery
- type ServiceEndpoint
- type ServiceInstance
- type ServiceRegistry
- func (r *ServiceRegistry) Deregister(ctx context.Context, serviceID string) error
- func (r *ServiceRegistry) Discover(ctx context.Context, serviceName string, opts DiscoveryOptions) (*ServiceInstance, error)
- func (r *ServiceRegistry) DiscoverAll(ctx context.Context, serviceName string, opts DiscoveryOptions) ([]*ServiceInstance, error)
- func (r *ServiceRegistry) GetService(serviceName string) (*ServiceConfig, bool)
- func (r *ServiceRegistry) GetStats() RegistryStats
- func (r *ServiceRegistry) ListServices() []*ServiceConfig
- func (r *ServiceRegistry) Register(ctx context.Context, config *ServiceConfig) error
- func (r *ServiceRegistry) Watch(ctx context.Context, serviceName string) (<-chan []*ServiceInstance, error)
- type ServiceRequest
- type ServiceResponse
- type TTLServiceCache
- func (t *TTLServiceCache) Clear()
- func (t *TTLServiceCache) Close()
- func (t *TTLServiceCache) Delete(key string)
- func (t *TTLServiceCache) Get(key string) ([]*ServiceInstance, bool)
- func (t *TTLServiceCache) Set(key string, instances []*ServiceInstance, ttl time.Duration)
- func (t *TTLServiceCache) Stats() CacheStats
- type UpdateUserRequest
- type User
- type UserFilters
- type UserList
- type UserService
- type UserServiceClient
- func (u *UserServiceClient) CreateUser(ctx context.Context, user *CreateUserRequest) (*User, error)
- func (u *UserServiceClient) DeleteUser(ctx context.Context, userID string) error
- func (u *UserServiceClient) GetUser(ctx context.Context, userID string) (*User, error)
- func (u *UserServiceClient) ListUsers(ctx context.Context, filters *UserFilters) (*UserList, error)
- func (u *UserServiceClient) UpdateUser(ctx context.Context, userID string, updates *UpdateUserRequest) (*User, error)
- type WeightedLoadBalancer
- func (w *WeightedLoadBalancer) GetStats() LoadBalancerStats
- func (w *WeightedLoadBalancer) GetWeight(instanceID string) int
- func (w *WeightedLoadBalancer) Select(instances []*ServiceInstance, strategy LoadBalanceStrategy) *ServiceInstance
- func (w *WeightedLoadBalancer) SetWeight(instanceID string, weight int)
- func (w *WeightedLoadBalancer) UpdateWeights(instances []*ServiceInstance) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTTPClientMiddleware ¶
func HTTPClientMiddleware(config SecureHTTPClientConfig) func(*http.Client) *http.Client
HTTPClientMiddleware provides HTTP client configuration middleware
func NewSecureHTTPClient ¶
func NewSecureHTTPClient(config SecureHTTPClientConfig) *http.Client
NewSecureHTTPClient creates a secure HTTP client with comprehensive timeout configurations
func SecureHTTPClientExample ¶
SecureHTTPClientExample demonstrates secure HTTP client usage
func ServiceClientMiddleware ¶
func ServiceClientMiddleware(client *ServiceClient) lift.Middleware
ServiceClientMiddleware creates middleware for service client integration
func ValidateHTTPClientSecurity ¶
ValidateHTTPClientSecurity validates HTTP client security configuration
Types ¶
type CacheStats ¶
type CacheStats struct {
Hits int64 `json:"hits"`
Misses int64 `json:"misses"`
Sets int64 `json:"sets"`
Deletes int64 `json:"deletes"`
Errors int64 `json:"errors"`
HitRate float64 `json:"hit_rate"`
AvgLatency int64 `json:"avg_latency_ns"`
Size int64 `json:"size"`
Memory int64 `json:"memory_bytes"`
}
CacheStats provides cache performance metrics (reusing from features package)
type CheckResult ¶
type CheckResult struct {
Status string `json:"status"`
Message string `json:"message"`
Latency int64 `json:"latency_ms"`
}
CheckResult represents the result of a health check
type CircuitBreaker ¶
type CircuitBreaker interface {
Execute(fn func() (any, error)) (any, error)
GetState() CircuitBreakerState
GetStats() CircuitBreakerStats
}
CircuitBreaker defines the interface for circuit breaking
type CircuitBreakerState ¶
type CircuitBreakerState string
CircuitBreakerState represents circuit breaker states
const ( CircuitBreakerClosed CircuitBreakerState = "closed" CircuitBreakerOpen CircuitBreakerState = "open" CircuitBreakerHalfOpen CircuitBreakerState = "half_open" )
type CircuitBreakerStats ¶
type CircuitBreakerStats struct {
State CircuitBreakerState `json:"state"`
TotalRequests int64 `json:"total_requests"`
SuccessfulRequests int64 `json:"successful_requests"`
FailedRequests int64 `json:"failed_requests"`
LastStateChange time.Time `json:"last_state_change"`
}
CircuitBreakerStats provides circuit breaker metrics
type CreateUserRequest ¶
type CreateUserRequest struct {
Email string `json:"email"`
Name string `json:"name"`
TenantID string `json:"tenant_id"`
Metadata map[string]string `json:"metadata"`
}
CreateUserRequest represents a user creation request
type DefaultLoadBalancer ¶
type DefaultLoadBalancer struct {
// contains filtered or unexported fields
}
DefaultLoadBalancer implements multiple load balancing strategies
func NewDefaultLoadBalancer ¶
func NewDefaultLoadBalancer() *DefaultLoadBalancer
NewDefaultLoadBalancer creates a new load balancer
func (*DefaultLoadBalancer) GetStats ¶
func (lb *DefaultLoadBalancer) GetStats() LoadBalancerStats
GetStats returns load balancer statistics
func (*DefaultLoadBalancer) ReleaseConnection ¶
func (lb *DefaultLoadBalancer) ReleaseConnection(instanceID string)
ReleaseConnection decrements the connection count for an instance
func (*DefaultLoadBalancer) Reset ¶
func (lb *DefaultLoadBalancer) Reset()
Reset resets all counters and statistics
func (*DefaultLoadBalancer) Select ¶
func (lb *DefaultLoadBalancer) Select(instances []*ServiceInstance, strategy LoadBalanceStrategy) *ServiceInstance
Select selects an instance using the specified strategy
func (*DefaultLoadBalancer) UpdateWeights ¶
func (lb *DefaultLoadBalancer) UpdateWeights(instances []*ServiceInstance) error
UpdateWeights updates the weights of instances
type DiscoveryOptions ¶
type DiscoveryOptions struct {
TenantID string `json:"tenant_id,omitempty"`
Strategy LoadBalanceStrategy `json:"strategy"`
Tags []string `json:"tags"`
Version string `json:"version,omitempty"`
Region string `json:"region,omitempty"`
IncludeUnhealthy bool `json:"include_unhealthy"`
MaxInstances int `json:"max_instances"`
PreferLocal bool `json:"prefer_local"`
}
DiscoveryOptions configures service discovery behavior
type HTTPClient ¶
HTTPClient defines the interface for HTTP operations
type HealthAwareLoadBalancer ¶
type HealthAwareLoadBalancer struct {
// contains filtered or unexported fields
}
HealthAwareLoadBalancer wraps a load balancer with health awareness
func NewHealthAwareLoadBalancer ¶
func NewHealthAwareLoadBalancer(delegate LoadBalancer, healthThreshold time.Duration) *HealthAwareLoadBalancer
NewHealthAwareLoadBalancer creates a health-aware load balancer
func (*HealthAwareLoadBalancer) GetStats ¶
func (h *HealthAwareLoadBalancer) GetStats() LoadBalancerStats
GetStats delegates to the underlying load balancer
func (*HealthAwareLoadBalancer) Select ¶
func (h *HealthAwareLoadBalancer) Select(instances []*ServiceInstance, strategy LoadBalanceStrategy) *ServiceInstance
Select selects an instance with health awareness
func (*HealthAwareLoadBalancer) UpdateWeights ¶
func (h *HealthAwareLoadBalancer) UpdateWeights(instances []*ServiceInstance) error
UpdateWeights delegates to the underlying load balancer
type HealthCheckConfig ¶
type HealthCheckConfig struct {
Enabled bool `json:"enabled"`
Path string `json:"path"`
Interval time.Duration `json:"interval"`
Timeout time.Duration `json:"timeout"`
Retries int `json:"retries"`
FailureThreshold int `json:"failure_threshold"`
SuccessThreshold int `json:"success_threshold"`
}
HealthCheckConfig configures health checking for a service
type HealthStatus ¶
type HealthStatus struct {
Status string `json:"status"`
Message string `json:"message"`
Timestamp time.Time `json:"timestamp"`
Checks map[string]CheckResult `json:"checks"`
}
HealthStatus represents the health status of a service
type LoadBalanceStrategy ¶
type LoadBalanceStrategy string
LoadBalanceStrategy defines load balancing strategies
const ( RoundRobin LoadBalanceStrategy = "round_robin" WeightedRandom LoadBalanceStrategy = "weighted_random" LeastConnections LoadBalanceStrategy = "least_connections" HealthyFirst LoadBalanceStrategy = "healthy_first" LocalFirst LoadBalanceStrategy = "local_first" )
type LoadBalancer ¶
type LoadBalancer interface {
Select(instances []*ServiceInstance, strategy LoadBalanceStrategy) *ServiceInstance
UpdateWeights(instances []*ServiceInstance) error
GetStats() LoadBalancerStats
}
LoadBalancer defines the interface for load balancing
func NewHealthyFirstLoadBalancer ¶
func NewHealthyFirstLoadBalancer(healthThreshold time.Duration) LoadBalancer
NewHealthyFirstLoadBalancer creates a health-first load balancer
func NewLeastConnectionsLoadBalancer ¶
func NewLeastConnectionsLoadBalancer() LoadBalancer
NewLeastConnectionsLoadBalancer creates a least connections load balancer
func NewRoundRobinLoadBalancer ¶
func NewRoundRobinLoadBalancer() LoadBalancer
NewRoundRobinLoadBalancer creates a round-robin load balancer
func NewWeightedRandomLoadBalancer ¶
func NewWeightedRandomLoadBalancer() LoadBalancer
NewWeightedRandomLoadBalancer creates a weighted random load balancer
type LoadBalancerMetrics ¶
type LoadBalancerMetrics struct {
// contains filtered or unexported fields
}
LoadBalancerMetrics tracks load balancer performance
type LoadBalancerStats ¶
type LoadBalancerStats struct {
TotalRequests int64 `json:"total_requests"`
SuccessfulSelections int64 `json:"successful_selections"`
FailedSelections int64 `json:"failed_selections"`
AverageLatency int64 `json:"average_latency_ns"`
}
LoadBalancerStats provides load balancer metrics
type MemoryServiceCache ¶
type MemoryServiceCache struct {
// contains filtered or unexported fields
}
MemoryServiceCache implements an in-memory service discovery cache
func (*MemoryServiceCache) Clear ¶
func (c *MemoryServiceCache) Clear()
Clear removes all entries from cache
func (*MemoryServiceCache) Delete ¶
func (c *MemoryServiceCache) Delete(key string)
Delete removes an entry from cache
func (*MemoryServiceCache) Get ¶
func (c *MemoryServiceCache) Get(key string) ([]*ServiceInstance, bool)
Get retrieves service instances from cache
func (*MemoryServiceCache) Set ¶
func (c *MemoryServiceCache) Set(key string, instances []*ServiceInstance, ttl time.Duration)
Set stores service instances in cache
func (*MemoryServiceCache) Stats ¶
func (c *MemoryServiceCache) Stats() CacheStats
Stats returns cache statistics
type MetricsCollector ¶
type MetricsCollector = lift.MetricsCollector
MetricsCollector is re-exported from lift package
type MultiTierServiceCache ¶
type MultiTierServiceCache struct {
// contains filtered or unexported fields
}
MultiTierServiceCache implements a multi-tier caching strategy
func NewMultiTierServiceCache ¶
func NewMultiTierServiceCache(l1Cache, l2Cache ServiceCache) *MultiTierServiceCache
NewMultiTierServiceCache creates a multi-tier cache
func (*MultiTierServiceCache) Clear ¶
func (m *MultiTierServiceCache) Clear()
Clear clears both caches
func (*MultiTierServiceCache) Delete ¶
func (m *MultiTierServiceCache) Delete(key string)
Delete removes from both caches
func (*MultiTierServiceCache) Get ¶
func (m *MultiTierServiceCache) Get(key string) ([]*ServiceInstance, bool)
Get retrieves from L1 cache first, then L2 cache
func (*MultiTierServiceCache) Set ¶
func (m *MultiTierServiceCache) Set(key string, instances []*ServiceInstance, ttl time.Duration)
Set stores in both L1 and L2 caches
func (*MultiTierServiceCache) Stats ¶
func (m *MultiTierServiceCache) Stats() CacheStats
Stats returns combined statistics
type RegistryConfig ¶
type RegistryConfig struct {
EnableCaching bool `json:"enable_caching"`
CacheTTL time.Duration `json:"cache_ttl"`
HealthCheckInterval time.Duration `json:"health_check_interval"`
EnableMetrics bool `json:"enable_metrics"`
TenantIsolation bool `json:"tenant_isolation"`
MaxRetries int `json:"max_retries"`
RetryBackoff time.Duration `json:"retry_backoff"`
}
RegistryConfig configures the service registry
type RegistryStats ¶
type RegistryStats struct {
RegisteredServices int `json:"registered_services"`
CacheStats CacheStats `json:"cache_stats"`
LoadBalancerStats LoadBalancerStats `json:"load_balancer_stats"`
Timestamp time.Time `json:"timestamp"`
}
RegistryStats provides registry performance metrics
type RetryPolicy ¶
type RetryPolicy struct {
MaxRetries int `json:"max_retries"`
InitialBackoff time.Duration `json:"initial_backoff"`
MaxBackoff time.Duration `json:"max_backoff"`
BackoffMultiplier float64 `json:"backoff_multiplier"`
RetryableStatusCodes []int `json:"retryable_status_codes"`
RetryableErrors []string `json:"retryable_errors"`
}
RetryPolicy defines retry behavior
type SecureHTTPClientConfig ¶
type SecureHTTPClientConfig struct {
// Connection timeouts
ConnectTimeout time.Duration `json:"connect_timeout"` // Time to establish connection
RequestTimeout time.Duration `json:"request_timeout"` // Total request timeout
ResponseTimeout time.Duration `json:"response_timeout"` // Time to read response headers
KeepAliveTimeout time.Duration `json:"keepalive_timeout"` // Keep-alive timeout
// TLS settings
TLSHandshakeTimeout time.Duration `json:"tls_handshake_timeout"` // TLS handshake timeout
InsecureSkipVerify bool `json:"insecure_skip_verify"` // Skip TLS verification (dev only)
// Connection pooling
MaxIdleConns int `json:"max_idle_conns"` // Maximum idle connections
MaxIdleConnsPerHost int `json:"max_idle_conns_per_host"` // Maximum idle connections per host
MaxConnsPerHost int `json:"max_conns_per_host"` // Maximum connections per host
IdleConnTimeout time.Duration `json:"idle_conn_timeout"` // Idle connection timeout
// Request limits
MaxResponseHeaderBytes int64 `json:"max_response_header_bytes"` // Maximum response header size
DisableCompression bool `json:"disable_compression"` // Disable gzip compression
DisableKeepAlives bool `json:"disable_keep_alives"` // Disable keep-alive connections
// Security
UserAgent string `json:"user_agent"` // User agent string
}
SecureHTTPClientConfig provides comprehensive HTTP client security configuration
func DefaultSecureHTTPClientConfig ¶
func DefaultSecureHTTPClientConfig() SecureHTTPClientConfig
DefaultSecureHTTPClientConfig returns secure default configuration
func DevelopmentHTTPClientConfig ¶
func DevelopmentHTTPClientConfig() SecureHTTPClientConfig
DevelopmentHTTPClientConfig returns development-friendly configuration
func ProductionHTTPClientConfig ¶
func ProductionHTTPClientConfig() SecureHTTPClientConfig
ProductionHTTPClientConfig returns production-ready configuration
type ServiceCache ¶
type ServiceCache interface {
Get(key string) ([]*ServiceInstance, bool)
Set(key string, instances []*ServiceInstance, ttl time.Duration)
Delete(key string)
Clear()
Stats() CacheStats
}
ServiceCache defines the interface for service discovery caching
func NewMemoryServiceCache ¶
func NewMemoryServiceCache() ServiceCache
NewMemoryServiceCache creates a new in-memory service cache
func NewMemoryServiceCacheWithSize ¶
func NewMemoryServiceCacheWithSize(maxSize int) ServiceCache
NewMemoryServiceCacheWithSize creates a cache with specified max size
type ServiceClient ¶
type ServiceClient struct {
// contains filtered or unexported fields
}
ServiceClient provides type-safe inter-service communication
func GetServiceClient ¶
func GetServiceClient(ctx *lift.Context) *ServiceClient
GetServiceClient retrieves the service client from context
func NewServiceClient ¶
func NewServiceClient(registry *ServiceRegistry, config ServiceClientConfig) *ServiceClient
NewServiceClient creates a new service client
func (*ServiceClient) Call ¶
func (c *ServiceClient) Call(ctx context.Context, request *ServiceRequest) (*ServiceResponse, error)
Call makes a type-safe service call with automatic discovery
type ServiceClientConfig ¶
type ServiceClientConfig struct {
DefaultTimeout time.Duration `json:"default_timeout"`
MaxRetries int `json:"max_retries"`
RetryBackoff time.Duration `json:"retry_backoff"`
EnableTracing bool `json:"enable_tracing"`
EnableMetrics bool `json:"enable_metrics"`
EnableCircuitBreaker bool `json:"enable_circuit_breaker"`
TenantIsolation bool `json:"tenant_isolation"`
UserAgent string `json:"user_agent"`
}
ServiceClientConfig configures the service client
type ServiceConfig ¶
type ServiceConfig struct {
Name string `json:"name"`
Version string `json:"version"`
Endpoints []ServiceEndpoint `json:"endpoints"`
HealthCheck HealthCheckConfig `json:"health_check"`
Metadata map[string]string `json:"metadata"`
TenantID string `json:"tenant_id,omitempty"`
Tags []string `json:"tags"`
Weight int `json:"weight"`
Region string `json:"region"`
Environment string `json:"environment"`
Created time.Time `json:"created"`
LastSeen time.Time `json:"last_seen"`
}
ServiceConfig represents a service configuration
type ServiceDiscovery ¶
type ServiceDiscovery interface {
Register(ctx context.Context, config *ServiceConfig) error
Deregister(ctx context.Context, serviceID string) error
Discover(ctx context.Context, serviceName string) ([]*ServiceInstance, error)
Watch(ctx context.Context, serviceName string) (<-chan []*ServiceInstance, error)
HealthCheck(ctx context.Context, instance *ServiceInstance) (*HealthStatus, error)
}
ServiceDiscovery defines the interface for service discovery backends
type ServiceEndpoint ¶
type ServiceEndpoint struct {
Protocol string `json:"protocol"`
Host string `json:"host"`
Port int `json:"port"`
Path string `json:"path"`
Metadata map[string]string `json:"metadata"`
}
ServiceEndpoint represents a service endpoint
type ServiceInstance ¶
type ServiceInstance struct {
ID string `json:"id"`
ServiceName string `json:"service_name"`
Version string `json:"version"`
Endpoint ServiceEndpoint `json:"endpoint"`
Health HealthStatus `json:"health"`
Metadata map[string]string `json:"metadata"`
TenantID string `json:"tenant_id,omitempty"`
Weight int `json:"weight"`
LastSeen time.Time `json:"last_seen"`
}
ServiceInstance represents a discovered service instance
type ServiceRegistry ¶
type ServiceRegistry struct {
// contains filtered or unexported fields
}
ServiceRegistry manages service registration and discovery
func NewServiceRegistry ¶
func NewServiceRegistry(config RegistryConfig, discovery ServiceDiscovery, loadBalancer LoadBalancer) *ServiceRegistry
NewServiceRegistry creates a new service registry
func (*ServiceRegistry) Deregister ¶
func (r *ServiceRegistry) Deregister(ctx context.Context, serviceID string) error
Deregister removes a service from the registry
func (*ServiceRegistry) Discover ¶
func (r *ServiceRegistry) Discover(ctx context.Context, serviceName string, opts DiscoveryOptions) (*ServiceInstance, error)
Discover discovers service instances
func (*ServiceRegistry) DiscoverAll ¶
func (r *ServiceRegistry) DiscoverAll(ctx context.Context, serviceName string, opts DiscoveryOptions) ([]*ServiceInstance, error)
DiscoverAll discovers all instances of a service
func (*ServiceRegistry) GetService ¶
func (r *ServiceRegistry) GetService(serviceName string) (*ServiceConfig, bool)
GetService returns a service configuration
func (*ServiceRegistry) GetStats ¶
func (r *ServiceRegistry) GetStats() RegistryStats
GetStats returns registry statistics
func (*ServiceRegistry) ListServices ¶
func (r *ServiceRegistry) ListServices() []*ServiceConfig
ListServices returns all registered services
func (*ServiceRegistry) Register ¶
func (r *ServiceRegistry) Register(ctx context.Context, config *ServiceConfig) error
Register registers a service with the registry
func (*ServiceRegistry) Watch ¶
func (r *ServiceRegistry) Watch(ctx context.Context, serviceName string) (<-chan []*ServiceInstance, error)
Watch watches for changes to a service
type ServiceRequest ¶
type ServiceRequest struct {
ServiceName string `json:"service_name"`
Method string `json:"method"`
Path string `json:"path"`
Headers map[string]string `json:"headers"`
Body any `json:"body"`
TenantID string `json:"tenant_id,omitempty"`
UserID string `json:"user_id,omitempty"`
RequestID string `json:"request_id,omitempty"`
LoadBalanceStrategy LoadBalanceStrategy `json:"load_balance_strategy"`
Timeout time.Duration `json:"timeout"`
Metadata map[string]any `json:"metadata"`
}
ServiceRequest represents a service call request
type ServiceResponse ¶
type ServiceResponse struct {
StatusCode int `json:"status_code"`
Headers map[string]string `json:"headers"`
Body []byte `json:"body"`
Metadata map[string]any `json:"metadata"`
Duration time.Duration `json:"duration"`
Instance *ServiceInstance `json:"instance"`
}
ServiceResponse represents a service call response
type TTLServiceCache ¶
type TTLServiceCache struct {
// contains filtered or unexported fields
}
TTLServiceCache wraps a cache with automatic TTL cleanup
func NewTTLServiceCache ¶
func NewTTLServiceCache(delegate ServiceCache, cleanupInterval time.Duration) *TTLServiceCache
NewTTLServiceCache creates a cache with automatic TTL cleanup
func (*TTLServiceCache) Clear ¶
func (t *TTLServiceCache) Clear()
Clear delegates to the underlying cache
func (*TTLServiceCache) Delete ¶
func (t *TTLServiceCache) Delete(key string)
Delete delegates to the underlying cache
func (*TTLServiceCache) Get ¶
func (t *TTLServiceCache) Get(key string) ([]*ServiceInstance, bool)
Get delegates to the underlying cache
func (*TTLServiceCache) Set ¶
func (t *TTLServiceCache) Set(key string, instances []*ServiceInstance, ttl time.Duration)
Set delegates to the underlying cache
func (*TTLServiceCache) Stats ¶
func (t *TTLServiceCache) Stats() CacheStats
Stats delegates to the underlying cache
type UpdateUserRequest ¶
type UpdateUserRequest struct {
Email *string `json:"email,omitempty"`
Name *string `json:"name,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
}
UpdateUserRequest represents a user update request
type User ¶
type User struct {
ID string `json:"id"`
Email string `json:"email"`
Name string `json:"name"`
TenantID string `json:"tenant_id"`
Metadata map[string]string `json:"metadata"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
User represents a user entity
type UserFilters ¶
type UserFilters struct {
TenantID string `json:"tenant_id,omitempty"`
Email string `json:"email,omitempty"`
Limit int `json:"limit,omitempty"`
Offset int `json:"offset,omitempty"`
}
UserFilters represents user listing filters
type UserList ¶
type UserList struct {
Users []*User `json:"users"`
Total int `json:"total"`
Limit int `json:"limit"`
Offset int `json:"offset"`
}
UserList represents a list of users
type UserService ¶
type UserService interface {
GetUser(ctx context.Context, userID string) (*User, error)
CreateUser(ctx context.Context, user *CreateUserRequest) (*User, error)
UpdateUser(ctx context.Context, userID string, updates *UpdateUserRequest) (*User, error)
DeleteUser(ctx context.Context, userID string) error
ListUsers(ctx context.Context, filters *UserFilters) (*UserList, error)
}
UserService defines the interface for user service operations
func NewUserServiceClient ¶
func NewUserServiceClient(client *ServiceClient, tenantID string) UserService
NewUserServiceClient creates a new user service client
type UserServiceClient ¶
type UserServiceClient struct {
// contains filtered or unexported fields
}
UserServiceClient implements the UserService interface
func (*UserServiceClient) CreateUser ¶
func (u *UserServiceClient) CreateUser(ctx context.Context, user *CreateUserRequest) (*User, error)
CreateUser creates a new user
func (*UserServiceClient) DeleteUser ¶
func (u *UserServiceClient) DeleteUser(ctx context.Context, userID string) error
DeleteUser deletes a user
func (*UserServiceClient) ListUsers ¶
func (u *UserServiceClient) ListUsers(ctx context.Context, filters *UserFilters) (*UserList, error)
ListUsers lists users with optional filters
func (*UserServiceClient) UpdateUser ¶
func (u *UserServiceClient) UpdateUser(ctx context.Context, userID string, updates *UpdateUserRequest) (*User, error)
UpdateUser updates an existing user
type WeightedLoadBalancer ¶
type WeightedLoadBalancer struct {
// contains filtered or unexported fields
}
WeightedLoadBalancer implements weighted load balancing with dynamic weight adjustment
func NewWeightedLoadBalancer ¶
func NewWeightedLoadBalancer(delegate LoadBalancer) *WeightedLoadBalancer
NewWeightedLoadBalancer creates a weighted load balancer
func (*WeightedLoadBalancer) GetStats ¶
func (w *WeightedLoadBalancer) GetStats() LoadBalancerStats
GetStats delegates to the underlying load balancer
func (*WeightedLoadBalancer) GetWeight ¶
func (w *WeightedLoadBalancer) GetWeight(instanceID string) int
GetWeight gets the weight for a specific instance
func (*WeightedLoadBalancer) Select ¶
func (w *WeightedLoadBalancer) Select(instances []*ServiceInstance, strategy LoadBalanceStrategy) *ServiceInstance
Select selects an instance using weighted selection
func (*WeightedLoadBalancer) SetWeight ¶
func (w *WeightedLoadBalancer) SetWeight(instanceID string, weight int)
SetWeight sets the weight for a specific instance
func (*WeightedLoadBalancer) UpdateWeights ¶
func (w *WeightedLoadBalancer) UpdateWeights(instances []*ServiceInstance) error
UpdateWeights updates weights based on performance metrics