Documentation
¶
Overview ¶
Package loader provides functionality for loading templates from various sources.
Package loader provides functionality for loading templates from various sources.
Package loader provides functionality for loading templates from various sources.
Package loader provides functionality for loading templates from various sources.
Index ¶
- type LoaderStats
- type OptimizedTemplateLoader
- func (l *OptimizedTemplateLoader) ClearAllSourceIndices()
- func (l *OptimizedTemplateLoader) ClearCache()
- func (l *OptimizedTemplateLoader) ClearSourceIndex(source string, sourceType string)
- func (l *OptimizedTemplateLoader) GetCacheStats() map[string]interface{}
- func (l *OptimizedTemplateLoader) GetLoaderStats() map[string]interface{}
- func (l *OptimizedTemplateLoader) LoadTemplate(ctx context.Context, source string, sourceType string) (*format.Template, error)
- func (l *OptimizedTemplateLoader) LoadTemplateWithTimeout(ctx context.Context, source string, sourceType string, timeout time.Duration) (*format.Template, error)
- func (l *OptimizedTemplateLoader) LoadTemplates(ctx context.Context, source string, sourceType string) ([]*format.Template, error)
- func (l *OptimizedTemplateLoader) LoadTemplatesWithTimeout(ctx context.Context, source string, sourceType string, timeout time.Duration) ([]*format.Template, error)
- func (l *OptimizedTemplateLoader) SetConcurrencyLimit(limit int)
- type OptimizerStats
- type ResourceEfficientLoader
- func (l *ResourceEfficientLoader) ClearAllSourceIndices()
- func (l *ResourceEfficientLoader) ClearCache()
- func (l *ResourceEfficientLoader) ClearSourceIndex(source string, sourceType string)
- func (l *ResourceEfficientLoader) GetLoaderStats() map[string]interface{}
- func (l *ResourceEfficientLoader) LoadTemplate(ctx context.Context, source string, sourceType string) (*format.Template, error)
- func (l *ResourceEfficientLoader) LoadTemplates(ctx context.Context, source string, sourceType string) ([]*format.Template, error)
- func (l *ResourceEfficientLoader) SetConcurrencyLimit(limit int)
- type ResourceEfficientLoaderOptions
- type SourceIndex
- type TemplateLoader
- func (l *TemplateLoader) ClearCache()
- func (l *TemplateLoader) GetCacheSize() int
- func (l *TemplateLoader) Load(filePath string) (*format.Template, error)
- func (l *TemplateLoader) LoadBatch(directory string) ([]*format.Template, error)
- func (l *TemplateLoader) LoadFromBytes(data []byte, formatType string) (*format.Template, error)
- func (l *TemplateLoader) LoadFromPath(ctx context.Context, path string, recursive bool) ([]*format.Template, error)
- func (l *TemplateLoader) LoadFromRepository(ctx context.Context, repoURL string, options map[string]interface{}) ([]*format.Template, error)
- func (l *TemplateLoader) LoadTemplate(ctx context.Context, source string, sourceType string) (*format.Template, error)
- func (l *TemplateLoader) LoadTemplateWithTimeout(ctx context.Context, source string, sourceType string, timeout time.Duration) (*format.Template, error)
- func (l *TemplateLoader) LoadTemplates(ctx context.Context, source string, sourceType string) ([]*format.Template, error)
- func (l *TemplateLoader) LoadTemplatesWithTimeout(ctx context.Context, source string, sourceType string, timeout time.Duration) ([]*format.Template, error)
- func (l *TemplateLoader) PruneCache() int
- type TemplateOptimizer
- func (o *TemplateOptimizer) GetOptimizationStats() map[string]interface{}
- func (o *TemplateOptimizer) OptimizeTemplate(template *format.Template) (*format.Template, error)
- func (o *TemplateOptimizer) OptimizeTemplates(templates []*format.Template) ([]*format.Template, error)
- func (o *TemplateOptimizer) SetCompressEnabled(enabled bool)
- func (o *TemplateOptimizer) SetMinifyEnabled(enabled bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LoaderStats ¶
type LoaderStats struct {
// TotalLoads is the total number of template loads
TotalLoads int64
// CacheHits is the number of cache hits
CacheHits int64
// CacheMisses is the number of cache misses
CacheMisses int64
// LoadErrors is the number of load errors
LoadErrors int64
// TotalLoadTime is the total time spent loading templates
TotalLoadTime time.Duration
}
LoaderStats tracks loader statistics
type OptimizedTemplateLoader ¶
type OptimizedTemplateLoader struct {
// contains filtered or unexported fields
}
OptimizedTemplateLoader is an enhanced template loader with lazy loading and improved performance
func NewOptimizedTemplateLoader ¶
func NewOptimizedTemplateLoader(cacheTTL time.Duration, maxCacheSize int, repoManager *repository.Manager, concurrencyLimit int) *OptimizedTemplateLoader
NewOptimizedTemplateLoader creates a new optimized template loader
func (*OptimizedTemplateLoader) ClearAllSourceIndices ¶
func (l *OptimizedTemplateLoader) ClearAllSourceIndices()
ClearAllSourceIndices clears all source indices
func (*OptimizedTemplateLoader) ClearCache ¶
func (l *OptimizedTemplateLoader) ClearCache()
ClearCache clears the template cache
func (*OptimizedTemplateLoader) ClearSourceIndex ¶
func (l *OptimizedTemplateLoader) ClearSourceIndex(source string, sourceType string)
ClearSourceIndex clears the source index for a specific source
func (*OptimizedTemplateLoader) GetCacheStats ¶
func (l *OptimizedTemplateLoader) GetCacheStats() map[string]interface{}
GetCacheStats returns statistics about the cache
func (*OptimizedTemplateLoader) GetLoaderStats ¶
func (l *OptimizedTemplateLoader) GetLoaderStats() map[string]interface{}
GetLoaderStats returns statistics about the loader
func (*OptimizedTemplateLoader) LoadTemplate ¶
func (l *OptimizedTemplateLoader) LoadTemplate(ctx context.Context, source string, sourceType string) (*format.Template, error)
LoadTemplate loads a template from a source
func (*OptimizedTemplateLoader) LoadTemplateWithTimeout ¶
func (l *OptimizedTemplateLoader) LoadTemplateWithTimeout(ctx context.Context, source string, sourceType string, timeout time.Duration) (*format.Template, error)
LoadTemplateWithTimeout loads a template with a timeout
func (*OptimizedTemplateLoader) LoadTemplates ¶
func (l *OptimizedTemplateLoader) LoadTemplates(ctx context.Context, source string, sourceType string) ([]*format.Template, error)
LoadTemplates loads multiple templates from a source
func (*OptimizedTemplateLoader) LoadTemplatesWithTimeout ¶
func (l *OptimizedTemplateLoader) LoadTemplatesWithTimeout(ctx context.Context, source string, sourceType string, timeout time.Duration) ([]*format.Template, error)
LoadTemplatesWithTimeout loads multiple templates with a timeout
func (*OptimizedTemplateLoader) SetConcurrencyLimit ¶
func (l *OptimizedTemplateLoader) SetConcurrencyLimit(limit int)
SetConcurrencyLimit sets the concurrency limit for loading operations
type OptimizerStats ¶
type OptimizerStats struct {
// TotalOptimizations is the total number of template optimizations
TotalOptimizations int64
// TotalBytesOriginal is the total size of templates before optimization
TotalBytesOriginal int64
// TotalBytesOptimized is the total size of templates after optimization
TotalBytesOptimized int64
// CompressionRatio is the average compression ratio
CompressionRatio float64
}
OptimizerStats tracks optimizer statistics
type ResourceEfficientLoader ¶
type ResourceEfficientLoader struct {
// contains filtered or unexported fields
}
ResourceEfficientLoader is a template loader optimized for minimal resource usage
func NewResourceEfficientLoader ¶
func NewResourceEfficientLoader(repoManager *repository.Manager, options ResourceEfficientLoaderOptions) *ResourceEfficientLoader
NewResourceEfficientLoader creates a new resource-efficient template loader
func (*ResourceEfficientLoader) ClearAllSourceIndices ¶
func (l *ResourceEfficientLoader) ClearAllSourceIndices()
ClearAllSourceIndices clears all source indices
func (*ResourceEfficientLoader) ClearCache ¶
func (l *ResourceEfficientLoader) ClearCache()
ClearCache clears the template cache
func (*ResourceEfficientLoader) ClearSourceIndex ¶
func (l *ResourceEfficientLoader) ClearSourceIndex(source string, sourceType string)
ClearSourceIndex clears the source index for a specific source
func (*ResourceEfficientLoader) GetLoaderStats ¶
func (l *ResourceEfficientLoader) GetLoaderStats() map[string]interface{}
GetLoaderStats returns statistics about the loader
func (*ResourceEfficientLoader) LoadTemplate ¶
func (l *ResourceEfficientLoader) LoadTemplate(ctx context.Context, source string, sourceType string) (*format.Template, error)
LoadTemplate loads a template from a source
func (*ResourceEfficientLoader) LoadTemplates ¶
func (l *ResourceEfficientLoader) LoadTemplates(ctx context.Context, source string, sourceType string) ([]*format.Template, error)
LoadTemplates loads multiple templates from a source
func (*ResourceEfficientLoader) SetConcurrencyLimit ¶
func (l *ResourceEfficientLoader) SetConcurrencyLimit(limit int)
SetConcurrencyLimit sets the concurrency limit for loading operations
type ResourceEfficientLoaderOptions ¶
type ResourceEfficientLoaderOptions struct {
// CacheTTL is the time-to-live for cached templates
CacheTTL time.Duration
// MaxCacheSize is the maximum number of templates in the cache
MaxCacheSize int
// ConcurrencyLimit limits concurrent loading operations
ConcurrencyLimit int
// EnableOptimization enables template optimization
EnableOptimization bool
// EnableStructureOptimization enables template structure optimization
EnableStructureOptimization bool
// EnableCompression enables template compression
EnableCompression bool
// EnableMinification enables template minification
EnableMinification bool
// ChunkSize is the size of chunks for streaming operations
ChunkSize int
// MaxMemoryUsage is the maximum memory usage in bytes
MaxMemoryUsage int64
}
ResourceEfficientLoaderOptions contains configuration options for the loader
type SourceIndex ¶
type SourceIndex struct {
// Type is the type of the source
Type string
// Path is the path to the source
Path string
// LastIndexed is the time the source was last indexed
LastIndexed time.Time
// TemplateIDs is a list of template IDs in the source
TemplateIDs []string
// FileMap maps template IDs to file paths
FileMap map[string]string
// Metadata contains additional metadata about the source
Metadata map[string]interface{}
}
SourceIndex contains metadata about a template source
type TemplateLoader ¶
type TemplateLoader struct {
// contains filtered or unexported fields
}
TemplateLoader is responsible for loading templates from various sources
func NewTemplateLoader ¶
func NewTemplateLoader(cacheTTL time.Duration, repoManager *repository.Manager) *TemplateLoader
NewTemplateLoader creates a new template loader
func (*TemplateLoader) ClearCache ¶
func (l *TemplateLoader) ClearCache()
ClearCache clears the template cache
func (*TemplateLoader) GetCacheSize ¶
func (l *TemplateLoader) GetCacheSize() int
GetCacheSize returns the number of templates in the cache
func (*TemplateLoader) Load ¶
func (l *TemplateLoader) Load(filePath string) (*format.Template, error)
Load loads a template from a file
func (*TemplateLoader) LoadBatch ¶
func (l *TemplateLoader) LoadBatch(directory string) ([]*format.Template, error)
LoadBatch loads multiple templates from a directory
func (*TemplateLoader) LoadFromBytes ¶
LoadFromBytes loads a template from bytes
func (*TemplateLoader) LoadFromPath ¶
func (l *TemplateLoader) LoadFromPath(ctx context.Context, path string, recursive bool) ([]*format.Template, error)
LoadFromPath loads templates from a specific path
func (*TemplateLoader) LoadFromRepository ¶
func (l *TemplateLoader) LoadFromRepository(ctx context.Context, repoURL string, options map[string]interface{}) ([]*format.Template, error)
LoadFromRepository loads templates from a remote repository
func (*TemplateLoader) LoadTemplate ¶
func (l *TemplateLoader) LoadTemplate(ctx context.Context, source string, sourceType string) (*format.Template, error)
LoadTemplate loads a template from a source
func (*TemplateLoader) LoadTemplateWithTimeout ¶
func (l *TemplateLoader) LoadTemplateWithTimeout(ctx context.Context, source string, sourceType string, timeout time.Duration) (*format.Template, error)
LoadTemplateWithTimeout loads a template with a timeout
func (*TemplateLoader) LoadTemplates ¶
func (l *TemplateLoader) LoadTemplates(ctx context.Context, source string, sourceType string) ([]*format.Template, error)
LoadTemplates loads multiple templates from a source
func (*TemplateLoader) LoadTemplatesWithTimeout ¶
func (l *TemplateLoader) LoadTemplatesWithTimeout(ctx context.Context, source string, sourceType string, timeout time.Duration) ([]*format.Template, error)
LoadTemplatesWithTimeout loads multiple templates with a timeout
func (*TemplateLoader) PruneCache ¶
func (l *TemplateLoader) PruneCache() int
PruneCache removes expired entries from the cache
type TemplateOptimizer ¶
type TemplateOptimizer struct {
// contains filtered or unexported fields
}
TemplateOptimizer provides functionality for optimizing templates
func NewTemplateOptimizer ¶
func NewTemplateOptimizer(minifyEnabled, compressEnabled bool) *TemplateOptimizer
NewTemplateOptimizer creates a new template optimizer
func (*TemplateOptimizer) GetOptimizationStats ¶
func (o *TemplateOptimizer) GetOptimizationStats() map[string]interface{}
GetOptimizationStats returns statistics about the optimizer
func (*TemplateOptimizer) OptimizeTemplate ¶
OptimizeTemplate optimizes a template by applying various optimizations
func (*TemplateOptimizer) OptimizeTemplates ¶
func (o *TemplateOptimizer) OptimizeTemplates(templates []*format.Template) ([]*format.Template, error)
OptimizeTemplates optimizes multiple templates
func (*TemplateOptimizer) SetCompressEnabled ¶
func (o *TemplateOptimizer) SetCompressEnabled(enabled bool)
SetCompressEnabled enables or disables compression
func (*TemplateOptimizer) SetMinifyEnabled ¶
func (o *TemplateOptimizer) SetMinifyEnabled(enabled bool)
SetMinifyEnabled enables or disables minification