internal

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EscapeJSONPointer added in v1.1.0

func EscapeJSONPointer(s string) string

EscapeJSONPointer escapes special characters for JSON Pointer

func GetSafeArrayElement added in v1.0.7

func GetSafeArrayElement(arr []any, index int) (any, bool)

func IsValidIndex added in v1.0.7

func IsValidIndex(index, length int) bool

func NormalizeIndex added in v1.0.7

func NormalizeIndex(index, length int) int

func NormalizeSlice added in v1.0.7

func NormalizeSlice(start, end, length int) (int, int)

func ParseAndValidateArrayIndex added in v1.1.0

func ParseAndValidateArrayIndex(s string, arrayLength int) (int, bool)

ParseAndValidateArrayIndex parses a string as an array index and validates it against array length Returns the index and true if successful, 0 and false otherwise

func ParseArrayIndex added in v1.0.7

func ParseArrayIndex(property string) (int, bool)

func ParseSliceComponents added in v1.0.7

func ParseSliceComponents(slicePart string) (start, end, step *int, err error)

func PerformArraySlice added in v1.0.7

func PerformArraySlice(arr []any, start, end, step *int) []any

PerformArraySlice performs Python-style array slicing with optimized capacity calculation

func UnescapeJSONPointer added in v1.1.0

func UnescapeJSONPointer(s string) string

UnescapeJSONPointer unescapes JSON Pointer special characters

func ValidatePath added in v1.0.7

func ValidatePath(path string) error

ValidatePath validates a path string for security and correctness

Types

type CacheConfig added in v1.0.10

type CacheConfig interface {
	IsCacheEnabled() bool
	GetMaxCacheSize() int
	GetCacheTTL() time.Duration
}

CacheConfig provides the configuration needed by CacheManager This minimal interface avoids circular dependencies with the main json package

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 CacheConfig) *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() CacheStats

GetStats returns cache statistics

func (*CacheManager) Set

func (cm *CacheManager) Set(key string, value any)

Set stores a value in the cache

type CacheStats

type CacheStats struct {
	Entries          int64
	TotalMemory      int64
	HitCount         int64
	MissCount        int64
	HitRatio         float64
	MemoryEfficiency float64
	Evictions        int64
	ShardCount       int
}

CacheStats represents cache statistics

type CheckResult

type CheckResult struct {
	Healthy bool   `json:"healthy"`
	Message string `json:"message"`
}

CheckResult represents the result of a single health check

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

type HealthCheckerConfig struct {
	MaxMemoryBytes      uint64
	MaxErrorRatePercent float64
}

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) Reset

func (mc *MetricsCollector) Reset()

Reset resets all metrics

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL