Documentation
¶
Index ¶
- func GetSafeArrayElement(arr []any, index int) (any, bool)
- func IsValidIndex(index, length int) bool
- func NormalizeIndex(index, length int) int
- func NormalizeSlice(start, end, length int) (int, int)
- func ParseArrayIndex(property string) (int, bool)
- func ParseSliceComponents(slicePart string) (start, end, step *int, err error)
- func PerformArraySlice(arr []any, start, end, step *int) []any
- func ValidatePath(path string) error
- type CacheManager
- type CheckResult
- type ConfigInterface
- type HealthChecker
- type HealthCheckerConfig
- type HealthStatus
- type Metrics
- type MetricsCollector
- func (mc *MetricsCollector) EndConcurrentOperation()
- func (mc *MetricsCollector) GetMetrics() Metrics
- func (mc *MetricsCollector) GetSummary() string
- func (mc *MetricsCollector) RecordCacheHit()
- func (mc *MetricsCollector) RecordCacheMiss()
- func (mc *MetricsCollector) RecordError(errorType string)
- func (mc *MetricsCollector) RecordOperation(duration time.Duration, success bool, memoryUsed int64)
- func (mc *MetricsCollector) Reset()
- func (mc *MetricsCollector) StartConcurrentOperation()
- func (mc *MetricsCollector) UpdateMemoryUsage(current int64)
- type PathSegment
- func NewArrayIndexSegment(index int) PathSegment
- func NewArraySliceSegment(start, end, step *int) PathSegment
- func NewExtractSegment(extract string) PathSegment
- func NewPropertySegment(key string) PathSegment
- func ParseComplexSegment(part string) ([]PathSegment, error)
- func ParsePath(path string) ([]PathSegment, error)
- type PathSegmentType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSafeArrayElement ¶ added in v1.0.7
GetSafeArrayElement safely gets an array element with bounds checking
func IsValidIndex ¶ added in v1.0.7
IsValidIndex checks if an index is valid
func NormalizeIndex ¶ added in v1.0.7
NormalizeIndex normalizes array index, handling negative indices
func NormalizeSlice ¶ added in v1.0.7
NormalizeSlice normalizes slice bounds
func ParseArrayIndex ¶ added in v1.0.7
ParseArrayIndex parses array index, supporting negative indices Returns the parsed index and a boolean indicating success
func ParseSliceComponents ¶ added in v1.0.7
ParseSliceComponents parses slice syntax into components
func PerformArraySlice ¶ added in v1.0.7
PerformArraySlice performs Python-style array slicing with optimized capacity calculation
func ValidatePath ¶ added in v1.0.7
ValidatePath validates a path string for security and correctness
Types ¶
type CacheManager ¶
type CacheManager struct {
// contains filtered or unexported fields
}
CacheManager handles all caching operations with performance and memory management
func NewCacheManager ¶
func NewCacheManager(config ConfigInterface) *CacheManager
NewCacheManager creates a new cache manager with sharding
func (*CacheManager) CleanExpiredCache ¶
func (cm *CacheManager) CleanExpiredCache()
CleanExpiredCache removes expired entries from all shards (with goroutine limit)
func (*CacheManager) Clear ¶ added in v1.0.6
func (cm *CacheManager) Clear()
Clear removes all entries from the cache
func (*CacheManager) Delete ¶ added in v1.0.6
func (cm *CacheManager) Delete(key string)
Delete removes a value from the cache
func (*CacheManager) Get ¶
func (cm *CacheManager) Get(key string) (any, bool)
Get retrieves a value from cache with O(1) complexity
func (*CacheManager) GetStats ¶
func (cm *CacheManager) GetStats() map[string]any
GetStats returns cache statistics
func (*CacheManager) Set ¶
func (cm *CacheManager) Set(key string, value any)
Set stores a value in the cache
type CheckResult ¶
CheckResult represents the result of a single health check
type ConfigInterface ¶
type ConfigInterface interface {
IsCacheEnabled() bool
GetMaxCacheSize() int
GetCacheTTL() time.Duration
}
ConfigInterface is imported from root package to avoid circular dependency
type HealthChecker ¶
type HealthChecker struct {
// contains filtered or unexported fields
}
HealthChecker provides health checking functionality for the JSON processor
func NewHealthChecker ¶
func NewHealthChecker(metrics *MetricsCollector, config *HealthCheckerConfig) *HealthChecker
NewHealthChecker creates a new health checker with optional custom thresholds
func (*HealthChecker) CheckHealth ¶
func (hc *HealthChecker) CheckHealth() HealthStatus
CheckHealth performs health checks and returns overall status
type HealthCheckerConfig ¶ added in v1.0.7
HealthCheckerConfig holds configuration for health checker
type HealthStatus ¶
type HealthStatus struct {
Timestamp time.Time `json:"timestamp"`
Healthy bool `json:"healthy"`
Checks map[string]CheckResult `json:"checks"`
}
HealthStatus represents the health status of the processor
func (*HealthStatus) GetFailedChecks ¶
func (hs *HealthStatus) GetFailedChecks() []string
GetFailedChecks returns a list of failed health check names
func (*HealthStatus) GetSummary ¶
func (hs *HealthStatus) GetSummary() string
GetSummary returns a formatted summary of the health status
type Metrics ¶
type Metrics struct {
// Operation metrics
TotalOperations int64 `json:"total_operations"`
SuccessfulOps int64 `json:"successful_ops"`
FailedOps int64 `json:"failed_ops"`
CacheHits int64 `json:"cache_hits"`
CacheMisses int64 `json:"cache_misses"`
// Performance metrics
TotalProcessingTime time.Duration `json:"total_processing_time"`
AvgProcessingTime time.Duration `json:"avg_processing_time"`
MaxProcessingTime time.Duration `json:"max_processing_time"`
MinProcessingTime time.Duration `json:"min_processing_time"`
// Memory metrics
TotalMemoryAllocated int64 `json:"total_memory_allocated"`
PeakMemoryUsage int64 `json:"peak_memory_usage"`
CurrentMemoryUsage int64 `json:"current_memory_usage"`
// Concurrency metrics
ActiveConcurrentOps int64 `json:"active_concurrent_ops"`
MaxConcurrentOps int64 `json:"max_concurrent_ops"`
// Runtime metrics
RuntimeMemStats runtime.MemStats `json:"runtime_mem_stats"`
Uptime time.Duration `json:"uptime"`
ErrorsByType map[string]int64 `json:"errors_by_type"`
}
Metrics represents collected performance metrics
type MetricsCollector ¶
type MetricsCollector struct {
// contains filtered or unexported fields
}
MetricsCollector collects and provides performance metrics for the JSON processor
func NewMetricsCollector ¶
func NewMetricsCollector() *MetricsCollector
NewMetricsCollector creates a new metrics collector
func (*MetricsCollector) EndConcurrentOperation ¶
func (mc *MetricsCollector) EndConcurrentOperation()
EndConcurrentOperation records the end of a concurrent operation
func (*MetricsCollector) GetMetrics ¶
func (mc *MetricsCollector) GetMetrics() Metrics
GetMetrics returns current metrics with runtime stats
func (*MetricsCollector) GetSummary ¶
func (mc *MetricsCollector) GetSummary() string
GetSummary returns a formatted summary of metrics
func (*MetricsCollector) RecordCacheHit ¶
func (mc *MetricsCollector) RecordCacheHit()
RecordCacheHit records a cache hit
func (*MetricsCollector) RecordCacheMiss ¶
func (mc *MetricsCollector) RecordCacheMiss()
RecordCacheMiss records a cache miss
func (*MetricsCollector) RecordError ¶
func (mc *MetricsCollector) RecordError(errorType string)
RecordError records an error by type
func (*MetricsCollector) RecordOperation ¶
func (mc *MetricsCollector) RecordOperation(duration time.Duration, success bool, memoryUsed int64)
RecordOperation records a completed operation
func (*MetricsCollector) StartConcurrentOperation ¶
func (mc *MetricsCollector) StartConcurrentOperation()
StartConcurrentOperation records the start of a concurrent operation
func (*MetricsCollector) UpdateMemoryUsage ¶ added in v1.0.6
func (mc *MetricsCollector) UpdateMemoryUsage(current int64)
UpdateMemoryUsage updates memory usage metrics
type PathSegment ¶
type PathSegment struct {
Type PathSegmentType
Key string // Used for PropertySegment and ExtractSegment
Index int // Used for ArrayIndexSegment
Start *int // Used for ArraySliceSegment
End *int // Used for ArraySliceSegment
Step *int // Used for ArraySliceSegment
IsNegative bool // True if Index is negative
IsWildcard bool // True for WildcardSegment
IsFlat bool // True for flat extraction
}
PathSegment represents a single segment in a JSON path
func NewArrayIndexSegment ¶
func NewArrayIndexSegment(index int) PathSegment
NewArrayIndexSegment creates an array index access segment
func NewArraySliceSegment ¶
func NewArraySliceSegment(start, end, step *int) PathSegment
NewArraySliceSegment creates an array slice access segment
func NewExtractSegment ¶
func NewExtractSegment(extract string) PathSegment
NewExtractSegment creates an extraction segment
func NewPropertySegment ¶
func NewPropertySegment(key string) PathSegment
NewPropertySegment creates a property access segment
func ParseComplexSegment ¶ added in v1.0.7
func ParseComplexSegment(part string) ([]PathSegment, error)
ParseComplexSegment parses a complex segment that may contain mixed syntax
func ParsePath ¶ added in v1.0.7
func ParsePath(path string) ([]PathSegment, error)
ParsePath parses a JSON path string into segments
func (PathSegment) GetArrayIndex ¶
func (ps PathSegment) GetArrayIndex(arrayLength int) (int, error)
GetArrayIndex returns the array index, handling negative indices
func (PathSegment) IsArrayAccess ¶
func (ps PathSegment) IsArrayAccess() bool
IsArrayAccess returns true if this segment accesses an array
func (PathSegment) String ¶
func (ps PathSegment) String() string
String returns a string representation of the path segment
func (PathSegment) TypeString ¶
func (ps PathSegment) TypeString() string
TypeString returns the string type for the segment
type PathSegmentType ¶
type PathSegmentType int
PathSegmentType represents the type of path segment
const ( PropertySegment PathSegmentType = iota ArrayIndexSegment ArraySliceSegment WildcardSegment RecursiveSegment FilterSegment ExtractSegment // For extract operations )
func (PathSegmentType) String ¶
func (pst PathSegmentType) String() string
String returns the string representation of PathSegmentType