Documentation
¶
Overview ¶
Package funcs provides FHIRPath function implementations.
Package funcs provides FHIRPath function implementations. This file contains type checking functions: is() and as()
According to FHIRPath specification: - is(type): Returns true if the input is of the specified type - as(type): Returns the input if it is of the specified type, otherwise empty
These functions are equivalent to the 'is' and 'as' operators but in function form. Example: Patient.name.first().is(HumanName) is equivalent to Patient.name.first() is HumanName
Index ¶
- Variables
- func Get(name string) (eval.FuncDef, bool)
- func Has(name string) bool
- func List() []string
- func Register(def eval.FuncDef)
- func SetTraceLogger(logger TraceLogger)
- type DefaultTraceLogger
- type FuncDef
- type NullTraceLogger
- type RegexCache
- func (c *RegexCache) Clear()
- func (c *RegexCache) Compile(pattern string) (*regexp.Regexp, error)
- func (c *RegexCache) MatchWithTimeout(ctx context.Context, pattern, s string) (bool, error)
- func (c *RegexCache) ReplaceWithTimeout(ctx context.Context, pattern, s, replacement string) (string, error)
- func (c *RegexCache) Size() int
- type Registry
- type TraceEntry
- type TraceLogger
Constants ¶
This section is empty.
Variables ¶
var DefaultRegexCache = NewRegexCache(500, 1000, 100*time.Millisecond)
DefaultRegexCache is a global regex cache for production use.
Functions ¶
func SetTraceLogger ¶
func SetTraceLogger(logger TraceLogger)
SetTraceLogger sets the global trace logger. Use NullTraceLogger{} to disable trace output in production.
Types ¶
type DefaultTraceLogger ¶
type DefaultTraceLogger struct {
// contains filtered or unexported fields
}
DefaultTraceLogger logs trace entries to stderr in JSON format.
func NewDefaultTraceLogger ¶
func NewDefaultTraceLogger(writer io.Writer, jsonFormat bool) *DefaultTraceLogger
NewDefaultTraceLogger creates a new default trace logger.
func (*DefaultTraceLogger) Log ¶
func (l *DefaultTraceLogger) Log(entry TraceEntry)
Log writes a trace entry to the logger's writer.
type NullTraceLogger ¶
type NullTraceLogger struct{}
NullTraceLogger discards all trace output (useful for production).
type RegexCache ¶
type RegexCache struct {
// contains filtered or unexported fields
}
RegexCache provides thread-safe caching of compiled regular expressions with LRU eviction and complexity limits for ReDoS protection.
func NewRegexCache ¶
func NewRegexCache(limit, maxLen int, timeout time.Duration) *RegexCache
NewRegexCache creates a new regex cache with the given parameters. - limit: maximum number of cached patterns - maxLen: maximum allowed pattern length (ReDoS protection) - timeout: default timeout for regex operations
func (*RegexCache) Compile ¶
func (c *RegexCache) Compile(pattern string) (*regexp.Regexp, error)
Compile compiles a regex pattern with caching and complexity validation.
func (*RegexCache) MatchWithTimeout ¶
MatchWithTimeout performs a regex match with timeout protection.
func (*RegexCache) ReplaceWithTimeout ¶
func (c *RegexCache) ReplaceWithTimeout(ctx context.Context, pattern, s, replacement string) (string, error)
ReplaceWithTimeout performs a regex replace with timeout protection.
func (*RegexCache) Size ¶
func (c *RegexCache) Size() int
Size returns the number of cached patterns.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds registered functions.
type TraceEntry ¶
type TraceEntry struct {
Timestamp time.Time `json:"timestamp"`
Name string `json:"name"`
Input interface{} `json:"input"`
Projection interface{} `json:"projection,omitempty"`
Count int `json:"count"`
}
TraceEntry represents a structured trace log entry.
type TraceLogger ¶
type TraceLogger interface {
Log(entry TraceEntry)
}
TraceLogger defines the interface for structured logging of trace() calls.
func GetTraceLogger ¶
func GetTraceLogger() TraceLogger
GetTraceLogger returns the current trace logger.