Documentation
¶
Index ¶
- Constants
- func Cache(config CacheConfig) lift.Middleware
- func CacheStatsMiddleware(store CacheStore) lift.Middleware
- func CacheWithInvalidation(store CacheStore, ttl time.Duration, invalidatePattern string) lift.Middleware
- func CacheWithKey(store CacheStore, ttl time.Duration, keyFunc func(*lift.Context) string) lift.Middleware
- func CacheWithStore(store CacheStore, ttl time.Duration) lift.Middleware
- func InitializeFeatureFlags(config FeatureFlagConfig) error
- func IsEnabled(flag string) bool
- func RequestValidation(schema *ValidationSchema) lift.Middleware
- func ResponseValidation(schema *ValidationSchema) lift.Middleware
- func StrictValidation(requestSchema, responseSchema *ValidationSchema) lift.Middleware
- func Validation(schema *ValidationSchema) lift.Middleware
- type CacheConfig
- type CacheMetrics
- type CacheMiddleware
- type CacheSerializer
- type CacheStats
- type CacheStore
- type CacheStrategy
- type FeatureFlagConfig
- type FeatureFlags
- type JSONCacheSerializer
- type MemoryCache
- func (mc *MemoryCache) Clear(_ context.Context) error
- func (mc *MemoryCache) Close() error
- func (mc *MemoryCache) Delete(_ context.Context, key string) error
- func (mc *MemoryCache) Exists(key string) bool
- func (mc *MemoryCache) Get(_ context.Context, key string) (any, bool, error)
- func (mc *MemoryCache) Keys(_ string) ([]string, error)
- func (mc *MemoryCache) Set(_ context.Context, key string, value any, ttl time.Duration) error
- func (mc *MemoryCache) Stats() CacheStats
- func (mc *MemoryCache) TTL(key string) time.Duration
- type MemoryCacheConfig
- type MultiBendCacheStore
- func (m *MultiBendCacheStore) Clear(ctx context.Context) error
- func (m *MultiBendCacheStore) Close() error
- func (m *MultiBendCacheStore) Delete(ctx context.Context, key string) error
- func (m *MultiBendCacheStore) Exists(key string) bool
- func (m *MultiBendCacheStore) Get(ctx context.Context, key string) (any, bool, error)
- func (m *MultiBendCacheStore) Keys(pattern string) ([]string, error)
- func (m *MultiBendCacheStore) Set(ctx context.Context, key string, value any, ttl time.Duration) error
- func (m *MultiBendCacheStore) Stats() CacheStats
- func (m *MultiBendCacheStore) TTL(key string) time.Duration
- type ResponseCapturer
- func (r *ResponseCapturer) Binary(data []byte) error
- func (r *ResponseCapturer) GetCapturedData() any
- func (r *ResponseCapturer) HTML(html string) error
- func (r *ResponseCapturer) Header(key, value string) *lift.Response
- func (r *ResponseCapturer) IsWritten() bool
- func (r *ResponseCapturer) JSON(data any) error
- func (r *ResponseCapturer) MarshalJSON() ([]byte, error)
- func (r *ResponseCapturer) Status(code int) *lift.Response
- func (r *ResponseCapturer) Text(text string) error
- type SerializationType
- type ValidationCondition
- type ValidationConfig
- type ValidationError
- type ValidationMiddleware
- type ValidationResult
- type ValidationRule
- type ValidationSchema
- func (s *ValidationSchema) AddProperty(name string, rule ValidationRule) *ValidationSchema
- func (s *ValidationSchema) AddRequired(fields ...string) *ValidationSchema
- func (s *ValidationSchema) AddRule(rule ValidationRule) *ValidationSchema
- func (s *ValidationSchema) SetCustom(fn func(any) error) *ValidationSchema
Constants ¶
const ( // Core features RateLimitingEnabled = "rate_limiting_enabled" CircuitBreakerEnabled = "circuit_breaker_enabled" EnhancedMonitoring = "enhanced_monitoring" ServiceMeshIntegration = "service_mesh_integration" // Development features MockServicesEnabled = "mock_services_enabled" DebugLoggingEnabled = "debug_logging_enabled" DevDashboardEnabled = "dev_dashboard_enabled" // UI features NewDashboardUI = "new_dashboard_ui" // Security features AdvancedSecurityEnabled = "advanced_security_enabled" IPAllowlistEnabled = "ip_allowlist_enabled" )
Feature flag keys
Variables ¶
This section is empty.
Functions ¶
func CacheStatsMiddleware ¶
func CacheStatsMiddleware(store CacheStore) lift.Middleware
CacheStatsMiddleware middleware to expose cache statistics
func CacheWithInvalidation ¶
func CacheWithInvalidation(store CacheStore, ttl time.Duration, invalidatePattern string) lift.Middleware
CacheWithInvalidation creates cache middleware with invalidation support
func CacheWithKey ¶
func CacheWithKey(store CacheStore, ttl time.Duration, keyFunc func(*lift.Context) string) lift.Middleware
CacheWithKey creates cache middleware with custom key function
func CacheWithStore ¶
func CacheWithStore(store CacheStore, ttl time.Duration) lift.Middleware
CacheWithStore creates a simple cache middleware with default configuration
func InitializeFeatureFlags ¶ added in v1.0.37
func InitializeFeatureFlags(config FeatureFlagConfig) error
InitializeFeatureFlags initializes the global feature flags instance
func IsEnabled ¶ added in v1.0.37
IsEnabled checks if a feature is enabled using the global instance
func RequestValidation ¶
func RequestValidation(schema *ValidationSchema) lift.Middleware
RequestValidation creates request-only validation middleware
func ResponseValidation ¶
func ResponseValidation(schema *ValidationSchema) lift.Middleware
ResponseValidation creates response-only validation middleware
func StrictValidation ¶
func StrictValidation(requestSchema, responseSchema *ValidationSchema) lift.Middleware
StrictValidation creates strict validation middleware
func Validation ¶
func Validation(schema *ValidationSchema) lift.Middleware
Validation creates a simple validation middleware
Types ¶
type CacheConfig ¶
type CacheConfig struct {
Store CacheStore
Serializer CacheSerializer
KeyFunc func(*lift.Context) string
ShouldCache func(*lift.Context, any) bool
ShouldInvalidate func(*lift.Context) bool
InvalidatePattern string
Strategy CacheStrategy
Namespace string
EvictionPolicy string
Tags []string
InvalidateOn []string
DefaultTTL time.Duration
MaxSize int64
Serialization SerializationType
EnableMetrics bool
TenantIsolation bool
Compression bool
Encryption bool
}
CacheConfig configures the caching middleware
type CacheMetrics ¶
type CacheMetrics struct {
// contains filtered or unexported fields
}
CacheMetrics tracks cache performance
type CacheMiddleware ¶
type CacheMiddleware struct {
// contains filtered or unexported fields
}
CacheMiddleware provides intelligent caching capabilities
func NewCacheMiddleware ¶
func NewCacheMiddleware(config CacheConfig) *CacheMiddleware
NewCacheMiddleware creates a new caching middleware
func (*CacheMiddleware) GetStats ¶
func (c *CacheMiddleware) GetStats() CacheStats
GetStats returns cache statistics
type CacheSerializer ¶
type CacheSerializer interface {
Serialize(value any) ([]byte, error)
Deserialize(data []byte, target any) error
}
CacheSerializer interface for cache serialization
type CacheStats ¶
type CacheStats struct {
Hits int64 `json:"hits"`
Misses int64 `json:"misses"`
Sets int64 `json:"sets"`
Deletes int64 `json:"deletes"`
Evictions int64 `json:"evictions"`
HitRate float64 `json:"hit_rate"`
AvgLatency time.Duration `json:"avg_latency"`
Size int64 `json:"size"`
MaxSize int64 `json:"max_size"`
MemoryUsage int64 `json:"memory_usage"`
}
CacheStats provides cache performance metrics
type CacheStore ¶
type CacheStore interface {
Get(ctx context.Context, key string) (any, bool, error)
Set(ctx context.Context, key string, value any, ttl time.Duration) error
Delete(ctx context.Context, key string) error
Clear(ctx context.Context) error
Stats() CacheStats
Close() error
Keys(pattern string) ([]string, error)
Exists(key string) bool
TTL(key string) time.Duration
}
CacheStore defines the interface for cache backends
type CacheStrategy ¶
type CacheStrategy string
CacheStrategy defines caching behavior
const ( CacheStrategyLRU CacheStrategy = "lru" CacheStrategyLFU CacheStrategy = "lfu" CacheStrategyTTL CacheStrategy = "ttl" CacheStrategyWriteThrough CacheStrategy = "write_through" CacheStrategyWriteBack CacheStrategy = "write_back" CacheStrategyReadThrough CacheStrategy = "read_through" )
type FeatureFlagConfig ¶ added in v1.0.37
type FeatureFlagConfig struct {
Environment string
Application string
Region string
LocalOnly bool // For testing without AWS
}
FeatureFlagConfig configures the feature flag system
type FeatureFlags ¶ added in v1.0.37
type FeatureFlags struct {
// contains filtered or unexported fields
}
FeatureFlags manages feature toggles for the application
func NewFeatureFlags ¶ added in v1.0.37
func NewFeatureFlags(config FeatureFlagConfig) (*FeatureFlags, error)
NewFeatureFlags creates a new feature flag manager
func (*FeatureFlags) GetAllFlags ¶ added in v1.0.37
func (ff *FeatureFlags) GetAllFlags() map[string]bool
GetAllFlags returns all current flag values
func (*FeatureFlags) IsEnabled ¶ added in v1.0.37
func (ff *FeatureFlags) IsEnabled(flag string) bool
IsEnabled checks if a feature flag is enabled
func (*FeatureFlags) SetFlag ¶ added in v1.0.37
func (ff *FeatureFlags) SetFlag(flag string, enabled bool)
SetFlag manually sets a flag value (useful for testing)
func (*FeatureFlags) Stop ¶ added in v1.0.37
func (ff *FeatureFlags) Stop()
Stop stops the refresh loop
type JSONCacheSerializer ¶
type JSONCacheSerializer struct{}
JSONCacheSerializer implements JSON serialization
func (*JSONCacheSerializer) Deserialize ¶
func (j *JSONCacheSerializer) Deserialize(data []byte, target any) error
type MemoryCache ¶
type MemoryCache struct {
// contains filtered or unexported fields
}
MemoryCache implements an in-memory cache store using go-cache
func NewMemoryCache ¶
func NewMemoryCache(config MemoryCacheConfig) *MemoryCache
NewMemoryCache creates a new memory cache using go-cache
func (*MemoryCache) Clear ¶
func (mc *MemoryCache) Clear(_ context.Context) error
Clear removes all items from the cache
func (*MemoryCache) Delete ¶
func (mc *MemoryCache) Delete(_ context.Context, key string) error
Delete removes a value from the cache
func (*MemoryCache) Exists ¶
func (mc *MemoryCache) Exists(key string) bool
Exists checks if a key exists in the cache
func (*MemoryCache) Keys ¶
func (mc *MemoryCache) Keys(_ string) ([]string, error)
Keys returns all keys (go-cache doesn't have pattern matching, so we return all keys)
func (*MemoryCache) Stats ¶
func (mc *MemoryCache) Stats() CacheStats
Stats returns cache statistics
type MemoryCacheConfig ¶
MemoryCacheConfig configures the memory cache
type MultiBendCacheStore ¶
type MultiBendCacheStore struct {
// contains filtered or unexported fields
}
Multi-backend cache store
func NewMultiBackendCacheStore ¶
func NewMultiBackendCacheStore(primary, secondary CacheStore, strategy string) *MultiBendCacheStore
NewMultiBackendCacheStore creates a multi-backend cache store
func (*MultiBendCacheStore) Close ¶
func (m *MultiBendCacheStore) Close() error
func (*MultiBendCacheStore) Delete ¶
func (m *MultiBendCacheStore) Delete(ctx context.Context, key string) error
func (*MultiBendCacheStore) Exists ¶
func (m *MultiBendCacheStore) Exists(key string) bool
func (*MultiBendCacheStore) Keys ¶
func (m *MultiBendCacheStore) Keys(pattern string) ([]string, error)
func (*MultiBendCacheStore) Stats ¶
func (m *MultiBendCacheStore) Stats() CacheStats
type ResponseCapturer ¶
ResponseCapturer captures response data for caching
func (*ResponseCapturer) Binary ¶
func (r *ResponseCapturer) Binary(data []byte) error
Binary captures binary response
func (*ResponseCapturer) GetCapturedData ¶
func (r *ResponseCapturer) GetCapturedData() any
GetCapturedData returns the captured response data
func (*ResponseCapturer) HTML ¶
func (r *ResponseCapturer) HTML(html string) error
HTML captures HTML response
func (*ResponseCapturer) Header ¶
func (r *ResponseCapturer) Header(key, value string) *lift.Response
Header sets a header
func (*ResponseCapturer) IsWritten ¶
func (r *ResponseCapturer) IsWritten() bool
IsWritten returns whether the response has been written
func (*ResponseCapturer) JSON ¶
func (r *ResponseCapturer) JSON(data any) error
JSON captures JSON response
func (*ResponseCapturer) MarshalJSON ¶
func (r *ResponseCapturer) MarshalJSON() ([]byte, error)
MarshalJSON implements JSON marshaling
func (*ResponseCapturer) Status ¶
func (r *ResponseCapturer) Status(code int) *lift.Response
Status sets the status code
func (*ResponseCapturer) Text ¶
func (r *ResponseCapturer) Text(text string) error
Text captures text response
type SerializationType ¶
type SerializationType int
SerializationType defines how data is serialized in cache
const ( SerializationJSON SerializationType = iota SerializationGob SerializationMsgPack )
type ValidationCondition ¶
type ValidationCondition struct {
Value any `json:"value"`
Field string `json:"field"`
Operator string `json:"operator"`
}
ValidationCondition defines conditional validation
type ValidationConfig ¶
type ValidationConfig struct {
RequestSchema *ValidationSchema
ResponseSchema *ValidationSchema
CustomValidators map[string]func(any) error
ErrorHandler func(*lift.Context, []ValidationError) error
ValidateRequest bool
ValidateResponse bool
StrictMode bool
}
ValidationConfig configures validation behavior
type ValidationError ¶
type ValidationError struct {
Field string `json:"field"`
Message string `json:"message"`
Value any `json:"value,omitempty"`
Code string `json:"code"`
}
ValidationError represents a validation error
type ValidationMiddleware ¶
type ValidationMiddleware struct {
// contains filtered or unexported fields
}
ValidationMiddleware provides advanced validation
func NewValidationMiddleware ¶
func NewValidationMiddleware(config ValidationConfig) *ValidationMiddleware
NewValidationMiddleware creates a new validation middleware
func (*ValidationMiddleware) Validate ¶
func (vm *ValidationMiddleware) Validate() lift.Middleware
Validate creates the validation middleware
type ValidationResult ¶
type ValidationResult struct {
Errors []ValidationError `json:"errors,omitempty"`
Valid bool `json:"valid"`
}
ValidationResult contains validation results
type ValidationRule ¶
type ValidationRule struct {
Min any `json:"min,omitempty"`
Max any `json:"max,omitempty"`
Custom func(any) error `json:"-"`
Field string `json:"field"`
Type string `json:"type"`
Pattern string `json:"pattern,omitempty"`
Message string `json:"message,omitempty"`
Enum []any `json:"enum,omitempty"`
Conditions []ValidationCondition `json:"conditions,omitempty"`
Required bool `json:"required"`
}
ValidationRule defines a validation rule
func CreditCardValidation ¶
func CreditCardValidation() ValidationRule
CreditCardValidation validates credit card number
func PhoneValidation ¶
func PhoneValidation() ValidationRule
PhoneValidation validates phone number format
type ValidationSchema ¶
type ValidationSchema struct {
Properties map[string]ValidationRule `json:"properties"`
Custom func(any) error `json:"-"`
Type string `json:"type"`
Required []string `json:"required"`
Rules []ValidationRule `json:"rules"`
}
ValidationSchema defines a complete validation schema
func (*ValidationSchema) AddProperty ¶
func (s *ValidationSchema) AddProperty(name string, rule ValidationRule) *ValidationSchema
AddProperty adds a property to the schema
func (*ValidationSchema) AddRequired ¶
func (s *ValidationSchema) AddRequired(fields ...string) *ValidationSchema
AddRequired adds a required field
func (*ValidationSchema) AddRule ¶
func (s *ValidationSchema) AddRule(rule ValidationRule) *ValidationSchema
AddRule adds a custom rule
func (*ValidationSchema) SetCustom ¶
func (s *ValidationSchema) SetCustom(fn func(any) error) *ValidationSchema
SetCustom sets a custom validation function