Documentation
¶
Index ¶
- Constants
- func GenerateServiceName(baseName string, protocol string, port int, pattern ServiceNamingPattern) string
- func GetErrorContext(err error) map[string]string
- func GetServiceEndpointInfo(registrations []*ServiceRegistration) map[string]interface{}
- func IsErrorCategory(err error, category ErrorCategory) bool
- func IsErrorCode(err error, code string) bool
- func IsServerError(err error) bool
- func PerformanceLoggingHook(event string, metrics *PerformanceMetrics)
- func PerformanceMetricsCollectionHook(event string, metrics *PerformanceMetrics)
- func PerformanceThresholdViolationHook(event string, metrics *PerformanceMetrics)
- func ValidateServiceRegistrations(registrations []*ServiceRegistration) error
- type AuthServiceTemplate
- type BusinessDependencyContainer
- type BusinessDependencyContainerBuilder
- func (b *BusinessDependencyContainerBuilder) AddInstance(name string, instance interface{}) *BusinessDependencyContainerBuilder
- func (b *BusinessDependencyContainerBuilder) AddSingleton(name string, factory DependencyFactory) *BusinessDependencyContainerBuilder
- func (b *BusinessDependencyContainerBuilder) AddTransient(name string, factory DependencyFactory) *BusinessDependencyContainerBuilder
- func (b *BusinessDependencyContainerBuilder) Build() BusinessDependencyContainer
- type BusinessDependencyRegistry
- type BusinessGRPCService
- type BusinessHTTPHandler
- type BusinessHealthCheck
- type BusinessServerCore
- type BusinessServerImpl
- func (s *BusinessServerImpl) GetGRPCAddress() string
- func (s *BusinessServerImpl) GetHTTPAddress() string
- func (s *BusinessServerImpl) GetPerformanceMetrics() *PerformanceMetrics
- func (s *BusinessServerImpl) GetPerformanceMonitor() *PerformanceMonitor
- func (s *BusinessServerImpl) GetTransportHealth(ctx context.Context) map[string]map[string]*types.HealthStatus
- func (s *BusinessServerImpl) GetTransportStatus() map[string]TransportStatus
- func (s *BusinessServerImpl) GetTransports() []transport.NetworkTransport
- func (s *BusinessServerImpl) GetUptime() time.Duration
- func (s *BusinessServerImpl) SetDiscoveryManager(manager ServiceDiscoveryManager)
- func (s *BusinessServerImpl) Shutdown() error
- func (s *BusinessServerImpl) Start(ctx context.Context) error
- func (s *BusinessServerImpl) Stop(ctx context.Context) error
- type BusinessServerWithPerformance
- type BusinessServiceRegistrar
- type BusinessServiceRegistry
- type CORSConfig
- type CommonServicePatterns
- func (p *CommonServicePatterns) ApplyStandardDefaults(config *ServerConfig, defaults StandardConfigDefaults)
- func (p *CommonServicePatterns) CreateDatabaseHealthCheck(db *gorm.DB) HealthCheckFunc
- func (p *CommonServicePatterns) CreateGenericDependencyContainer(serviceName string, services map[string]interface{}, db *gorm.DB) *GenericDependencyContainer
- func (p *CommonServicePatterns) CreateServiceAvailabilityCheck(service interface{}, serviceName string) HealthCheckFunc
- func (p *CommonServicePatterns) SafeCloseDatabase(db *gorm.DB, serviceName string) error
- type ConfigBuilder
- func (b *ConfigBuilder) Build() (*ServerConfig, error)
- func (b *ConfigBuilder) DisableDiscovery() *ConfigBuilder
- func (b *ConfigBuilder) DisableGRPC() *ConfigBuilder
- func (b *ConfigBuilder) DisableHTTP() *ConfigBuilder
- func (b *ConfigBuilder) EnableGRPC() *ConfigBuilder
- func (b *ConfigBuilder) EnableHTTP() *ConfigBuilder
- func (b *ConfigBuilder) MustBuild() *ServerConfig
- func (b *ConfigBuilder) WithAuth() *ConfigBuilder
- func (b *ConfigBuilder) WithCORS(allowOrigins []string) *ConfigBuilder
- func (b *ConfigBuilder) WithDiscovery(address, serviceName string, tags []string) *ConfigBuilder
- func (b *ConfigBuilder) WithGRPCHealthService() *ConfigBuilder
- func (b *ConfigBuilder) WithGRPCKeepalive(time, timeout time.Duration) *ConfigBuilder
- func (b *ConfigBuilder) WithGRPCPort(port string) *ConfigBuilder
- func (b *ConfigBuilder) WithGRPCReflection() *ConfigBuilder
- func (b *ConfigBuilder) WithHTTPPort(port string) *ConfigBuilder
- func (b *ConfigBuilder) WithLogging() *ConfigBuilder
- func (b *ConfigBuilder) WithRateLimit(requestsPerSecond, burstSize int) *ConfigBuilder
- func (b *ConfigBuilder) WithServiceName(name string) *ConfigBuilder
- func (b *ConfigBuilder) WithShutdownTimeout(timeout time.Duration) *ConfigBuilder
- func (b *ConfigBuilder) WithTestMode(httpTestPort, grpcTestPort string) *ConfigBuilder
- func (b *ConfigBuilder) WithTimeout(timeout time.Duration) *ConfigBuilder
- type ConfigMapperBase
- func (m *ConfigMapperBase) SetDefaultDiscoveryConfig(config *ServerConfig, address, serviceName string, tags []string)
- func (m *ConfigMapperBase) SetDefaultGRPCConfig(config *ServerConfig, port, defaultPort string, ...)
- func (m *ConfigMapperBase) SetDefaultHTTPConfig(config *ServerConfig, port, defaultPort string, enableReady bool)
- func (m *ConfigMapperBase) SetDefaultMiddlewareConfig(config *ServerConfig, ...)
- func (m *ConfigMapperBase) SetDefaultServerConfig(config *ServerConfig, serviceName string)
- type ConfigTemplate
- type ConfigValidator
- type DefaultServiceRegistry
- func (r *DefaultServiceRegistry) CheckAllHealth(ctx context.Context) map[string]*types.HealthStatus
- func (r *DefaultServiceRegistry) CreateBusinessHealthCheckEndpoint(serviceName string, checkFunc func(ctx context.Context) error) BusinessHealthCheck
- func (r *DefaultServiceRegistry) GetBusinessGRPCServices() []BusinessGRPCService
- func (r *DefaultServiceRegistry) GetBusinessHTTPHandlers() []BusinessHTTPHandler
- func (r *DefaultServiceRegistry) GetBusinessHealthChecks() []BusinessHealthCheck
- func (r *DefaultServiceRegistry) GetOverallHealthStatus(ctx context.Context) *types.HealthStatus
- func (r *DefaultServiceRegistry) GetRegisteredServiceNames() []string
- func (r *DefaultServiceRegistry) GetServiceCount() int
- func (r *DefaultServiceRegistry) RegisterBusinessGRPCService(service BusinessGRPCService) error
- func (r *DefaultServiceRegistry) RegisterBusinessGRPCServiceWithHealthCheck(service BusinessGRPCService, healthCheckFunc func(ctx context.Context) error) error
- func (r *DefaultServiceRegistry) RegisterBusinessHTTPHandler(handler BusinessHTTPHandler) error
- func (r *DefaultServiceRegistry) RegisterBusinessHealthCheck(check BusinessHealthCheck) error
- func (r *DefaultServiceRegistry) RegisterBusinessServiceWithHealthCheck(handler BusinessHTTPHandler, healthCheckFunc func(ctx context.Context) error) error
- type DependencyFactory
- type DependencyLifecycle
- type DependencyMetadata
- type DependencyStatus
- type DiscoveryConfig
- type DiscoveryFailureMode
- type DiscoveryHealthStatus
- type DiscoveryManagerImpl
- func (d *DiscoveryManagerImpl) DeregisterMultipleEndpoints(ctx context.Context, registrations []*ServiceRegistration) error
- func (d *DiscoveryManagerImpl) DeregisterService(ctx context.Context, registration *ServiceRegistration) error
- func (d *DiscoveryManagerImpl) GetHealthStatus() *DiscoveryHealthStatus
- func (d *DiscoveryManagerImpl) IsDiscoveryAvailable() bool
- func (d *DiscoveryManagerImpl) IsHealthy(ctx context.Context) bool
- func (d *DiscoveryManagerImpl) RegisterMultipleEndpoints(ctx context.Context, registrations []*ServiceRegistration) error
- func (d *DiscoveryManagerImpl) RegisterService(ctx context.Context, registration *ServiceRegistration) error
- type ErrorCategory
- type GRPCConfig
- type GRPCInterceptorConfig
- type GRPCKeepaliveParams
- type GRPCKeepalivePolicy
- type GRPCOnlyTemplate
- type GRPCServiceDefinition
- type GRPCServiceRegistrar
- type GRPCTLSConfig
- type GenericDependencyContainer
- type GenericGRPCService
- type GenericHTTPHandler
- type GenericHealthCheck
- type HTTPConfig
- type HTTPHandlerRegistrar
- type HTTPMiddleware
- type HTTPMiddlewareFunc
- type HTTPOnlyTemplate
- type HTTPServiceDefinition
- type HealthCheckFunc
- type HealthCheckInfo
- type LifecycleManager
- func (lm *LifecycleManager) GetCurrentPhase() LifecyclePhase
- func (lm *LifecycleManager) IsStarted() bool
- func (lm *LifecycleManager) IsStopped() bool
- func (lm *LifecycleManager) IsStopping() bool
- func (lm *LifecycleManager) SetDependencies(deps BusinessDependencyContainer)
- func (lm *LifecycleManager) SetServiceDiscovery(sd *discovery.ServiceDiscovery)
- func (lm *LifecycleManager) SetTransportManager(tm TransportManager)
- func (lm *LifecycleManager) ShutdownSequence(ctx context.Context) error
- func (lm *LifecycleManager) StartupSequence(ctx context.Context) error
- type LifecyclePhase
- type LogLevel
- type LoggingConfig
- type LoggingHook
- type Metric
- type MetricType
- type MetricsCollector
- type MicroserviceTemplate
- type MiddlewareConfig
- type MiddlewareManager
- func (m *MiddlewareManager) ApplyServiceSpecificMiddleware(config ServiceSpecificMiddlewareConfig)
- func (m *MiddlewareManager) ConfigureHTTPMiddleware(router *gin.Engine) error
- func (m *MiddlewareManager) GetGRPCInterceptors() ([]grpc.UnaryServerInterceptor, []grpc.StreamServerInterceptor)
- func (m *MiddlewareManager) RegisterGRPCStreamInterceptor(interceptor grpc.StreamServerInterceptor)
- func (m *MiddlewareManager) RegisterGRPCUnaryInterceptor(interceptor grpc.UnaryServerInterceptor)
- func (m *MiddlewareManager) RegisterHTTPMiddleware(middleware HTTPMiddlewareFunc)
- type NoOpDiscoveryManager
- func (n *NoOpDiscoveryManager) DeregisterMultipleEndpoints(ctx context.Context, registrations []*ServiceRegistration) error
- func (n *NoOpDiscoveryManager) DeregisterService(ctx context.Context, registration *ServiceRegistration) error
- func (n *NoOpDiscoveryManager) GetHealthStatus() *DiscoveryHealthStatus
- func (n *NoOpDiscoveryManager) IsDiscoveryAvailable() bool
- func (n *NoOpDiscoveryManager) IsHealthy(ctx context.Context) bool
- func (n *NoOpDiscoveryManager) RegisterMultipleEndpoints(ctx context.Context, registrations []*ServiceRegistration) error
- func (n *NoOpDiscoveryManager) RegisterService(ctx context.Context, registration *ServiceRegistration) error
- type ObservabilityManager
- func (om *ObservabilityManager) GetMetrics() *ServerMetrics
- func (om *ObservabilityManager) GetServerStatus(server BusinessServerCore) *ServerStatus
- func (om *ObservabilityManager) RegisterDebugEndpoints(router *gin.Engine, server BusinessServerCore)
- func (om *ObservabilityManager) RegisterHealthEndpoint(router *gin.Engine, server BusinessServerCore)
- func (om *ObservabilityManager) SetBuildInfo(info map[string]string)
- func (om *ObservabilityManager) SetVersion(version string)
- type PerformanceHook
- type PerformanceMetrics
- func (m *PerformanceMetrics) CheckThresholds() []string
- func (m *PerformanceMetrics) GetSnapshot() PerformanceSnapshot
- func (m *PerformanceMetrics) IncrementErrorCount()
- func (m *PerformanceMetrics) IncrementRequestCount()
- func (m *PerformanceMetrics) RecordMemoryUsage()
- func (m *PerformanceMetrics) RecordServiceMetrics(serviceCount, transportCount int)
- func (m *PerformanceMetrics) RecordShutdownTime(duration time.Duration)
- func (m *PerformanceMetrics) RecordStartupTime(duration time.Duration)
- func (m *PerformanceMetrics) RecordUptime(uptime time.Duration)
- func (m *PerformanceMetrics) String() string
- type PerformanceMonitor
- func (pm *PerformanceMonitor) AddHook(hook PerformanceHook)
- func (pm *PerformanceMonitor) Disable()
- func (pm *PerformanceMonitor) Enable()
- func (pm *PerformanceMonitor) GetMetrics() *PerformanceMetrics
- func (pm *PerformanceMonitor) IsEnabled() bool
- func (pm *PerformanceMonitor) ProfileOperation(name string, operation func() error) error
- func (pm *PerformanceMonitor) RecordEvent(event string)
- func (pm *PerformanceMonitor) RemoveAllHooks()
- func (pm *PerformanceMonitor) StartPeriodicCollection(ctx context.Context, interval time.Duration)
- type PerformanceOptimizations
- type PerformanceProfiler
- func (p *PerformanceProfiler) GetMetrics() *PerformanceMetrics
- func (p *PerformanceProfiler) GetMonitor() *PerformanceMonitor
- func (p *PerformanceProfiler) ProfileServerShutdown(server *BusinessServerImpl) (time.Duration, error)
- func (p *PerformanceProfiler) ProfileServerStartup(server *BusinessServerImpl) (time.Duration, error)
- type PerformanceSnapshot
- type RateLimitConfig
- type ResourceCleanup
- type RetryConfig
- type ServerConfig
- func (c *ServerConfig) DeepCopy() *ServerConfig
- func (c *ServerConfig) GetDiscoveryFailureModeDescription() string
- func (c *ServerConfig) GetGRPCAddress() string
- func (c *ServerConfig) GetHTTPAddress() string
- func (c *ServerConfig) IsDiscoveryEnabled() bool
- func (c *ServerConfig) IsDiscoveryFailureModeFailFast() bool
- func (c *ServerConfig) IsDiscoveryFailureModeGraceful() bool
- func (c *ServerConfig) IsDiscoveryFailureModeStrict() bool
- func (c *ServerConfig) IsGRPCEnabled() bool
- func (c *ServerConfig) IsHTTPEnabled() bool
- func (c *ServerConfig) SetDefaults()
- func (c *ServerConfig) Validate() error
- type ServerError
- func ErrConfigInvalid(message string) *ServerError
- func ErrConfigInvalidWithCause(message string, cause error) *ServerError
- func ErrDependencyFailed(message string) *ServerError
- func ErrDependencyFailedWithCause(message string, cause error) *ServerError
- func ErrDiscoveryFailed(message string) *ServerError
- func ErrDiscoveryFailedWithCause(message string, cause error) *ServerError
- func ErrLifecycleFailed(message string) *ServerError
- func ErrLifecycleFailedWithCause(message string, cause error) *ServerError
- func ErrMiddlewareFailed(message string) *ServerError
- func ErrMiddlewareFailedWithCause(message string, cause error) *ServerError
- func ErrServerAlreadyStarted() *ServerError
- func ErrServerNotStarted() *ServerError
- func ErrServiceRegFailed(message string) *ServerError
- func ErrServiceRegFailedWithCause(message string, cause error) *ServerError
- func ErrShutdownTimeout(message string) *ServerError
- func ErrShutdownTimeoutWithCause(message string, cause error) *ServerError
- func ErrTransportFailed(message string) *ServerError
- func ErrTransportFailedWithCause(message string, cause error) *ServerError
- func GetServerError(err error) *ServerError
- func NewServerError(code, message string, category ErrorCategory) *ServerError
- func NewServerErrorWithCause(code, message string, category ErrorCategory, cause error) *ServerError
- func NewServerErrorWithDetails(code, message, details string, category ErrorCategory) *ServerError
- func WrapError(err error, code, message string, category ErrorCategory) *ServerError
- type ServerLogger
- func (sl *ServerLogger) GetUnderlyingLogger() *zap.Logger
- func (sl *ServerLogger) LogDebug(message string, fields ...zap.Field)
- func (sl *ServerLogger) LogDependencyInitialized(dependencyName string)
- func (sl *ServerLogger) LogDiscoveryDeregistered(discoveryService string, endpointCount int)
- func (sl *ServerLogger) LogDiscoveryRegistered(discoveryService string, endpointCount int)
- func (sl *ServerLogger) LogError(message string, err error, fields ...zap.Field)
- func (sl *ServerLogger) LogInfo(message string, fields ...zap.Field)
- func (sl *ServerLogger) LogMiddlewareConfigured(middlewareName string, enabled bool)
- func (sl *ServerLogger) LogServerShutdownFailed(err error, shutdownDuration time.Duration)
- func (sl *ServerLogger) LogServerStarted(httpAddr, grpcAddr string, startupDuration time.Duration)
- func (sl *ServerLogger) LogServerStarting()
- func (sl *ServerLogger) LogServerStartupFailed(err error, phase string, startupDuration time.Duration)
- func (sl *ServerLogger) LogServerStopped(shutdownDuration time.Duration)
- func (sl *ServerLogger) LogServerStopping()
- func (sl *ServerLogger) LogServiceRegistered(serviceName, serviceType string)
- func (sl *ServerLogger) LogTransportInitialized(transportType, address string)
- func (sl *ServerLogger) LogTransportStarted(transportType, address string)
- func (sl *ServerLogger) LogTransportStopped(transportType string, shutdownDuration time.Duration)
- func (sl *ServerLogger) LogWarning(message string, fields ...zap.Field)
- func (sl *ServerLogger) Sync() error
- func (sl *ServerLogger) WithContext(ctx context.Context) *ServerLogger
- func (sl *ServerLogger) WithFields(fields ...zap.Field) *ServerLogger
- type ServerLoggerWithHooks
- func (slh *ServerLoggerWithHooks) AddHook(level LogLevel, hook LoggingHook)
- func (slh *ServerLoggerWithHooks) LogDebug(message string, fields ...zap.Field)
- func (slh *ServerLoggerWithHooks) LogError(message string, err error, fields ...zap.Field)
- func (slh *ServerLoggerWithHooks) LogInfo(message string, fields ...zap.Field)
- func (slh *ServerLoggerWithHooks) LogWarning(message string, fields ...zap.Field)
- type ServerMetrics
- func (sm *ServerMetrics) GetCollector() MetricsCollector
- func (sm *ServerMetrics) RecordError(errorType, operation string)
- func (sm *ServerMetrics) RecordOperationDuration(operation string, duration time.Duration)
- func (sm *ServerMetrics) RecordServerStart()
- func (sm *ServerMetrics) RecordServerStop()
- func (sm *ServerMetrics) RecordServiceRegistration(serviceName, serviceType string)
- func (sm *ServerMetrics) RecordTransportStart(transportType string)
- func (sm *ServerMetrics) RecordTransportStop(transportType string)
- type ServerPerformanceMetrics
- type ServerStatus
- type ServiceDiscoveryManager
- type ServiceNamingPattern
- type ServiceRegistration
- func CreateGRPCServiceRegistration(serviceName, address string, port int, tags []string) *ServiceRegistration
- func CreateHTTPServiceRegistration(serviceName, address string, port int, tags []string) *ServiceRegistration
- func CreateServiceRegistrations(config *ServerConfig) []*ServiceRegistration
- func GetServicesByPort(registrations []*ServiceRegistration, port int) []*ServiceRegistration
- func GetServicesByProtocol(registrations []*ServiceRegistration, protocol string) []*ServiceRegistration
- type ServiceRegistrationBatch
- type ServiceRegistrationHelper
- type ServiceSpecificMiddlewareConfig
- type SimpleBusinessDependencyContainer
- func (c *SimpleBusinessDependencyContainer) Close() error
- func (c *SimpleBusinessDependencyContainer) GetDependencyMetadata(name string) (*DependencyMetadata, error)
- func (c *SimpleBusinessDependencyContainer) GetDependencyNames() []string
- func (c *SimpleBusinessDependencyContainer) GetService(name string) (interface{}, error)
- func (c *SimpleBusinessDependencyContainer) Initialize(ctx context.Context) error
- func (c *SimpleBusinessDependencyContainer) IsClosed() bool
- func (c *SimpleBusinessDependencyContainer) IsInitialized() bool
- func (c *SimpleBusinessDependencyContainer) RegisterInstance(name string, instance interface{}) error
- func (c *SimpleBusinessDependencyContainer) RegisterSingleton(name string, factory DependencyFactory) error
- func (c *SimpleBusinessDependencyContainer) RegisterTransient(name string, factory DependencyFactory) error
- type SimpleMetricsCollector
- func (smc *SimpleMetricsCollector) AddToCounter(name string, value float64, labels map[string]string)
- func (smc *SimpleMetricsCollector) DecrementGauge(name string, labels map[string]string)
- func (smc *SimpleMetricsCollector) GetMetric(name string) (*Metric, bool)
- func (smc *SimpleMetricsCollector) GetMetrics() []Metric
- func (smc *SimpleMetricsCollector) IncrementCounter(name string, labels map[string]string)
- func (smc *SimpleMetricsCollector) IncrementGauge(name string, labels map[string]string)
- func (smc *SimpleMetricsCollector) ObserveHistogram(name string, value float64, labels map[string]string)
- func (smc *SimpleMetricsCollector) Reset()
- func (smc *SimpleMetricsCollector) SetGauge(name string, value float64, labels map[string]string)
- type StandardConfigDefaults
- type SystemInfo
- type TemplateRegistry
- func (r *TemplateRegistry) CreateConfigFromTemplate(templateName string, params map[string]interface{}) (*ServerConfig, error)
- func (r *TemplateRegistry) GetAllTemplates() map[string]ConfigTemplate
- func (r *TemplateRegistry) GetTemplate(name string) (ConfigTemplate, bool)
- func (r *TemplateRegistry) GetTemplateNames() []string
- func (r *TemplateRegistry) RegisterTemplate(template ConfigTemplate)
- type TestServiceTemplate
- type TimeoutConfig
- type TransportManager
- type TransportStatus
- type WebAPITemplate
Constants ¶
const ( ErrCodeConfigInvalid = "CONFIG_INVALID" ErrCodeTransportFailed = "TRANSPORT_FAILED" ErrCodeServiceRegFailed = "SERVICE_REGISTRATION_FAILED" ErrCodeDiscoveryFailed = "DISCOVERY_FAILED" ErrCodeShutdownTimeout = "SHUTDOWN_TIMEOUT" ErrCodeDependencyFailed = "DEPENDENCY_FAILED" ErrCodeLifecycleFailed = "LIFECYCLE_FAILED" ErrCodeMiddlewareFailed = "MIDDLEWARE_FAILED" ErrCodeServerAlreadyStarted = "SERVER_ALREADY_STARTED" ErrCodeServerNotStarted = "SERVER_NOT_STARTED" )
Server error codes as defined in the design document
Variables ¶
This section is empty.
Functions ¶
func GenerateServiceName ¶
func GenerateServiceName(baseName string, protocol string, port int, pattern ServiceNamingPattern) string
GenerateServiceName generates a service name based on the naming pattern
func GetErrorContext ¶
GetErrorContext retrieves context information from a server error
func GetServiceEndpointInfo ¶
func GetServiceEndpointInfo(registrations []*ServiceRegistration) map[string]interface{}
GetServiceEndpointInfo returns detailed endpoint information for a service
func IsErrorCategory ¶
func IsErrorCategory(err error, category ErrorCategory) bool
IsErrorCategory checks if an error belongs to a specific category
func IsErrorCode ¶
IsErrorCode checks if an error has a specific error code
func IsServerError ¶
IsServerError checks if an error is a ServerError
func PerformanceLoggingHook ¶
func PerformanceLoggingHook(event string, metrics *PerformanceMetrics)
PerformanceLoggingHook creates a hook that logs performance events
func PerformanceMetricsCollectionHook ¶
func PerformanceMetricsCollectionHook(event string, metrics *PerformanceMetrics)
PerformanceMetricsCollectionHook creates a hook that triggers metrics collection
func PerformanceThresholdViolationHook ¶
func PerformanceThresholdViolationHook(event string, metrics *PerformanceMetrics)
PerformanceThresholdViolationHook creates a hook that logs threshold violations
func ValidateServiceRegistrations ¶
func ValidateServiceRegistrations(registrations []*ServiceRegistration) error
ValidateServiceRegistrations validates that service registrations are properly configured
Types ¶
type AuthServiceTemplate ¶
AuthServiceTemplate provides a template for authentication services
func (*AuthServiceTemplate) Build ¶
func (t *AuthServiceTemplate) Build() *ServerConfig
func (*AuthServiceTemplate) GetDescription ¶
func (t *AuthServiceTemplate) GetDescription() string
func (*AuthServiceTemplate) GetName ¶
func (t *AuthServiceTemplate) GetName() string
type BusinessDependencyContainer ¶
type BusinessDependencyContainer interface {
// Close closes all managed dependencies and cleans up resources
Close() error
// GetService retrieves a service by name from the container
GetService(name string) (interface{}, error)
}
BusinessDependencyContainer defines the interface for dependency injection containers It provides access to service dependencies and manages their lifecycle
type BusinessDependencyContainerBuilder ¶
type BusinessDependencyContainerBuilder struct {
// contains filtered or unexported fields
}
BusinessDependencyContainerBuilder provides a fluent interface for building dependency containers
func NewBusinessDependencyContainerBuilder ¶
func NewBusinessDependencyContainerBuilder() *BusinessDependencyContainerBuilder
NewBusinessDependencyContainerBuilder creates a new BusinessDependencyContainerBuilder
func (*BusinessDependencyContainerBuilder) AddInstance ¶
func (b *BusinessDependencyContainerBuilder) AddInstance(name string, instance interface{}) *BusinessDependencyContainerBuilder
AddInstance adds a pre-created instance to the container being built
func (*BusinessDependencyContainerBuilder) AddSingleton ¶
func (b *BusinessDependencyContainerBuilder) AddSingleton(name string, factory DependencyFactory) *BusinessDependencyContainerBuilder
AddSingleton adds a singleton dependency to the container being built
func (*BusinessDependencyContainerBuilder) AddTransient ¶
func (b *BusinessDependencyContainerBuilder) AddTransient(name string, factory DependencyFactory) *BusinessDependencyContainerBuilder
AddTransient adds a transient dependency to the container being built
func (*BusinessDependencyContainerBuilder) Build ¶
func (b *BusinessDependencyContainerBuilder) Build() BusinessDependencyContainer
Build returns the built dependency container
type BusinessDependencyRegistry ¶
type BusinessDependencyRegistry interface {
BusinessDependencyContainer
// Initialize initializes all registered dependencies
Initialize(ctx context.Context) error
// RegisterSingleton registers a singleton dependency
RegisterSingleton(name string, factory DependencyFactory) error
// RegisterTransient registers a transient dependency
RegisterTransient(name string, factory DependencyFactory) error
// RegisterInstance registers a pre-created instance
RegisterInstance(name string, instance interface{}) error
// GetDependencyNames returns all registered dependency names
GetDependencyNames() []string
// IsInitialized returns true if the container has been initialized
IsInitialized() bool
// IsClosed returns true if the container has been closed
IsClosed() bool
}
BusinessDependencyRegistry extends BusinessDependencyContainer with additional functionality for registration and lifecycle management
type BusinessGRPCService ¶
type BusinessGRPCService interface {
// RegisterGRPC registers the gRPC service with the provided server
RegisterGRPC(server interface{}) error
// GetServiceName returns the service name for identification
GetServiceName() string
}
BusinessGRPCService defines the interface for gRPC service implementations
type BusinessHTTPHandler ¶
type BusinessHTTPHandler interface {
// RegisterRoutes registers HTTP routes with the provided router
RegisterRoutes(router interface{}) error
// GetServiceName returns the service name for identification
GetServiceName() string
}
BusinessHTTPHandler defines the interface for HTTP service handlers
type BusinessHealthCheck ¶
type BusinessHealthCheck interface {
// Check performs the health check and returns the status
Check(ctx context.Context) error
// GetServiceName returns the service name for the health check
GetServiceName() string
}
BusinessHealthCheck defines the interface for service health checks
type BusinessServerCore ¶
type BusinessServerCore interface {
// Start starts the server with all registered services
Start(ctx context.Context) error
// Stop gracefully stops the server
Stop(ctx context.Context) error
// Shutdown performs complete server shutdown with resource cleanup
Shutdown() error
// GetHTTPAddress returns the HTTP server listening address
GetHTTPAddress() string
// GetGRPCAddress returns the gRPC server listening address
GetGRPCAddress() string
// GetTransports returns all registered transports
GetTransports() []transport.NetworkTransport
// GetTransportStatus returns the status of all transports
GetTransportStatus() map[string]TransportStatus
// GetTransportHealth returns health status of all services across all transports
GetTransportHealth(ctx context.Context) map[string]map[string]*types.HealthStatus
}
BusinessServerCore defines the core interface for all server implementations It provides consistent lifecycle management and transport access
type BusinessServerImpl ¶
type BusinessServerImpl struct {
// contains filtered or unexported fields
}
BusinessServerImpl implements the BusinessServerCore interface providing common server functionality
func NewBusinessServerCore ¶
func NewBusinessServerCore(config *ServerConfig, registrar BusinessServiceRegistrar, deps BusinessDependencyContainer) (*BusinessServerImpl, error)
NewBusinessServerCore creates a new base server instance with the provided configuration
func (*BusinessServerImpl) GetGRPCAddress ¶
func (s *BusinessServerImpl) GetGRPCAddress() string
GetGRPCAddress returns the gRPC server listening address
func (*BusinessServerImpl) GetHTTPAddress ¶
func (s *BusinessServerImpl) GetHTTPAddress() string
GetHTTPAddress returns the HTTP server listening address
func (*BusinessServerImpl) GetPerformanceMetrics ¶
func (s *BusinessServerImpl) GetPerformanceMetrics() *PerformanceMetrics
GetPerformanceMetrics returns current performance metrics
func (*BusinessServerImpl) GetPerformanceMonitor ¶
func (s *BusinessServerImpl) GetPerformanceMonitor() *PerformanceMonitor
GetPerformanceMonitor returns the performance monitor instance
func (*BusinessServerImpl) GetTransportHealth ¶
func (s *BusinessServerImpl) GetTransportHealth(ctx context.Context) map[string]map[string]*types.HealthStatus
GetTransportHealth returns health status of all services across all transports
func (*BusinessServerImpl) GetTransportStatus ¶
func (s *BusinessServerImpl) GetTransportStatus() map[string]TransportStatus
GetTransportStatus returns the status of all transports
func (*BusinessServerImpl) GetTransports ¶
func (s *BusinessServerImpl) GetTransports() []transport.NetworkTransport
GetTransports returns all registered transports
func (*BusinessServerImpl) GetUptime ¶
func (s *BusinessServerImpl) GetUptime() time.Duration
GetUptime returns the server uptime
func (*BusinessServerImpl) SetDiscoveryManager ¶
func (s *BusinessServerImpl) SetDiscoveryManager(manager ServiceDiscoveryManager)
SetDiscoveryManager sets the discovery manager (for testing purposes)
func (*BusinessServerImpl) Shutdown ¶
func (s *BusinessServerImpl) Shutdown() error
Shutdown performs complete server shutdown with resource cleanup
type BusinessServerWithPerformance ¶
type BusinessServerWithPerformance interface {
BusinessServerCore
// GetPerformanceMetrics returns current performance metrics
GetPerformanceMetrics() *PerformanceMetrics
// GetUptime returns the server uptime
GetUptime() time.Duration
// GetPerformanceMonitor returns the performance monitor instance
GetPerformanceMonitor() *PerformanceMonitor
}
BusinessServerWithPerformance extends BusinessServerCore with performance monitoring capabilities
type BusinessServiceRegistrar ¶
type BusinessServiceRegistrar interface {
// RegisterServices registers all service handlers with the provided registry
RegisterServices(registry BusinessServiceRegistry) error
}
BusinessServiceRegistrar defines the interface for services to register themselves with the server's transport layer
type BusinessServiceRegistry ¶
type BusinessServiceRegistry interface {
// RegisterBusinessHTTPHandler registers an HTTP service handler
RegisterBusinessHTTPHandler(handler BusinessHTTPHandler) error
// RegisterBusinessGRPCService registers a gRPC service
RegisterBusinessGRPCService(service BusinessGRPCService) error
// RegisterBusinessHealthCheck registers a health check for a service
RegisterBusinessHealthCheck(check BusinessHealthCheck) error
}
BusinessServiceRegistry defines the interface for registering different types of services It abstracts the underlying transport registration mechanisms
type CORSConfig ¶
type CORSConfig struct {
AllowOrigins []string `yaml:"allow_origins" json:"allow_origins"`
AllowMethods []string `yaml:"allow_methods" json:"allow_methods"`
AllowHeaders []string `yaml:"allow_headers" json:"allow_headers"`
ExposeHeaders []string `yaml:"expose_headers" json:"expose_headers"`
AllowCredentials bool `yaml:"allow_credentials" json:"allow_credentials"`
MaxAge int `yaml:"max_age" json:"max_age"`
}
CORSConfig holds CORS middleware configuration
type CommonServicePatterns ¶
type CommonServicePatterns struct{}
CommonServicePatterns provides reusable patterns for service implementations
func NewCommonServicePatterns ¶
func NewCommonServicePatterns() *CommonServicePatterns
NewCommonServicePatterns creates a new instance of common service patterns
func (*CommonServicePatterns) ApplyStandardDefaults ¶
func (p *CommonServicePatterns) ApplyStandardDefaults(config *ServerConfig, defaults StandardConfigDefaults)
ApplyStandardDefaults applies standard configuration defaults to a server config
func (*CommonServicePatterns) CreateDatabaseHealthCheck ¶
func (p *CommonServicePatterns) CreateDatabaseHealthCheck(db *gorm.DB) HealthCheckFunc
CreateDatabaseHealthCheck creates a standard database health check function
func (*CommonServicePatterns) CreateGenericDependencyContainer ¶
func (p *CommonServicePatterns) CreateGenericDependencyContainer( serviceName string, services map[string]interface{}, db *gorm.DB, ) *GenericDependencyContainer
CreateGenericDependencyContainer creates a dependency container with common services
func (*CommonServicePatterns) CreateServiceAvailabilityCheck ¶
func (p *CommonServicePatterns) CreateServiceAvailabilityCheck(service interface{}, serviceName string) HealthCheckFunc
CreateServiceAvailabilityCheck creates a standard service availability check
func (*CommonServicePatterns) SafeCloseDatabase ¶
func (p *CommonServicePatterns) SafeCloseDatabase(db *gorm.DB, serviceName string) error
SafeCloseDatabase safely closes a database connection with error logging
type ConfigBuilder ¶
type ConfigBuilder struct {
// contains filtered or unexported fields
}
ConfigBuilder provides a fluent interface for building server configurations It supports method chaining and provides validation during the build process
func NewConfigBuilder ¶
func NewConfigBuilder() *ConfigBuilder
NewConfigBuilder creates a new ConfigBuilder with default configuration
func NewConfigBuilderFromTemplate ¶
func NewConfigBuilderFromTemplate(template ConfigTemplate) *ConfigBuilder
NewConfigBuilderFromTemplate creates a new ConfigBuilder from a predefined template
func (*ConfigBuilder) Build ¶
func (b *ConfigBuilder) Build() (*ServerConfig, error)
Build builds and validates the configuration
func (*ConfigBuilder) DisableDiscovery ¶
func (b *ConfigBuilder) DisableDiscovery() *ConfigBuilder
DisableDiscovery disables service discovery
func (*ConfigBuilder) DisableGRPC ¶
func (b *ConfigBuilder) DisableGRPC() *ConfigBuilder
DisableGRPC disables gRPC transport
func (*ConfigBuilder) DisableHTTP ¶
func (b *ConfigBuilder) DisableHTTP() *ConfigBuilder
DisableHTTP disables HTTP transport
func (*ConfigBuilder) EnableGRPC ¶
func (b *ConfigBuilder) EnableGRPC() *ConfigBuilder
EnableGRPC enables gRPC transport
func (*ConfigBuilder) EnableHTTP ¶
func (b *ConfigBuilder) EnableHTTP() *ConfigBuilder
EnableHTTP enables HTTP transport
func (*ConfigBuilder) MustBuild ¶
func (b *ConfigBuilder) MustBuild() *ServerConfig
MustBuild builds the configuration and panics on error This is useful for static configuration where errors should not occur
func (*ConfigBuilder) WithAuth ¶
func (b *ConfigBuilder) WithAuth() *ConfigBuilder
WithAuth enables authentication middleware
func (*ConfigBuilder) WithCORS ¶
func (b *ConfigBuilder) WithCORS(allowOrigins []string) *ConfigBuilder
WithCORS enables CORS middleware with optional configuration
func (*ConfigBuilder) WithDiscovery ¶
func (b *ConfigBuilder) WithDiscovery(address, serviceName string, tags []string) *ConfigBuilder
WithDiscovery configures service discovery
func (*ConfigBuilder) WithGRPCHealthService ¶
func (b *ConfigBuilder) WithGRPCHealthService() *ConfigBuilder
WithGRPCHealthService enables gRPC health service
func (*ConfigBuilder) WithGRPCKeepalive ¶
func (b *ConfigBuilder) WithGRPCKeepalive(time, timeout time.Duration) *ConfigBuilder
WithGRPCKeepalive enables gRPC keepalive with custom parameters
func (*ConfigBuilder) WithGRPCPort ¶
func (b *ConfigBuilder) WithGRPCPort(port string) *ConfigBuilder
WithGRPCPort sets the gRPC port
func (*ConfigBuilder) WithGRPCReflection ¶
func (b *ConfigBuilder) WithGRPCReflection() *ConfigBuilder
WithGRPCReflection enables gRPC reflection
func (*ConfigBuilder) WithHTTPPort ¶
func (b *ConfigBuilder) WithHTTPPort(port string) *ConfigBuilder
WithHTTPPort sets the HTTP port
func (*ConfigBuilder) WithLogging ¶
func (b *ConfigBuilder) WithLogging() *ConfigBuilder
WithLogging enables request logging
func (*ConfigBuilder) WithRateLimit ¶
func (b *ConfigBuilder) WithRateLimit(requestsPerSecond, burstSize int) *ConfigBuilder
WithRateLimit enables rate limiting with specified requests per second
func (*ConfigBuilder) WithServiceName ¶
func (b *ConfigBuilder) WithServiceName(name string) *ConfigBuilder
WithServiceName sets the service name
func (*ConfigBuilder) WithShutdownTimeout ¶
func (b *ConfigBuilder) WithShutdownTimeout(timeout time.Duration) *ConfigBuilder
WithShutdownTimeout sets the shutdown timeout
func (*ConfigBuilder) WithTestMode ¶
func (b *ConfigBuilder) WithTestMode(httpTestPort, grpcTestPort string) *ConfigBuilder
WithTestMode enables test mode with optional test ports
func (*ConfigBuilder) WithTimeout ¶
func (b *ConfigBuilder) WithTimeout(timeout time.Duration) *ConfigBuilder
WithTimeout sets request timeout
type ConfigMapperBase ¶
type ConfigMapperBase struct{}
ConfigMapperBase provides common configuration mapping utilities
func NewConfigMapperBase ¶
func NewConfigMapperBase() *ConfigMapperBase
NewConfigMapperBase creates a new base configuration mapper
func (*ConfigMapperBase) SetDefaultDiscoveryConfig ¶
func (m *ConfigMapperBase) SetDefaultDiscoveryConfig(config *ServerConfig, address, serviceName string, tags []string)
SetDefaultDiscoveryConfig sets default service discovery configuration
func (*ConfigMapperBase) SetDefaultGRPCConfig ¶
func (m *ConfigMapperBase) SetDefaultGRPCConfig(config *ServerConfig, port, defaultPort string, enableKeepalive, enableReflection, enableHealthService bool)
SetDefaultGRPCConfig sets default gRPC configuration values
func (*ConfigMapperBase) SetDefaultHTTPConfig ¶
func (m *ConfigMapperBase) SetDefaultHTTPConfig(config *ServerConfig, port, defaultPort string, enableReady bool)
SetDefaultHTTPConfig sets default HTTP configuration values
func (*ConfigMapperBase) SetDefaultMiddlewareConfig ¶
func (m *ConfigMapperBase) SetDefaultMiddlewareConfig(config *ServerConfig, enableCORS, enableAuth, enableRateLimit, enableLogging bool)
SetDefaultMiddlewareConfig sets default middleware configuration
func (*ConfigMapperBase) SetDefaultServerConfig ¶
func (m *ConfigMapperBase) SetDefaultServerConfig(config *ServerConfig, serviceName string)
SetDefaultServerConfig sets common server configuration defaults
type ConfigTemplate ¶
type ConfigTemplate interface {
// Build creates a server configuration from the template
Build() *ServerConfig
// GetName returns the template name
GetName() string
// GetDescription returns the template description
GetDescription() string
}
ConfigTemplate defines an interface for configuration templates
type ConfigValidator ¶
type ConfigValidator interface {
// Validate validates the configuration and returns any errors
Validate() error
// SetDefaults sets default values for unspecified configuration options
SetDefaults()
}
ConfigValidator defines the interface for configuration validation
type DefaultServiceRegistry ¶
type DefaultServiceRegistry struct {
// contains filtered or unexported fields
}
DefaultServiceRegistry implements the ServiceRegistry interface It bridges the server framework with the transport layer
func NewDefaultServiceRegistry ¶
func NewDefaultServiceRegistry(transportManager *transport.TransportCoordinator) *DefaultServiceRegistry
NewDefaultServiceRegistry creates a new service registry with the given transport manager
func (*DefaultServiceRegistry) CheckAllHealth ¶
func (r *DefaultServiceRegistry) CheckAllHealth(ctx context.Context) map[string]*types.HealthStatus
CheckAllHealth performs health checks on all registered services
func (*DefaultServiceRegistry) CreateBusinessHealthCheckEndpoint ¶
func (r *DefaultServiceRegistry) CreateBusinessHealthCheckEndpoint(serviceName string, checkFunc func(ctx context.Context) error) BusinessHealthCheck
CreateHealthCheckEndpoint creates a default health check implementation for a service
func (*DefaultServiceRegistry) GetBusinessGRPCServices ¶
func (r *DefaultServiceRegistry) GetBusinessGRPCServices() []BusinessGRPCService
GetGRPCServices returns all registered gRPC services
func (*DefaultServiceRegistry) GetBusinessHTTPHandlers ¶
func (r *DefaultServiceRegistry) GetBusinessHTTPHandlers() []BusinessHTTPHandler
GetHTTPHandlers returns all registered HTTP handlers
func (*DefaultServiceRegistry) GetBusinessHealthChecks ¶
func (r *DefaultServiceRegistry) GetBusinessHealthChecks() []BusinessHealthCheck
GetHealthChecks returns all registered health checks
func (*DefaultServiceRegistry) GetOverallHealthStatus ¶
func (r *DefaultServiceRegistry) GetOverallHealthStatus(ctx context.Context) *types.HealthStatus
GetOverallHealthStatus aggregates all service health checks into an overall status
func (*DefaultServiceRegistry) GetRegisteredServiceNames ¶
func (r *DefaultServiceRegistry) GetRegisteredServiceNames() []string
GetRegisteredServiceNames returns all registered service names
func (*DefaultServiceRegistry) GetServiceCount ¶
func (r *DefaultServiceRegistry) GetServiceCount() int
GetServiceCount returns the total number of registered services
func (*DefaultServiceRegistry) RegisterBusinessGRPCService ¶
func (r *DefaultServiceRegistry) RegisterBusinessGRPCService(service BusinessGRPCService) error
RegisterGRPCService registers a gRPC service with automatic server binding
func (*DefaultServiceRegistry) RegisterBusinessGRPCServiceWithHealthCheck ¶
func (r *DefaultServiceRegistry) RegisterBusinessGRPCServiceWithHealthCheck(service BusinessGRPCService, healthCheckFunc func(ctx context.Context) error) error
RegisterGRPCServiceWithHealthCheck registers a gRPC service along with its health check
func (*DefaultServiceRegistry) RegisterBusinessHTTPHandler ¶
func (r *DefaultServiceRegistry) RegisterBusinessHTTPHandler(handler BusinessHTTPHandler) error
RegisterHTTPHandler registers an HTTP service handler with automatic route registration
func (*DefaultServiceRegistry) RegisterBusinessHealthCheck ¶
func (r *DefaultServiceRegistry) RegisterBusinessHealthCheck(check BusinessHealthCheck) error
RegisterHealthCheck registers a health check for a service with automatic endpoint creation
func (*DefaultServiceRegistry) RegisterBusinessServiceWithHealthCheck ¶
func (r *DefaultServiceRegistry) RegisterBusinessServiceWithHealthCheck(handler BusinessHTTPHandler, healthCheckFunc func(ctx context.Context) error) error
RegisterServiceWithHealthCheck registers a service along with its health check
type DependencyFactory ¶
type DependencyFactory func(container BusinessDependencyContainer) (interface{}, error)
DependencyFactory defines a function type for creating dependencies
type DependencyLifecycle ¶
type DependencyLifecycle interface {
// Initialize initializes the dependency with the provided context
Initialize(ctx context.Context) error
// Shutdown gracefully shuts down the dependency
Shutdown(ctx context.Context) error
}
DependencyLifecycle defines the lifecycle management interface for dependencies
type DependencyMetadata ¶
type DependencyMetadata struct {
Name string
Type reflect.Type
Singleton bool
Factory DependencyFactory
Instance interface{}
Initialized bool
}
DependencyMetadata holds metadata about a registered dependency
type DependencyStatus ¶
type DependencyStatus struct {
Name string `json:"name"`
Status string `json:"status"`
LastChecked time.Time `json:"last_checked"`
Error string `json:"error,omitempty"`
}
DependencyStatus represents the status of a dependency
type DiscoveryConfig ¶
type DiscoveryConfig struct {
Address string `yaml:"address" json:"address"`
ServiceName string `yaml:"service_name" json:"service_name"`
Tags []string `yaml:"tags" json:"tags"`
Enabled bool `yaml:"enabled" json:"enabled"`
FailureMode DiscoveryFailureMode `yaml:"failure_mode" json:"failure_mode"`
HealthCheckRequired bool `yaml:"health_check_required" json:"health_check_required"`
RegistrationTimeout time.Duration `yaml:"registration_timeout" json:"registration_timeout"`
}
DiscoveryConfig holds service discovery configuration
type DiscoveryFailureMode ¶
type DiscoveryFailureMode string
DiscoveryFailureMode defines how the server should handle service discovery failures
const ( // DiscoveryFailureModeGraceful continues server startup even if discovery registration fails // This is useful for development environments or when discovery is not critical DiscoveryFailureModeGraceful DiscoveryFailureMode = "graceful" // DiscoveryFailureModeFailFast stops server startup if discovery registration fails // This is recommended for production environments where discovery is critical DiscoveryFailureModeFailFast DiscoveryFailureMode = "fail_fast" // DiscoveryFailureModeStrict is similar to fail_fast but also requires discovery to be healthy // before allowing registration. This provides the highest level of reliability. DiscoveryFailureModeStrict DiscoveryFailureMode = "strict" )
type DiscoveryHealthStatus ¶
type DiscoveryHealthStatus struct {
Available bool `json:"available"`
LastCheck time.Time `json:"last_check"`
LastError string `json:"last_error,omitempty"`
ConsecutiveErrors int `json:"consecutive_errors"`
TotalErrors int `json:"total_errors"`
Uptime time.Duration `json:"uptime"`
}
DiscoveryHealthStatus represents the health status of the discovery service
type DiscoveryManagerImpl ¶
type DiscoveryManagerImpl struct {
// contains filtered or unexported fields
}
DiscoveryManagerImpl implements ServiceDiscoveryManager using Consul
func (*DiscoveryManagerImpl) DeregisterMultipleEndpoints ¶
func (d *DiscoveryManagerImpl) DeregisterMultipleEndpoints(ctx context.Context, registrations []*ServiceRegistration) error
DeregisterMultipleEndpoints removes multiple endpoints from discovery
func (*DiscoveryManagerImpl) DeregisterService ¶
func (d *DiscoveryManagerImpl) DeregisterService(ctx context.Context, registration *ServiceRegistration) error
DeregisterService removes a service from discovery
func (*DiscoveryManagerImpl) GetHealthStatus ¶
func (d *DiscoveryManagerImpl) GetHealthStatus() *DiscoveryHealthStatus
GetHealthStatus returns the current health status of the discovery service
func (*DiscoveryManagerImpl) IsDiscoveryAvailable ¶
func (d *DiscoveryManagerImpl) IsDiscoveryAvailable() bool
IsDiscoveryAvailable checks if discovery is available without updating health status
func (*DiscoveryManagerImpl) IsHealthy ¶
func (d *DiscoveryManagerImpl) IsHealthy(ctx context.Context) bool
IsHealthy checks if the discovery service is available
func (*DiscoveryManagerImpl) RegisterMultipleEndpoints ¶
func (d *DiscoveryManagerImpl) RegisterMultipleEndpoints(ctx context.Context, registrations []*ServiceRegistration) error
RegisterMultipleEndpoints registers multiple endpoints for a service
func (*DiscoveryManagerImpl) RegisterService ¶
func (d *DiscoveryManagerImpl) RegisterService(ctx context.Context, registration *ServiceRegistration) error
RegisterService registers a single service with discovery
type ErrorCategory ¶
type ErrorCategory string
ErrorCategory represents different types of server failures
const ( CategoryConfig ErrorCategory = "configuration" CategoryTransport ErrorCategory = "transport" CategoryDiscovery ErrorCategory = "discovery" CategoryDependency ErrorCategory = "dependency" CategoryLifecycle ErrorCategory = "lifecycle" CategoryMiddleware ErrorCategory = "middleware" CategoryService ErrorCategory = "service" )
func GetErrorCategory ¶
func GetErrorCategory(err error) ErrorCategory
GetErrorCategory retrieves the category from a server error
type GRPCConfig ¶
type GRPCConfig struct {
Port string `yaml:"port" json:"port"`
Address string `yaml:"address" json:"address"`
EnableKeepalive bool `yaml:"enable_keepalive" json:"enable_keepalive"`
EnableReflection bool `yaml:"enable_reflection" json:"enable_reflection"`
EnableHealthService bool `yaml:"enable_health_service" json:"enable_health_service"`
Enabled bool `yaml:"enabled" json:"enabled"`
TestMode bool `yaml:"test_mode" json:"test_mode"`
TestPort string `yaml:"test_port" json:"test_port"`
MaxRecvMsgSize int `yaml:"max_recv_msg_size" json:"max_recv_msg_size"`
MaxSendMsgSize int `yaml:"max_send_msg_size" json:"max_send_msg_size"`
KeepaliveParams GRPCKeepaliveParams `yaml:"keepalive_params" json:"keepalive_params"`
KeepalivePolicy GRPCKeepalivePolicy `yaml:"keepalive_policy" json:"keepalive_policy"`
Interceptors GRPCInterceptorConfig `yaml:"interceptors" json:"interceptors"`
TLS GRPCTLSConfig `yaml:"tls" json:"tls"`
}
GRPCConfig holds gRPC transport specific configuration
type GRPCInterceptorConfig ¶
type GRPCInterceptorConfig struct {
EnableAuth bool `yaml:"enable_auth" json:"enable_auth"`
EnableLogging bool `yaml:"enable_logging" json:"enable_logging"`
EnableMetrics bool `yaml:"enable_metrics" json:"enable_metrics"`
EnableRecovery bool `yaml:"enable_recovery" json:"enable_recovery"`
EnableRateLimit bool `yaml:"enable_rate_limit" json:"enable_rate_limit"`
}
GRPCInterceptorConfig holds gRPC interceptor configuration
type GRPCKeepaliveParams ¶
type GRPCKeepaliveParams struct {
MaxConnectionIdle time.Duration `yaml:"max_connection_idle" json:"max_connection_idle"`
MaxConnectionAge time.Duration `yaml:"max_connection_age" json:"max_connection_age"`
MaxConnectionAgeGrace time.Duration `yaml:"max_connection_age_grace" json:"max_connection_age_grace"`
Time time.Duration `yaml:"time" json:"time"`
Timeout time.Duration `yaml:"timeout" json:"timeout"`
}
GRPCKeepaliveParams holds gRPC keepalive parameters
type GRPCKeepalivePolicy ¶
type GRPCKeepalivePolicy struct {
MinTime time.Duration `yaml:"min_time" json:"min_time"`
PermitWithoutStream bool `yaml:"permit_without_stream" json:"permit_without_stream"`
}
GRPCKeepalivePolicy holds gRPC keepalive enforcement policy
type GRPCOnlyTemplate ¶
GRPCOnlyTemplate provides a template for gRPC-only services
func (*GRPCOnlyTemplate) Build ¶
func (t *GRPCOnlyTemplate) Build() *ServerConfig
func (*GRPCOnlyTemplate) GetDescription ¶
func (t *GRPCOnlyTemplate) GetDescription() string
func (*GRPCOnlyTemplate) GetName ¶
func (t *GRPCOnlyTemplate) GetName() string
type GRPCServiceDefinition ¶
type GRPCServiceDefinition struct {
ServiceName string
Registrar GRPCServiceRegistrar
HealthCheckFunc HealthCheckFunc
}
GRPCServiceDefinition defines a gRPC service for batch registration
type GRPCServiceRegistrar ¶
GRPCServiceRegistrar defines the interface for gRPC service registration
type GRPCTLSConfig ¶
type GRPCTLSConfig struct {
Enabled bool `yaml:"enabled" json:"enabled"`
CertFile string `yaml:"cert_file" json:"cert_file"`
KeyFile string `yaml:"key_file" json:"key_file"`
CAFile string `yaml:"ca_file" json:"ca_file"`
ServerName string `yaml:"server_name" json:"server_name"`
}
GRPCTLSConfig holds gRPC TLS configuration
type GenericDependencyContainer ¶
type GenericDependencyContainer struct {
// contains filtered or unexported fields
}
GenericDependencyContainer provides a generic dependency container implementation
func NewGenericDependencyContainer ¶
func NewGenericDependencyContainer(closeFunc func() error) *GenericDependencyContainer
NewGenericDependencyContainer creates a new generic dependency container
func (*GenericDependencyContainer) Close ¶
func (d *GenericDependencyContainer) Close() error
Close closes the dependency container and cleans up resources
func (*GenericDependencyContainer) GetService ¶
func (d *GenericDependencyContainer) GetService(name string) (interface{}, error)
GetService retrieves a service by name from the container
func (*GenericDependencyContainer) RegisterService ¶
func (d *GenericDependencyContainer) RegisterService(name string, service interface{})
RegisterService registers a service with the container
type GenericGRPCService ¶
type GenericGRPCService struct {
// contains filtered or unexported fields
}
GenericGRPCService provides a generic adapter for gRPC services
func NewGenericGRPCService ¶
func NewGenericGRPCService(serviceName string, registrar GRPCServiceRegistrar) *GenericGRPCService
NewGenericGRPCService creates a new generic gRPC service adapter
func (*GenericGRPCService) GetServiceName ¶
func (s *GenericGRPCService) GetServiceName() string
GetServiceName returns the service name for identification
func (*GenericGRPCService) RegisterGRPC ¶
func (s *GenericGRPCService) RegisterGRPC(server interface{}) error
RegisterGRPC registers the gRPC service with the provided server
type GenericHTTPHandler ¶
type GenericHTTPHandler struct {
// contains filtered or unexported fields
}
GenericHTTPHandler provides a generic adapter for HTTP handlers
func NewGenericHTTPHandler ¶
func NewGenericHTTPHandler(serviceName string, registrar HTTPHandlerRegistrar) *GenericHTTPHandler
NewGenericHTTPHandler creates a new generic HTTP handler adapter
func (*GenericHTTPHandler) GetServiceName ¶
func (h *GenericHTTPHandler) GetServiceName() string
GetServiceName returns the service name for identification
func (*GenericHTTPHandler) RegisterRoutes ¶
func (h *GenericHTTPHandler) RegisterRoutes(router interface{}) error
RegisterRoutes registers HTTP routes with the provided router
type GenericHealthCheck ¶
type GenericHealthCheck struct {
// contains filtered or unexported fields
}
GenericHealthCheck provides a generic health check implementation
func NewGenericHealthCheck ¶
func NewGenericHealthCheck(serviceName string, checkFunc HealthCheckFunc) *GenericHealthCheck
NewGenericHealthCheck creates a new generic health check
func (*GenericHealthCheck) Check ¶
func (h *GenericHealthCheck) Check(ctx context.Context) error
Check performs the health check and returns the status
func (*GenericHealthCheck) GetServiceName ¶
func (h *GenericHealthCheck) GetServiceName() string
GetServiceName returns the service name for the health check
func (*GenericHealthCheck) GetUptime ¶
func (h *GenericHealthCheck) GetUptime() time.Duration
GetUptime returns the uptime since the health check was created
type HTTPConfig ¶
type HTTPConfig struct {
Port string `yaml:"port" json:"port"`
Address string `yaml:"address" json:"address"`
EnableReady bool `yaml:"enable_ready" json:"enable_ready"`
Enabled bool `yaml:"enabled" json:"enabled"`
TestMode bool `yaml:"test_mode" json:"test_mode"`
TestPort string `yaml:"test_port" json:"test_port"`
Middleware HTTPMiddleware `yaml:"middleware" json:"middleware"`
ReadTimeout time.Duration `yaml:"read_timeout" json:"read_timeout"`
WriteTimeout time.Duration `yaml:"write_timeout" json:"write_timeout"`
IdleTimeout time.Duration `yaml:"idle_timeout" json:"idle_timeout"`
Headers map[string]string `yaml:"headers" json:"headers"`
}
HTTPConfig holds HTTP transport specific configuration
type HTTPHandlerRegistrar ¶
HTTPHandlerRegistrar defines the interface for HTTP route registration
type HTTPMiddleware ¶
type HTTPMiddleware struct {
EnableCORS bool `yaml:"enable_cors" json:"enable_cors"`
EnableAuth bool `yaml:"enable_auth" json:"enable_auth"`
EnableRateLimit bool `yaml:"enable_rate_limit" json:"enable_rate_limit"`
EnableLogging bool `yaml:"enable_logging" json:"enable_logging"`
EnableTimeout bool `yaml:"enable_timeout" json:"enable_timeout"`
CORSConfig CORSConfig `yaml:"cors" json:"cors"`
RateLimitConfig RateLimitConfig `yaml:"rate_limit" json:"rate_limit"`
TimeoutConfig TimeoutConfig `yaml:"timeout" json:"timeout"`
CustomHeaders map[string]string `yaml:"custom_headers" json:"custom_headers"`
}
HTTPMiddleware holds HTTP-specific middleware configuration
type HTTPMiddlewareFunc ¶
HTTPMiddlewareFunc represents an HTTP middleware function
type HTTPOnlyTemplate ¶
HTTPOnlyTemplate provides a template for HTTP-only services
func (*HTTPOnlyTemplate) Build ¶
func (t *HTTPOnlyTemplate) Build() *ServerConfig
func (*HTTPOnlyTemplate) GetDescription ¶
func (t *HTTPOnlyTemplate) GetDescription() string
func (*HTTPOnlyTemplate) GetName ¶
func (t *HTTPOnlyTemplate) GetName() string
type HTTPServiceDefinition ¶
type HTTPServiceDefinition struct {
ServiceName string
Registrar HTTPHandlerRegistrar
HealthCheckFunc HealthCheckFunc
}
HTTPServiceDefinition defines an HTTP service for batch registration
type HealthCheckFunc ¶
HealthCheckFunc defines a function type for health checks
func ServiceAvailabilityChecker ¶
func ServiceAvailabilityChecker(service interface{}) HealthCheckFunc
ServiceAvailabilityChecker creates a health check function that verifies service availability
type HealthCheckInfo ¶
type HealthCheckInfo struct {
HTTP string `json:"http,omitempty"`
GRPC string `json:"grpc,omitempty"`
Interval time.Duration `json:"interval"`
Timeout time.Duration `json:"timeout"`
DeregisterCriticalServiceAfter time.Duration `json:"deregister_critical_service_after"`
}
HealthCheckInfo represents health check configuration for service discovery
type LifecycleManager ¶
type LifecycleManager struct {
// contains filtered or unexported fields
}
LifecycleManager manages the server startup and shutdown sequences
func NewLifecycleManager ¶
func NewLifecycleManager(serviceName string, config *ServerConfig) *LifecycleManager
NewLifecycleManager creates a new lifecycle manager
func (*LifecycleManager) GetCurrentPhase ¶
func (lm *LifecycleManager) GetCurrentPhase() LifecyclePhase
GetCurrentPhase returns the current lifecycle phase
func (*LifecycleManager) IsStarted ¶
func (lm *LifecycleManager) IsStarted() bool
IsStarted returns true if the server is in started state
func (*LifecycleManager) IsStopped ¶
func (lm *LifecycleManager) IsStopped() bool
IsStopped returns true if the server is in stopped state
func (*LifecycleManager) IsStopping ¶
func (lm *LifecycleManager) IsStopping() bool
IsStopping returns true if the server is currently stopping
func (*LifecycleManager) SetDependencies ¶
func (lm *LifecycleManager) SetDependencies(deps BusinessDependencyContainer)
SetDependencies sets the dependency container for lifecycle management
func (*LifecycleManager) SetServiceDiscovery ¶
func (lm *LifecycleManager) SetServiceDiscovery(sd *discovery.ServiceDiscovery)
SetServiceDiscovery sets the service discovery client for lifecycle management
func (*LifecycleManager) SetTransportManager ¶
func (lm *LifecycleManager) SetTransportManager(tm TransportManager)
SetTransportManager sets the transport manager for lifecycle management
func (*LifecycleManager) ShutdownSequence ¶
func (lm *LifecycleManager) ShutdownSequence(ctx context.Context) error
ShutdownSequence executes the complete server shutdown sequence Order: discovery deregistration → transports shutdown → dependencies cleanup
func (*LifecycleManager) StartupSequence ¶
func (lm *LifecycleManager) StartupSequence(ctx context.Context) error
StartupSequence executes the complete server startup sequence Order: dependencies → transports → service registration → discovery registration
type LifecyclePhase ¶
type LifecyclePhase int
LifecyclePhase represents different phases of server lifecycle
const ( PhaseUninitialized LifecyclePhase = iota PhaseDependenciesInitialized PhaseTransportsInitialized PhaseServicesRegistered PhaseDiscoveryRegistered PhaseStarted PhaseStopping PhaseStopped )
func (LifecyclePhase) String ¶
func (p LifecyclePhase) String() string
String returns the string representation of the lifecycle phase
type LoggingConfig ¶
type LoggingConfig struct {
Level LogLevel `yaml:"level" json:"level"`
EnableStacktrace bool `yaml:"enable_stacktrace" json:"enable_stacktrace"`
EnableCaller bool `yaml:"enable_caller" json:"enable_caller"`
EnableTimestamp bool `yaml:"enable_timestamp" json:"enable_timestamp"`
Format string `yaml:"format" json:"format"` // "json" or "console"
}
LoggingConfig represents the logging configuration for the server
func DefaultLoggingConfig ¶
func DefaultLoggingConfig() *LoggingConfig
DefaultLoggingConfig returns the default logging configuration
type LoggingHook ¶
LoggingHook represents a function that can be called on specific logging events
type Metric ¶
type Metric struct {
Name string `json:"name"`
Type MetricType `json:"type"`
Value interface{} `json:"value"`
Labels map[string]string `json:"labels,omitempty"`
Description string `json:"description,omitempty"`
Timestamp time.Time `json:"timestamp"`
}
Metric represents a single metric with its metadata
type MetricType ¶
type MetricType string
MetricType represents different types of metrics
const ( MetricTypeCounter MetricType = "counter" MetricTypeGauge MetricType = "gauge" MetricTypeHistogram MetricType = "histogram" MetricTypeSummary MetricType = "summary" )
type MetricsCollector ¶
type MetricsCollector interface {
// Counter operations
IncrementCounter(name string, labels map[string]string)
AddToCounter(name string, value float64, labels map[string]string)
// Gauge operations
SetGauge(name string, value float64, labels map[string]string)
IncrementGauge(name string, labels map[string]string)
DecrementGauge(name string, labels map[string]string)
// Histogram operations
ObserveHistogram(name string, value float64, labels map[string]string)
// Metric retrieval
GetMetrics() []Metric
GetMetric(name string) (*Metric, bool)
// Cleanup
Reset()
}
MetricsCollector defines the interface for collecting metrics
type MicroserviceTemplate ¶
MicroserviceTemplate provides a template for general microservices
func (*MicroserviceTemplate) Build ¶
func (t *MicroserviceTemplate) Build() *ServerConfig
func (*MicroserviceTemplate) GetDescription ¶
func (t *MicroserviceTemplate) GetDescription() string
func (*MicroserviceTemplate) GetName ¶
func (t *MicroserviceTemplate) GetName() string
type MiddlewareConfig ¶
type MiddlewareConfig struct {
EnableCORS bool `yaml:"enable_cors" json:"enable_cors"`
EnableAuth bool `yaml:"enable_auth" json:"enable_auth"`
EnableRateLimit bool `yaml:"enable_rate_limit" json:"enable_rate_limit"`
EnableLogging bool `yaml:"enable_logging" json:"enable_logging"`
}
MiddlewareConfig holds middleware configuration flags
type MiddlewareManager ¶
type MiddlewareManager struct {
// contains filtered or unexported fields
}
MiddlewareManager manages middleware registration and configuration for both HTTP and gRPC transports
func NewMiddlewareManager ¶
func NewMiddlewareManager(config *ServerConfig) *MiddlewareManager
NewMiddlewareManager creates a new middleware manager with the given configuration
func (*MiddlewareManager) ApplyServiceSpecificMiddleware ¶
func (m *MiddlewareManager) ApplyServiceSpecificMiddleware(config ServiceSpecificMiddlewareConfig)
ApplyServiceSpecificMiddleware applies service-specific middleware configuration
func (*MiddlewareManager) ConfigureHTTPMiddleware ¶
func (m *MiddlewareManager) ConfigureHTTPMiddleware(router *gin.Engine) error
ConfigureHTTPMiddleware configures HTTP middleware based on the server configuration
func (*MiddlewareManager) GetGRPCInterceptors ¶
func (m *MiddlewareManager) GetGRPCInterceptors() ([]grpc.UnaryServerInterceptor, []grpc.StreamServerInterceptor)
GetGRPCInterceptors returns configured gRPC interceptors based on server configuration
func (*MiddlewareManager) RegisterGRPCStreamInterceptor ¶
func (m *MiddlewareManager) RegisterGRPCStreamInterceptor(interceptor grpc.StreamServerInterceptor)
RegisterGRPCStreamInterceptor registers a gRPC stream interceptor
func (*MiddlewareManager) RegisterGRPCUnaryInterceptor ¶
func (m *MiddlewareManager) RegisterGRPCUnaryInterceptor(interceptor grpc.UnaryServerInterceptor)
RegisterGRPCUnaryInterceptor registers a gRPC unary interceptor
func (*MiddlewareManager) RegisterHTTPMiddleware ¶
func (m *MiddlewareManager) RegisterHTTPMiddleware(middleware HTTPMiddlewareFunc)
RegisterHTTPMiddleware registers an HTTP middleware function
type NoOpDiscoveryManager ¶
type NoOpDiscoveryManager struct{}
NoOpDiscoveryManager is a no-op implementation for when discovery is disabled
func (*NoOpDiscoveryManager) DeregisterMultipleEndpoints ¶
func (n *NoOpDiscoveryManager) DeregisterMultipleEndpoints(ctx context.Context, registrations []*ServiceRegistration) error
func (*NoOpDiscoveryManager) DeregisterService ¶
func (n *NoOpDiscoveryManager) DeregisterService(ctx context.Context, registration *ServiceRegistration) error
func (*NoOpDiscoveryManager) GetHealthStatus ¶
func (n *NoOpDiscoveryManager) GetHealthStatus() *DiscoveryHealthStatus
GetHealthStatus returns a healthy status for no-op manager
func (*NoOpDiscoveryManager) IsDiscoveryAvailable ¶
func (n *NoOpDiscoveryManager) IsDiscoveryAvailable() bool
IsDiscoveryAvailable always returns true for no-op manager
func (*NoOpDiscoveryManager) IsHealthy ¶
func (n *NoOpDiscoveryManager) IsHealthy(ctx context.Context) bool
func (*NoOpDiscoveryManager) RegisterMultipleEndpoints ¶
func (n *NoOpDiscoveryManager) RegisterMultipleEndpoints(ctx context.Context, registrations []*ServiceRegistration) error
func (*NoOpDiscoveryManager) RegisterService ¶
func (n *NoOpDiscoveryManager) RegisterService(ctx context.Context, registration *ServiceRegistration) error
type ObservabilityManager ¶
type ObservabilityManager struct {
// contains filtered or unexported fields
}
ObservabilityManager manages observability features for the server
func NewObservabilityManager ¶
func NewObservabilityManager(serviceName string, collector MetricsCollector) *ObservabilityManager
NewObservabilityManager creates a new observability manager
func (*ObservabilityManager) GetMetrics ¶
func (om *ObservabilityManager) GetMetrics() *ServerMetrics
GetMetrics returns the metrics collector
func (*ObservabilityManager) GetServerStatus ¶
func (om *ObservabilityManager) GetServerStatus(server BusinessServerCore) *ServerStatus
GetServerStatus returns comprehensive server status
func (*ObservabilityManager) RegisterDebugEndpoints ¶
func (om *ObservabilityManager) RegisterDebugEndpoints(router *gin.Engine, server BusinessServerCore)
RegisterDebugEndpoints registers debugging endpoints with the HTTP router
func (*ObservabilityManager) RegisterHealthEndpoint ¶
func (om *ObservabilityManager) RegisterHealthEndpoint(router *gin.Engine, server BusinessServerCore)
RegisterHealthEndpoint registers a comprehensive health check endpoint
func (*ObservabilityManager) SetBuildInfo ¶
func (om *ObservabilityManager) SetBuildInfo(info map[string]string)
SetBuildInfo sets build information
func (*ObservabilityManager) SetVersion ¶
func (om *ObservabilityManager) SetVersion(version string)
SetVersion sets the service version
type PerformanceHook ¶
type PerformanceHook func(event string, metrics *PerformanceMetrics)
PerformanceHook defines a callback function for performance events
type PerformanceMetrics ¶
type PerformanceMetrics struct {
// Timing metrics
StartupTime time.Duration `json:"startup_time"`
ShutdownTime time.Duration `json:"shutdown_time"`
Uptime time.Duration `json:"uptime"`
// Resource metrics
MemoryUsage uint64 `json:"memory_usage"`
GoroutineCount int `json:"goroutine_count"`
CPUUsage float64 `json:"cpu_usage"`
// Service metrics
ServiceCount int `json:"service_count"`
TransportCount int `json:"transport_count"`
// Operation counters
StartCount int64 `json:"start_count"`
StopCount int64 `json:"stop_count"`
RequestCount int64 `json:"request_count"`
ErrorCount int64 `json:"error_count"`
// Performance thresholds
MaxStartupTime time.Duration `json:"max_startup_time"`
MaxShutdownTime time.Duration `json:"max_shutdown_time"`
MaxMemoryUsage uint64 `json:"max_memory_usage"`
// Timestamp
LastUpdated time.Time `json:"last_updated"`
// contains filtered or unexported fields
}
PerformanceMetrics holds comprehensive performance metrics for a server
func NewPerformanceMetrics ¶
func NewPerformanceMetrics() *PerformanceMetrics
NewPerformanceMetrics creates a new performance metrics instance with default thresholds
func (*PerformanceMetrics) CheckThresholds ¶
func (m *PerformanceMetrics) CheckThresholds() []string
CheckThresholds checks if any performance thresholds are exceeded
func (*PerformanceMetrics) GetSnapshot ¶
func (m *PerformanceMetrics) GetSnapshot() PerformanceSnapshot
GetSnapshot returns a thread-safe snapshot of the current metrics
func (*PerformanceMetrics) IncrementErrorCount ¶
func (m *PerformanceMetrics) IncrementErrorCount()
IncrementErrorCount atomically increments the error counter
func (*PerformanceMetrics) IncrementRequestCount ¶
func (m *PerformanceMetrics) IncrementRequestCount()
IncrementRequestCount atomically increments the request counter
func (*PerformanceMetrics) RecordMemoryUsage ¶
func (m *PerformanceMetrics) RecordMemoryUsage()
RecordMemoryUsage records current memory usage and goroutine count
func (*PerformanceMetrics) RecordServiceMetrics ¶
func (m *PerformanceMetrics) RecordServiceMetrics(serviceCount, transportCount int)
RecordServiceMetrics records service and transport counts
func (*PerformanceMetrics) RecordShutdownTime ¶
func (m *PerformanceMetrics) RecordShutdownTime(duration time.Duration)
RecordShutdownTime records the server shutdown time and increments stop counter
func (*PerformanceMetrics) RecordStartupTime ¶
func (m *PerformanceMetrics) RecordStartupTime(duration time.Duration)
RecordStartupTime records the server startup time and increments start counter
func (*PerformanceMetrics) RecordUptime ¶
func (m *PerformanceMetrics) RecordUptime(uptime time.Duration)
RecordUptime records the current uptime
func (*PerformanceMetrics) String ¶
func (m *PerformanceMetrics) String() string
String returns a string representation of the metrics
type PerformanceMonitor ¶
type PerformanceMonitor struct {
// contains filtered or unexported fields
}
PerformanceMonitor provides monitoring hooks and profiling capabilities
func NewPerformanceMonitor ¶
func NewPerformanceMonitor() *PerformanceMonitor
NewPerformanceMonitor creates a new performance monitor
func (*PerformanceMonitor) AddHook ¶
func (pm *PerformanceMonitor) AddHook(hook PerformanceHook)
AddHook adds a performance monitoring hook
func (*PerformanceMonitor) Disable ¶
func (pm *PerformanceMonitor) Disable()
Disable disables performance monitoring
func (*PerformanceMonitor) Enable ¶
func (pm *PerformanceMonitor) Enable()
Enable enables performance monitoring
func (*PerformanceMonitor) GetMetrics ¶
func (pm *PerformanceMonitor) GetMetrics() *PerformanceMetrics
GetMetrics returns the current performance metrics
func (*PerformanceMonitor) IsEnabled ¶
func (pm *PerformanceMonitor) IsEnabled() bool
IsEnabled returns whether performance monitoring is enabled
func (*PerformanceMonitor) ProfileOperation ¶
func (pm *PerformanceMonitor) ProfileOperation(name string, operation func() error) error
ProfileOperation profiles a function execution and records metrics
func (*PerformanceMonitor) RecordEvent ¶
func (pm *PerformanceMonitor) RecordEvent(event string)
RecordEvent records a performance event and triggers hooks
func (*PerformanceMonitor) RemoveAllHooks ¶
func (pm *PerformanceMonitor) RemoveAllHooks()
RemoveAllHooks removes all performance monitoring hooks
func (*PerformanceMonitor) StartPeriodicCollection ¶
func (pm *PerformanceMonitor) StartPeriodicCollection(ctx context.Context, interval time.Duration)
StartPeriodicCollection starts periodic collection of performance metrics
type PerformanceOptimizations ¶
type PerformanceOptimizations struct{}
PerformanceOptimizations provides performance optimization utilities
func NewPerformanceOptimizations ¶
func NewPerformanceOptimizations() *PerformanceOptimizations
NewPerformanceOptimizations creates a new performance optimizations instance
func (*PerformanceOptimizations) OptimizeGORMConnection ¶
func (p *PerformanceOptimizations) OptimizeGORMConnection(db *gorm.DB) error
OptimizeGORMConnection optimizes GORM database connection settings
func (*PerformanceOptimizations) PreallocateSlices ¶
func (p *PerformanceOptimizations) PreallocateSlices() map[string]interface{}
PreallocateSlices provides utilities for preallocating slices to reduce allocations
type PerformanceProfiler ¶
type PerformanceProfiler struct {
// contains filtered or unexported fields
}
PerformanceProfiler provides advanced profiling capabilities
func NewPerformanceProfiler ¶
func NewPerformanceProfiler() *PerformanceProfiler
NewPerformanceProfiler creates a new performance profiler
func (*PerformanceProfiler) GetMetrics ¶
func (p *PerformanceProfiler) GetMetrics() *PerformanceMetrics
GetMetrics returns the current performance metrics
func (*PerformanceProfiler) GetMonitor ¶
func (p *PerformanceProfiler) GetMonitor() *PerformanceMonitor
GetMonitor returns the underlying performance monitor
func (*PerformanceProfiler) ProfileServerShutdown ¶
func (p *PerformanceProfiler) ProfileServerShutdown(server *BusinessServerImpl) (time.Duration, error)
ProfileServerShutdown profiles server shutdown performance
func (*PerformanceProfiler) ProfileServerStartup ¶
func (p *PerformanceProfiler) ProfileServerStartup(server *BusinessServerImpl) (time.Duration, error)
ProfileServerStartup profiles server startup performance
type PerformanceSnapshot ¶
type PerformanceSnapshot struct {
// Timing metrics
StartupTime time.Duration `json:"startup_time"`
ShutdownTime time.Duration `json:"shutdown_time"`
Uptime time.Duration `json:"uptime"`
// Resource metrics
MemoryUsage uint64 `json:"memory_usage"`
GoroutineCount int `json:"goroutine_count"`
CPUUsage float64 `json:"cpu_usage"`
// Service metrics
ServiceCount int `json:"service_count"`
TransportCount int `json:"transport_count"`
// Operation counters
StartCount int64 `json:"start_count"`
StopCount int64 `json:"stop_count"`
RequestCount int64 `json:"request_count"`
ErrorCount int64 `json:"error_count"`
// Performance thresholds
MaxStartupTime time.Duration `json:"max_startup_time"`
MaxShutdownTime time.Duration `json:"max_shutdown_time"`
MaxMemoryUsage uint64 `json:"max_memory_usage"`
// Timestamp
LastUpdated time.Time `json:"last_updated"`
}
PerformanceSnapshot represents a snapshot of performance metrics without mutex
type RateLimitConfig ¶
type RateLimitConfig struct {
RequestsPerSecond int `yaml:"requests_per_second" json:"requests_per_second"`
BurstSize int `yaml:"burst_size" json:"burst_size"`
WindowSize time.Duration `yaml:"window_size" json:"window_size"`
KeyFunc string `yaml:"key_func" json:"key_func"` // "ip", "user", "custom"
}
RateLimitConfig holds rate limiting configuration
type ResourceCleanup ¶
type ResourceCleanup struct{}
ResourceCleanup provides utilities for resource cleanup
func NewResourceCleanup ¶
func NewResourceCleanup() *ResourceCleanup
NewResourceCleanup creates a new resource cleanup instance
func (*ResourceCleanup) CleanupDatabase ¶
func (r *ResourceCleanup) CleanupDatabase(db *gorm.DB, serviceName string) error
CleanupDatabase performs database cleanup operations
func (*ResourceCleanup) CleanupResources ¶
func (r *ResourceCleanup) CleanupResources(resources map[string]interface{}, serviceName string) error
CleanupResources performs general resource cleanup
type RetryConfig ¶
type RetryConfig struct {
MaxRetries int `yaml:"max_retries" json:"max_retries"`
InitialInterval time.Duration `yaml:"initial_interval" json:"initial_interval"`
MaxInterval time.Duration `yaml:"max_interval" json:"max_interval"`
Multiplier float64 `yaml:"multiplier" json:"multiplier"`
EnableJitter bool `yaml:"enable_jitter" json:"enable_jitter"`
}
RetryConfig holds retry configuration for discovery operations
type ServerConfig ¶
type ServerConfig struct {
ServiceName string `yaml:"service_name" json:"service_name"`
HTTP HTTPConfig `yaml:"http" json:"http"`
GRPC GRPCConfig `yaml:"grpc" json:"grpc"`
Discovery DiscoveryConfig `yaml:"discovery" json:"discovery"`
Middleware MiddlewareConfig `yaml:"middleware" json:"middleware"`
ShutdownTimeout time.Duration `yaml:"shutdown_timeout" json:"shutdown_timeout"`
}
ServerConfig holds the complete configuration for a base server instance It includes transport, discovery, and middleware configuration
func NewServerConfig ¶
func NewServerConfig() *ServerConfig
NewServerConfig creates a new ServerConfig with default values
func (*ServerConfig) DeepCopy ¶
func (c *ServerConfig) DeepCopy() *ServerConfig
DeepCopy creates a deep copy of the ServerConfig to prevent shared references between different factory instances. This ensures that modifications to one configuration instance don't affect others.
func (*ServerConfig) GetDiscoveryFailureModeDescription ¶
func (c *ServerConfig) GetDiscoveryFailureModeDescription() string
GetDiscoveryFailureModeDescription returns a human-readable description of the failure mode
func (*ServerConfig) GetGRPCAddress ¶
func (c *ServerConfig) GetGRPCAddress() string
GetGRPCAddress returns the full gRPC address with colon prefix
func (*ServerConfig) GetHTTPAddress ¶
func (c *ServerConfig) GetHTTPAddress() string
GetHTTPAddress returns the full HTTP address with colon prefix
func (*ServerConfig) IsDiscoveryEnabled ¶
func (c *ServerConfig) IsDiscoveryEnabled() bool
IsDiscoveryEnabled returns true if service discovery is enabled
func (*ServerConfig) IsDiscoveryFailureModeFailFast ¶
func (c *ServerConfig) IsDiscoveryFailureModeFailFast() bool
IsDiscoveryFailureModeFailFast returns true if discovery failure mode is fail_fast or strict
func (*ServerConfig) IsDiscoveryFailureModeGraceful ¶
func (c *ServerConfig) IsDiscoveryFailureModeGraceful() bool
IsDiscoveryFailureModeGraceful returns true if discovery failure mode is graceful
func (*ServerConfig) IsDiscoveryFailureModeStrict ¶
func (c *ServerConfig) IsDiscoveryFailureModeStrict() bool
IsDiscoveryFailureModeStrict returns true if discovery failure mode is strict
func (*ServerConfig) IsGRPCEnabled ¶
func (c *ServerConfig) IsGRPCEnabled() bool
IsGRPCEnabled returns true if gRPC transport is enabled
func (*ServerConfig) IsHTTPEnabled ¶
func (c *ServerConfig) IsHTTPEnabled() bool
IsHTTPEnabled returns true if HTTP transport is enabled
func (*ServerConfig) SetDefaults ¶
func (c *ServerConfig) SetDefaults()
SetDefaults sets default values for all configuration options
func (*ServerConfig) Validate ¶
func (c *ServerConfig) Validate() error
Validate validates the configuration and returns any errors
type ServerError ¶
type ServerError struct {
Code string `json:"code"`
Message string `json:"message"`
Details string `json:"details,omitempty"`
Category ErrorCategory `json:"category"`
Context map[string]string `json:"context,omitempty"`
Cause error `json:"-"`
Operation string `json:"operation,omitempty"`
}
ServerError represents a server-level error with categorization and context preservation
func ErrConfigInvalid ¶
func ErrConfigInvalid(message string) *ServerError
ErrConfigInvalid creates a configuration validation error
func ErrConfigInvalidWithCause ¶
func ErrConfigInvalidWithCause(message string, cause error) *ServerError
ErrConfigInvalidWithCause creates a configuration error with underlying cause
func ErrDependencyFailed ¶
func ErrDependencyFailed(message string) *ServerError
ErrDependencyFailed creates a dependency initialization/operation error
func ErrDependencyFailedWithCause ¶
func ErrDependencyFailedWithCause(message string, cause error) *ServerError
ErrDependencyFailedWithCause creates a dependency error with underlying cause
func ErrDiscoveryFailed ¶
func ErrDiscoveryFailed(message string) *ServerError
ErrDiscoveryFailed creates a service discovery error
func ErrDiscoveryFailedWithCause ¶
func ErrDiscoveryFailedWithCause(message string, cause error) *ServerError
ErrDiscoveryFailedWithCause creates a service discovery error with underlying cause
func ErrLifecycleFailed ¶
func ErrLifecycleFailed(message string) *ServerError
ErrLifecycleFailed creates a server lifecycle error
func ErrLifecycleFailedWithCause ¶
func ErrLifecycleFailedWithCause(message string, cause error) *ServerError
ErrLifecycleFailedWithCause creates a lifecycle error with underlying cause
func ErrMiddlewareFailed ¶
func ErrMiddlewareFailed(message string) *ServerError
ErrMiddlewareFailed creates a middleware configuration error
func ErrMiddlewareFailedWithCause ¶
func ErrMiddlewareFailedWithCause(message string, cause error) *ServerError
ErrMiddlewareFailedWithCause creates a middleware error with underlying cause
func ErrServerAlreadyStarted ¶
func ErrServerAlreadyStarted() *ServerError
ErrServerAlreadyStarted creates an error for attempting to start an already started server
func ErrServerNotStarted ¶
func ErrServerNotStarted() *ServerError
ErrServerNotStarted creates an error for operations requiring a started server
func ErrServiceRegFailed ¶
func ErrServiceRegFailed(message string) *ServerError
ErrServiceRegFailed creates a service registration error
func ErrServiceRegFailedWithCause ¶
func ErrServiceRegFailedWithCause(message string, cause error) *ServerError
ErrServiceRegFailedWithCause creates a service registration error with underlying cause
func ErrShutdownTimeout ¶
func ErrShutdownTimeout(message string) *ServerError
ErrShutdownTimeout creates a shutdown timeout error
func ErrShutdownTimeoutWithCause ¶
func ErrShutdownTimeoutWithCause(message string, cause error) *ServerError
ErrShutdownTimeoutWithCause creates a shutdown timeout error with underlying cause
func ErrTransportFailed ¶
func ErrTransportFailed(message string) *ServerError
ErrTransportFailed creates a transport initialization/operation error
func ErrTransportFailedWithCause ¶
func ErrTransportFailedWithCause(message string, cause error) *ServerError
ErrTransportFailedWithCause creates a transport error with underlying cause
func GetServerError ¶
func GetServerError(err error) *ServerError
GetServerError extracts ServerError from error
func NewServerError ¶
func NewServerError(code, message string, category ErrorCategory) *ServerError
NewServerError creates a new server error
func NewServerErrorWithCause ¶
func NewServerErrorWithCause(code, message string, category ErrorCategory, cause error) *ServerError
NewServerErrorWithCause creates a new server error with underlying cause
func NewServerErrorWithDetails ¶
func NewServerErrorWithDetails(code, message, details string, category ErrorCategory) *ServerError
NewServerErrorWithDetails creates a new server error with details
func WrapError ¶
func WrapError(err error, code, message string, category ErrorCategory) *ServerError
WrapError wraps an existing error with server error context
func (*ServerError) Error ¶
func (e *ServerError) Error() string
Error implements the error interface
func (*ServerError) Unwrap ¶
func (e *ServerError) Unwrap() error
Unwrap returns the underlying cause for error wrapping
func (*ServerError) WithContext ¶
func (e *ServerError) WithContext(key, value string) *ServerError
WithContext adds context information to the error
func (*ServerError) WithOperation ¶
func (e *ServerError) WithOperation(operation string) *ServerError
WithOperation sets the operation context for the error
type ServerLogger ¶
type ServerLogger struct {
// contains filtered or unexported fields
}
ServerLogger provides structured logging for server operations with consistent context
func NewServerLogger ¶
func NewServerLogger(serviceName string, config *LoggingConfig) *ServerLogger
NewServerLogger creates a new server logger with the given configuration
func (*ServerLogger) GetUnderlyingLogger ¶
func (sl *ServerLogger) GetUnderlyingLogger() *zap.Logger
GetUnderlyingLogger returns the underlying zap logger for advanced usage
func (*ServerLogger) LogDebug ¶
func (sl *ServerLogger) LogDebug(message string, fields ...zap.Field)
LogDebug logs a debug message with server context
func (*ServerLogger) LogDependencyInitialized ¶
func (sl *ServerLogger) LogDependencyInitialized(dependencyName string)
LogDependencyInitialized logs dependency initialization
func (*ServerLogger) LogDiscoveryDeregistered ¶
func (sl *ServerLogger) LogDiscoveryDeregistered(discoveryService string, endpointCount int)
LogDiscoveryDeregistered logs service discovery deregistration
func (*ServerLogger) LogDiscoveryRegistered ¶
func (sl *ServerLogger) LogDiscoveryRegistered(discoveryService string, endpointCount int)
LogDiscoveryRegistered logs service discovery registration
func (*ServerLogger) LogError ¶
func (sl *ServerLogger) LogError(message string, err error, fields ...zap.Field)
LogError logs a general error with server context
func (*ServerLogger) LogInfo ¶
func (sl *ServerLogger) LogInfo(message string, fields ...zap.Field)
LogInfo logs an informational message with server context
func (*ServerLogger) LogMiddlewareConfigured ¶
func (sl *ServerLogger) LogMiddlewareConfigured(middlewareName string, enabled bool)
LogMiddlewareConfigured logs middleware configuration
func (*ServerLogger) LogServerShutdownFailed ¶
func (sl *ServerLogger) LogServerShutdownFailed(err error, shutdownDuration time.Duration)
LogServerShutdownFailed logs server shutdown failure
func (*ServerLogger) LogServerStarted ¶
func (sl *ServerLogger) LogServerStarted(httpAddr, grpcAddr string, startupDuration time.Duration)
LogServerStarted logs successful server startup
func (*ServerLogger) LogServerStarting ¶
func (sl *ServerLogger) LogServerStarting()
LogServerStarting logs server startup initiation
func (*ServerLogger) LogServerStartupFailed ¶
func (sl *ServerLogger) LogServerStartupFailed(err error, phase string, startupDuration time.Duration)
LogServerStartupFailed logs server startup failure
func (*ServerLogger) LogServerStopped ¶
func (sl *ServerLogger) LogServerStopped(shutdownDuration time.Duration)
LogServerStopped logs successful server shutdown
func (*ServerLogger) LogServerStopping ¶
func (sl *ServerLogger) LogServerStopping()
LogServerStopping logs server shutdown initiation
func (*ServerLogger) LogServiceRegistered ¶
func (sl *ServerLogger) LogServiceRegistered(serviceName, serviceType string)
LogServiceRegistered logs service registration
func (*ServerLogger) LogTransportInitialized ¶
func (sl *ServerLogger) LogTransportInitialized(transportType, address string)
LogTransportInitialized logs transport initialization
func (*ServerLogger) LogTransportStarted ¶
func (sl *ServerLogger) LogTransportStarted(transportType, address string)
LogTransportStarted logs transport startup
func (*ServerLogger) LogTransportStopped ¶
func (sl *ServerLogger) LogTransportStopped(transportType string, shutdownDuration time.Duration)
LogTransportStopped logs transport shutdown
func (*ServerLogger) LogWarning ¶
func (sl *ServerLogger) LogWarning(message string, fields ...zap.Field)
LogWarning logs a warning with server context
func (*ServerLogger) Sync ¶
func (sl *ServerLogger) Sync() error
Sync flushes any buffered log entries
func (*ServerLogger) WithContext ¶
func (sl *ServerLogger) WithContext(ctx context.Context) *ServerLogger
WithContext creates a new logger with additional context fields
func (*ServerLogger) WithFields ¶
func (sl *ServerLogger) WithFields(fields ...zap.Field) *ServerLogger
WithFields creates a new logger with additional fields
type ServerLoggerWithHooks ¶
type ServerLoggerWithHooks struct {
*ServerLogger
// contains filtered or unexported fields
}
ServerLoggerWithHooks extends ServerLogger with hook support
func NewServerLoggerWithHooks ¶
func NewServerLoggerWithHooks(serviceName string, config *LoggingConfig) *ServerLoggerWithHooks
NewServerLoggerWithHooks creates a new server logger with hook support
func (*ServerLoggerWithHooks) AddHook ¶
func (slh *ServerLoggerWithHooks) AddHook(level LogLevel, hook LoggingHook)
AddHook adds a logging hook for the specified level
func (*ServerLoggerWithHooks) LogDebug ¶
func (slh *ServerLoggerWithHooks) LogDebug(message string, fields ...zap.Field)
LogDebug with hooks
func (*ServerLoggerWithHooks) LogError ¶
func (slh *ServerLoggerWithHooks) LogError(message string, err error, fields ...zap.Field)
LogError with hooks
func (*ServerLoggerWithHooks) LogInfo ¶
func (slh *ServerLoggerWithHooks) LogInfo(message string, fields ...zap.Field)
LogInfo with hooks
func (*ServerLoggerWithHooks) LogWarning ¶
func (slh *ServerLoggerWithHooks) LogWarning(message string, fields ...zap.Field)
LogWarning with hooks
type ServerMetrics ¶
type ServerMetrics struct {
// contains filtered or unexported fields
}
ServerMetrics provides server-specific metrics collection
func NewServerMetrics ¶
func NewServerMetrics(serviceName string, collector MetricsCollector) *ServerMetrics
NewServerMetrics creates a new server metrics collector
func (*ServerMetrics) GetCollector ¶
func (sm *ServerMetrics) GetCollector() MetricsCollector
GetCollector returns the underlying metrics collector
func (*ServerMetrics) RecordError ¶
func (sm *ServerMetrics) RecordError(errorType, operation string)
RecordError records error metrics
func (*ServerMetrics) RecordOperationDuration ¶
func (sm *ServerMetrics) RecordOperationDuration(operation string, duration time.Duration)
RecordOperationDuration records operation duration metrics
func (*ServerMetrics) RecordServerStart ¶
func (sm *ServerMetrics) RecordServerStart()
RecordServerStart records server startup metrics
func (*ServerMetrics) RecordServerStop ¶
func (sm *ServerMetrics) RecordServerStop()
RecordServerStop records server shutdown metrics
func (*ServerMetrics) RecordServiceRegistration ¶
func (sm *ServerMetrics) RecordServiceRegistration(serviceName, serviceType string)
RecordServiceRegistration records service registration metrics
func (*ServerMetrics) RecordTransportStart ¶
func (sm *ServerMetrics) RecordTransportStart(transportType string)
RecordTransportStart records transport startup metrics
func (*ServerMetrics) RecordTransportStop ¶
func (sm *ServerMetrics) RecordTransportStop(transportType string)
RecordTransportStop records transport shutdown metrics
type ServerPerformanceMetrics ¶
type ServerPerformanceMetrics = PerformanceMetrics
Backward compatibility aliases
func NewServerPerformanceMetrics ¶
func NewServerPerformanceMetrics() *ServerPerformanceMetrics
NewServerPerformanceMetrics creates a new performance metrics instance (backward compatibility)
type ServerStatus ¶
type ServerStatus struct {
ServiceName string `json:"service_name"`
Status string `json:"status"`
StartTime time.Time `json:"start_time"`
Uptime string `json:"uptime"`
Version string `json:"version,omitempty"`
BuildInfo map[string]string `json:"build_info,omitempty"`
Configuration map[string]interface{} `json:"configuration,omitempty"`
Transports []TransportStatus `json:"transports"`
Dependencies []DependencyStatus `json:"dependencies,omitempty"`
HealthChecks map[string]*types.HealthStatus `json:"health_checks,omitempty"`
Metrics []Metric `json:"metrics,omitempty"`
SystemInfo SystemInfo `json:"system_info"`
}
ServerStatus represents the overall server status
type ServiceDiscoveryManager ¶
type ServiceDiscoveryManager interface {
// RegisterService registers a service with discovery
RegisterService(ctx context.Context, registration *ServiceRegistration) error
// DeregisterService removes a service from discovery
DeregisterService(ctx context.Context, registration *ServiceRegistration) error
// RegisterMultipleEndpoints registers multiple endpoints for a service
RegisterMultipleEndpoints(ctx context.Context, registrations []*ServiceRegistration) error
// DeregisterMultipleEndpoints removes multiple endpoints from discovery
DeregisterMultipleEndpoints(ctx context.Context, registrations []*ServiceRegistration) error
// IsHealthy checks if the discovery service is available
IsHealthy(ctx context.Context) bool
}
ServiceDiscoveryManager abstracts service discovery operations for the base server
func NewDiscoveryManager ¶
func NewDiscoveryManager(config *DiscoveryConfig) (ServiceDiscoveryManager, error)
NewDiscoveryManager creates a new service discovery manager
type ServiceNamingPattern ¶
type ServiceNamingPattern string
ServiceNamingPattern defines different patterns for service naming in discovery
const ( // ServiceNamingPatternBase uses the base service name ServiceNamingPatternBase ServiceNamingPattern = "base" // ServiceNamingPatternProtocol appends protocol suffix (e.g., service-grpc) ServiceNamingPatternProtocol ServiceNamingPattern = "protocol" // ServiceNamingPatternPort appends port suffix (e.g., service-9080) ServiceNamingPatternPort ServiceNamingPattern = "port" )
type ServiceRegistration ¶
type ServiceRegistration struct {
ServiceName string `json:"service_name"`
ServiceID string `json:"service_id"`
Address string `json:"address"`
Port int `json:"port"`
Tags []string `json:"tags"`
Meta map[string]string `json:"meta"`
HealthCheck *HealthCheckInfo `json:"health_check,omitempty"`
}
ServiceRegistration represents a service registration with discovery
func CreateGRPCServiceRegistration ¶
func CreateGRPCServiceRegistration(serviceName, address string, port int, tags []string) *ServiceRegistration
CreateGRPCServiceRegistration creates a service registration for gRPC endpoint
func CreateHTTPServiceRegistration ¶
func CreateHTTPServiceRegistration(serviceName, address string, port int, tags []string) *ServiceRegistration
CreateHTTPServiceRegistration creates a service registration for HTTP endpoint
func CreateServiceRegistrations ¶
func CreateServiceRegistrations(config *ServerConfig) []*ServiceRegistration
CreateServiceRegistrations creates registrations for both HTTP and gRPC endpoints This function implements multi-endpoint registration support with service naming patterns and port-based service differentiation for discovery
func GetServicesByPort ¶
func GetServicesByPort(registrations []*ServiceRegistration, port int) []*ServiceRegistration
GetServicesByPort filters service registrations by port
func GetServicesByProtocol ¶
func GetServicesByProtocol(registrations []*ServiceRegistration, protocol string) []*ServiceRegistration
GetServicesByProtocol filters service registrations by protocol
type ServiceRegistrationBatch ¶
type ServiceRegistrationBatch struct {
// contains filtered or unexported fields
}
ServiceRegistrationBatch provides batch registration utilities
func NewServiceRegistrationBatch ¶
func NewServiceRegistrationBatch(registry BusinessServiceRegistry) *ServiceRegistrationBatch
NewServiceRegistrationBatch creates a new service registration batch
func (*ServiceRegistrationBatch) RegisterGRPCServices ¶
func (b *ServiceRegistrationBatch) RegisterGRPCServices(services []GRPCServiceDefinition) error
RegisterGRPCServices registers multiple gRPC services in batch
func (*ServiceRegistrationBatch) RegisterHTTPServices ¶
func (b *ServiceRegistrationBatch) RegisterHTTPServices(services []HTTPServiceDefinition) error
RegisterHTTPServices registers multiple HTTP services in batch
type ServiceRegistrationHelper ¶
type ServiceRegistrationHelper struct {
// contains filtered or unexported fields
}
ServiceRegistrationHelper provides utilities for service registration
func NewServiceRegistrationHelper ¶
func NewServiceRegistrationHelper(registry BusinessServiceRegistry) *ServiceRegistrationHelper
NewServiceRegistrationHelper creates a new service registration helper
func (*ServiceRegistrationHelper) RegisterGRPCServiceWithHealthCheck ¶
func (h *ServiceRegistrationHelper) RegisterGRPCServiceWithHealthCheck( serviceName string, registrar GRPCServiceRegistrar, healthCheckFunc HealthCheckFunc, ) error
RegisterGRPCServiceWithHealthCheck registers a gRPC service along with its health check
func (*ServiceRegistrationHelper) RegisterHTTPHandlerWithHealthCheck ¶
func (h *ServiceRegistrationHelper) RegisterHTTPHandlerWithHealthCheck( serviceName string, registrar HTTPHandlerRegistrar, healthCheckFunc HealthCheckFunc, ) error
RegisterHTTPHandlerWithHealthCheck registers an HTTP handler along with its health check
type ServiceSpecificMiddlewareConfig ¶
type ServiceSpecificMiddlewareConfig struct {
ServiceName string
HTTPMiddleware []HTTPMiddlewareFunc
GRPCUnaryInterceptors []grpc.UnaryServerInterceptor
GRPCStreamInterceptors []grpc.StreamServerInterceptor
OverrideHTTPConfig *HTTPMiddleware
OverrideGRPCConfig *GRPCInterceptorConfig
}
ServiceSpecificMiddlewareConfig allows services to customize middleware configuration
type SimpleBusinessDependencyContainer ¶
type SimpleBusinessDependencyContainer struct {
// contains filtered or unexported fields
}
SimpleBusinessDependencyContainer provides a basic implementation of BusinessDependencyContainer It supports singleton and transient dependencies with lifecycle management
func NewSimpleBusinessDependencyContainer ¶
func NewSimpleBusinessDependencyContainer() *SimpleBusinessDependencyContainer
NewSimpleBusinessDependencyContainer creates a new SimpleBusinessDependencyContainer
func (*SimpleBusinessDependencyContainer) Close ¶
func (c *SimpleBusinessDependencyContainer) Close() error
Close closes all managed dependencies and cleans up resources
func (*SimpleBusinessDependencyContainer) GetDependencyMetadata ¶
func (c *SimpleBusinessDependencyContainer) GetDependencyMetadata(name string) (*DependencyMetadata, error)
GetDependencyMetadata returns metadata for a specific dependency
func (*SimpleBusinessDependencyContainer) GetDependencyNames ¶
func (c *SimpleBusinessDependencyContainer) GetDependencyNames() []string
GetDependencyNames returns the names of all registered dependencies
func (*SimpleBusinessDependencyContainer) GetService ¶
func (c *SimpleBusinessDependencyContainer) GetService(name string) (interface{}, error)
GetService retrieves a service by name from the container
func (*SimpleBusinessDependencyContainer) Initialize ¶
func (c *SimpleBusinessDependencyContainer) Initialize(ctx context.Context) error
Initialize initializes all singleton dependencies
func (*SimpleBusinessDependencyContainer) IsClosed ¶
func (c *SimpleBusinessDependencyContainer) IsClosed() bool
IsClosed returns true if the container has been closed
func (*SimpleBusinessDependencyContainer) IsInitialized ¶
func (c *SimpleBusinessDependencyContainer) IsInitialized() bool
IsInitialized returns true if the container has been initialized
func (*SimpleBusinessDependencyContainer) RegisterInstance ¶
func (c *SimpleBusinessDependencyContainer) RegisterInstance(name string, instance interface{}) error
RegisterInstance registers a pre-created instance as a singleton dependency
func (*SimpleBusinessDependencyContainer) RegisterSingleton ¶
func (c *SimpleBusinessDependencyContainer) RegisterSingleton(name string, factory DependencyFactory) error
RegisterSingleton registers a singleton dependency with the container Singleton dependencies are created once and reused for all requests
func (*SimpleBusinessDependencyContainer) RegisterTransient ¶
func (c *SimpleBusinessDependencyContainer) RegisterTransient(name string, factory DependencyFactory) error
RegisterTransient registers a transient dependency with the container Transient dependencies are created fresh for each request
type SimpleMetricsCollector ¶
type SimpleMetricsCollector struct {
// contains filtered or unexported fields
}
SimpleMetricsCollector provides a basic in-memory metrics collector
func NewSimpleMetricsCollector ¶
func NewSimpleMetricsCollector() *SimpleMetricsCollector
NewSimpleMetricsCollector creates a new simple metrics collector
func (*SimpleMetricsCollector) AddToCounter ¶
func (smc *SimpleMetricsCollector) AddToCounter(name string, value float64, labels map[string]string)
AddToCounter adds a value to a counter metric
func (*SimpleMetricsCollector) DecrementGauge ¶
func (smc *SimpleMetricsCollector) DecrementGauge(name string, labels map[string]string)
DecrementGauge decrements a gauge metric by 1
func (*SimpleMetricsCollector) GetMetric ¶
func (smc *SimpleMetricsCollector) GetMetric(name string) (*Metric, bool)
GetMetric returns a specific metric by name
func (*SimpleMetricsCollector) GetMetrics ¶
func (smc *SimpleMetricsCollector) GetMetrics() []Metric
GetMetrics returns all collected metrics
func (*SimpleMetricsCollector) IncrementCounter ¶
func (smc *SimpleMetricsCollector) IncrementCounter(name string, labels map[string]string)
IncrementCounter increments a counter metric by 1
func (*SimpleMetricsCollector) IncrementGauge ¶
func (smc *SimpleMetricsCollector) IncrementGauge(name string, labels map[string]string)
IncrementGauge increments a gauge metric by 1
func (*SimpleMetricsCollector) ObserveHistogram ¶
func (smc *SimpleMetricsCollector) ObserveHistogram(name string, value float64, labels map[string]string)
ObserveHistogram adds an observation to a histogram metric
func (*SimpleMetricsCollector) Reset ¶
func (smc *SimpleMetricsCollector) Reset()
Reset clears all metrics
type StandardConfigDefaults ¶
type StandardConfigDefaults struct {
ServiceName string
HTTPPort string
GRPCPort string
EnableHTTPReady bool
EnableGRPCKeepalive bool
EnableGRPCReflection bool
EnableGRPCHealth bool
DiscoveryTags []string
EnableCORS bool
EnableAuth bool
EnableRateLimit bool
EnableLogging bool
}
StandardConfigDefaults provides standard configuration defaults for services
type SystemInfo ¶
type SystemInfo struct {
GoVersion string `json:"go_version"`
NumCPU int `json:"num_cpu"`
NumGoroutine int `json:"num_goroutine"`
MemStats struct {
Alloc uint64 `json:"alloc"`
TotalAlloc uint64 `json:"total_alloc"`
Sys uint64 `json:"sys"`
NumGC uint32 `json:"num_gc"`
} `json:"mem_stats"`
}
SystemInfo represents system information
type TemplateRegistry ¶
type TemplateRegistry struct {
// contains filtered or unexported fields
}
TemplateRegistry manages available configuration templates
func NewTemplateRegistry ¶
func NewTemplateRegistry() *TemplateRegistry
NewTemplateRegistry creates a new template registry with default templates
func (*TemplateRegistry) CreateConfigFromTemplate ¶
func (r *TemplateRegistry) CreateConfigFromTemplate(templateName string, params map[string]interface{}) (*ServerConfig, error)
CreateConfigFromTemplate creates a configuration from a template with custom parameters
func (*TemplateRegistry) GetAllTemplates ¶
func (r *TemplateRegistry) GetAllTemplates() map[string]ConfigTemplate
GetAllTemplates returns all registered templates
func (*TemplateRegistry) GetTemplate ¶
func (r *TemplateRegistry) GetTemplate(name string) (ConfigTemplate, bool)
GetTemplate retrieves a template by name
func (*TemplateRegistry) GetTemplateNames ¶
func (r *TemplateRegistry) GetTemplateNames() []string
GetTemplateNames returns the names of all registered templates
func (*TemplateRegistry) RegisterTemplate ¶
func (r *TemplateRegistry) RegisterTemplate(template ConfigTemplate)
RegisterTemplate registers a new template
type TestServiceTemplate ¶
TestServiceTemplate provides a template for test services
func (*TestServiceTemplate) Build ¶
func (t *TestServiceTemplate) Build() *ServerConfig
func (*TestServiceTemplate) GetDescription ¶
func (t *TestServiceTemplate) GetDescription() string
func (*TestServiceTemplate) GetName ¶
func (t *TestServiceTemplate) GetName() string
type TimeoutConfig ¶
type TimeoutConfig struct {
RequestTimeout time.Duration `yaml:"request_timeout" json:"request_timeout"`
HandlerTimeout time.Duration `yaml:"handler_timeout" json:"handler_timeout"`
}
TimeoutConfig holds timeout middleware configuration
type TransportManager ¶
type TransportManager interface {
GetTransports() []transport.NetworkTransport
InitializeAllServices(ctx context.Context) error
Start(ctx context.Context) error
Stop(timeout time.Duration) error
}
TransportManager defines the interface for transport management in lifecycle
type TransportStatus ¶
type TransportStatus struct {
Name string `json:"name"`
Address string `json:"address"`
Running bool `json:"running"`
}
TransportStatus represents the status of a transport
type WebAPITemplate ¶
WebAPITemplate provides a template for web API services
func (*WebAPITemplate) Build ¶
func (t *WebAPITemplate) Build() *ServerConfig
func (*WebAPITemplate) GetDescription ¶
func (t *WebAPITemplate) GetDescription() string
func (*WebAPITemplate) GetName ¶
func (t *WebAPITemplate) GetName() string