Documentation
¶
Index ¶
- type ArrayLocation
- type ArrayUtils
- func (au *ArrayUtils) GetSafeArrayElement(arr []any, index int) (any, bool)
- func (au *ArrayUtils) IsValidIndex(index, length int) bool
- func (au *ArrayUtils) NormalizeIndex(index, length int) int
- func (au *ArrayUtils) NormalizeSlice(start, end, length int) (int, int)
- func (au *ArrayUtils) ParseArrayIndex(property string) int
- func (au *ArrayUtils) ParseSliceComponents(slicePart string) (start, end, step *int, err error)
- func (au *ArrayUtils) ParseSliceFromSegment(segmentValue string) (start, end, step int)
- func (au *ArrayUtils) ParseSliceParameters(segmentValue string, arrayLength int) (start, end, step int, err error)
- func (au *ArrayUtils) PerformArraySlice(arr []any, start, end, step *int) []any
- type CacheInterface
- type CacheManager
- func (cm *CacheManager) CleanExpiredCache()
- func (cm *CacheManager) ClearCache()
- func (cm *CacheManager) Get(key string) (any, bool)
- func (cm *CacheManager) GetCacheSize() int64
- func (cm *CacheManager) GetStats() CacheStats
- func (cm *CacheManager) SecureHash(input string) string
- func (cm *CacheManager) Set(key string, value any)
- type CacheStats
- type CheckResult
- type ConfigInterface
- type EncodeConfigInterface
- type HealthChecker
- type HealthCheckerInterface
- type HealthStatus
- type MappingInfo
- 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()
- type MetricsInterface
- type OperationContext
- type PathParser
- type PathParserInterface
- type PathPatterns
- type PathSegment
- type PathSegmentType
- type ProcessorOptionsInterface
- type StatsInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArrayLocation ¶
type ArrayLocation struct {
ContainerPath string `json:"container_path"` // Path to the container
ArrayFieldName string `json:"array_field_name"` // Name of the array field
ContainerRef any `json:"-"` // Reference to the container (not serialized)
}
ArrayLocation represents the location of an array in the data structure
type ArrayUtils ¶
type ArrayUtils struct{}
ArrayUtils provides unified array index and slice operations
func NewArrayUtils ¶
func NewArrayUtils() *ArrayUtils
NewArrayUtils creates a new array utilities instance
func (*ArrayUtils) GetSafeArrayElement ¶
func (au *ArrayUtils) GetSafeArrayElement(arr []any, index int) (any, bool)
GetSafeArrayElement safely gets an array element with bounds checking
func (*ArrayUtils) IsValidIndex ¶
func (au *ArrayUtils) IsValidIndex(index, length int) bool
IsValidIndex checks if an index is valid for the given array length
func (*ArrayUtils) NormalizeIndex ¶
func (au *ArrayUtils) NormalizeIndex(index, length int) int
NormalizeIndex normalizes array index, handling negative indices
func (*ArrayUtils) NormalizeSlice ¶
func (au *ArrayUtils) NormalizeSlice(start, end, length int) (int, int)
NormalizeSlice normalizes slice bounds, handling negative indices and bounds checking
func (*ArrayUtils) ParseArrayIndex ¶
func (au *ArrayUtils) ParseArrayIndex(property string) int
ParseArrayIndex parses array index with performance, supporting negative indices
func (*ArrayUtils) ParseSliceComponents ¶
func (au *ArrayUtils) ParseSliceComponents(slicePart string) (start, end, step *int, err error)
ParseSliceComponents parses slice syntax like "1:3", "::2", "::-1" into components
func (*ArrayUtils) ParseSliceFromSegment ¶
func (au *ArrayUtils) ParseSliceFromSegment(segmentValue string) (start, end, step int)
ParseSliceFromSegment parses slice parameters from a segment string
func (*ArrayUtils) ParseSliceParameters ¶
func (au *ArrayUtils) ParseSliceParameters(segmentValue string, arrayLength int) (start, end, step int, err error)
ParseSliceParameters parses slice parameters with bounds checking
func (*ArrayUtils) PerformArraySlice ¶
func (au *ArrayUtils) PerformArraySlice(arr []any, start, end, step *int) []any
PerformArraySlice performs Python-style array slicing
type CacheInterface ¶
type CacheInterface interface {
Get(key string) (any, bool)
Set(key string, value any)
ClearCache()
GetStats() interface{} // Returns CacheStats but as interface{} to avoid circular dependency
}
CacheInterface defines the interface for cache operations
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 cache
func (*CacheManager) ClearCache ¶
func (cm *CacheManager) ClearCache()
ClearCache clears all cached data
func (*CacheManager) Get ¶
func (cm *CacheManager) Get(key string) (any, bool)
Get retrieves a value from cache with enhanced concurrency
func (*CacheManager) GetCacheSize ¶
func (cm *CacheManager) GetCacheSize() int64
GetCacheSize returns the total number of cached entries
func (*CacheManager) GetStats ¶
func (cm *CacheManager) GetStats() CacheStats
GetStats returns cache statistics
func (*CacheManager) SecureHash ¶
func (cm *CacheManager) SecureHash(input string) string
SecureHash creates a secure hash for cache keys using SHA-256
func (*CacheManager) Set ¶
func (cm *CacheManager) Set(key string, value any)
Set stores a value in cache
type CacheStats ¶
type CacheStats struct {
Size int64 `json:"size"`
Memory int64 `json:"memory"`
HitCount int64 `json:"hit_count"`
MissCount int64 `json:"miss_count"`
HitRatio float64 `json:"hit_ratio"`
Evictions int64 `json:"evictions"`
}
CacheStats represents cache statistics
type CheckResult ¶
CheckResult represents the result of a single health check
type ConfigInterface ¶
type ConfigInterface interface {
// Cache configuration
IsCacheEnabled() bool
GetMaxCacheSize() int
GetCacheTTL() time.Duration
// Performance configuration
GetMaxJSONSize() int64
GetMaxPathDepth() int
GetMaxConcurrency() int
IsMetricsEnabled() bool
IsHealthCheckEnabled() bool
// Parsing configuration
IsStrictMode() bool
AllowComments() bool
PreserveNumbers() bool
// Operation configuration
ShouldCreatePaths() bool
ShouldCleanupNulls() bool
ShouldCompactArrays() bool
// Security configuration
ShouldValidateInput() bool
GetMaxNestingDepth() int
IsRateLimitEnabled() bool
GetRateLimitPerSec() int
ShouldValidateFilePath() bool
// Memory management
AreResourcePoolsEnabled() bool
GetMaxPoolSize() int
GetPoolCleanupInterval() time.Duration
}
ConfigInterface defines the interface for configuration objects
type EncodeConfigInterface ¶
type EncodeConfigInterface interface {
// Formatting options
IsPretty() bool
GetIndent() string
GetPrefix() string
ShouldSortKeys() bool
ShouldEscapeHTML() bool
// Output options
IsCompactOutput() bool
HasTrailingComma() bool
// Number formatting
ShouldPreserveNumbers() bool
GetFloatPrecision() int
// String handling
ShouldEscapeUnicode() bool
GetQuoteStyle() int
// Advanced options
ShouldOmitEmpty() bool
ShouldIncludeNulls() bool
ShouldValidateUTF8() bool
GetMaxDepth() int
GetBufferSize() int
}
EncodeConfigInterface defines the interface for encoding configuration
type HealthChecker ¶
type HealthChecker struct {
// contains filtered or unexported fields
}
HealthChecker provides health checking functionality for the JSON processor
func NewHealthChecker ¶
func NewHealthChecker(processor interface{}, metrics *MetricsCollector) *HealthChecker
NewHealthChecker creates a new health checker
func (*HealthChecker) CheckHealth ¶
func (hc *HealthChecker) CheckHealth() HealthStatus
CheckHealth performs comprehensive health checks
type HealthCheckerInterface ¶
type HealthCheckerInterface interface {
CheckHealth() interface{} // Returns HealthStatus but as interface{} to avoid circular dependency
}
HealthCheckerInterface defines the interface for health checking
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
func (*HealthStatus) IsHealthy ¶
func (hs *HealthStatus) IsHealthy() bool
IsHealthy returns true if all health checks passed
type MappingInfo ¶
type MappingInfo struct {
OriginalContainers []any `json:"-"` // Original container references
ArrayFieldName string `json:"array_field_name"` // Array field name
TargetIndices []int `json:"target_indices"` // Target indices for each container
}
MappingInfo holds information for reverse mapping operations
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
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 (thread-safe)
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
type MetricsInterface ¶
type MetricsInterface interface {
RecordOperation(duration time.Duration, success bool, memoryUsed int64)
RecordCacheHit()
RecordCacheMiss()
StartConcurrentOperation()
EndConcurrentOperation()
RecordError(errorType string)
GetMetrics() interface{} // Returns Metrics but as interface{} to avoid circular dependency
Reset()
GetSummary() string
}
MetricsInterface defines the interface for metrics collection
type OperationContext ¶
type OperationContext struct {
ExtractionPath string `json:"extraction_path"` // Path used for extraction
TargetArrays []ArrayLocation `json:"target_arrays"` // Target array locations
OperationType string `json:"operation_type"` // "get", "set", "delete"
}
OperationContext holds context information for distributed operations
type PathParser ¶
type PathParser struct {
// contains filtered or unexported fields
}
PathParser handles parsing of JSON paths
func (*PathParser) ParseComplexSegment ¶
func (pp *PathParser) ParseComplexSegment(part string) ([]PathSegment, error)
ParseComplexSegment parses a complex segment that may contain mixed syntax
func (*PathParser) ParsePath ¶
func (pp *PathParser) ParsePath(path string) ([]PathSegment, error)
ParsePath parses a JSON path string into segments
func (*PathParser) ValidatePath ¶
func (pp *PathParser) ValidatePath(path string) error
ValidatePath validates a path string for security and correctness
type PathParserInterface ¶
type PathParserInterface interface {
ParsePath(path string) ([]interface{}, error) // Returns []PathSegment but as []interface{}
ValidatePath(path string) error
SplitPathIntoSegments(path string) []interface{} // Returns []PathSegmentInfo but as []interface{}
}
PathParserInterface defines the interface for path parsing (internal use)
type PathPatterns ¶
type PathPatterns struct {
// Compiled patterns for common operations
SimpleProperty *regexp.Regexp
NumericIndex *regexp.Regexp
// contains filtered or unexported fields
}
PathPatterns holds compiled regex patterns for path parsing
func NewPathPatterns ¶
func NewPathPatterns() *PathPatterns
NewPathPatterns creates and compiles all path parsing patterns
type PathSegment ¶
type PathSegment struct {
// New structured fields
Type PathSegmentType `json:"type"`
Key string `json:"key"`
Index int `json:"index"`
Start *int `json:"start,omitempty"`
End *int `json:"end,omitempty"`
Step *int `json:"step,omitempty"`
IsNegative bool `json:"is_negative"`
IsSlice bool `json:"is_slice"`
IsWildcard bool `json:"is_wildcard"`
IsFlat bool `json:"is_flat"` // Whether this is a flat extraction operation
// Distributed operation support
IsDistributed bool `json:"is_distributed"` // Whether this is a distributed operation
OperationContext *OperationContext `json:"operation_context"` // Operation context for distributed operations
MappingInfo *MappingInfo `json:"mapping_info"` // Reverse mapping information
Value string `json:"value"` // The actual segment value
Extract string `json:"extract"` // For extract operations: the property to extract
}
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 NewLegacyPathSegment ¶
func NewLegacyPathSegment(typeStr, value string) PathSegment
NewLegacyPathSegment creates a PathSegment from legacy string type
func NewPropertySegment ¶
func NewPropertySegment(key string) PathSegment
NewPropertySegment creates a property access segment
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
type ProcessorOptionsInterface ¶
type ProcessorOptionsInterface interface {
GetContext() interface{} // Returns context.Context but as interface{} to avoid import
ShouldCacheResults() bool
IsStrictMode() bool
GetMaxDepth() int
AllowComments() bool
PreserveNumbers() bool
ShouldCreatePaths() bool
ShouldCleanupNulls() bool
ShouldCompactArrays() bool
}
ProcessorOptionsInterface defines the interface for processor options
type StatsInterface ¶
type StatsInterface interface {
GetCacheSize() int64
GetCacheMemory() int64
GetMaxCacheSize() int
GetHitCount() int64
GetMissCount() int64
GetHitRatio() float64
GetCacheTTL() time.Duration
IsCacheEnabled() bool
GetOperationCount() int64
GetErrorCount() int64
}
StatsInterface defines the interface for statistics