funcs

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 15 Imported by: 1

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

Constants

This section is empty.

Variables

View Source
var DefaultRegexCache = NewRegexCache(500, 1000, 100*time.Millisecond)

DefaultRegexCache is a global regex cache for production use.

Functions

func Get

func Get(name string) (eval.FuncDef, bool)

Get retrieves a function from the global registry.

func Has

func Has(name string) bool

Has checks if a function exists in the global registry.

func List

func List() []string

List returns all function names from the global registry.

func Register

func Register(def eval.FuncDef)

Register adds a function to the global registry.

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 FuncDef

type FuncDef = eval.FuncDef

FuncDef is an alias for eval.FuncDef.

type NullTraceLogger

type NullTraceLogger struct{}

NullTraceLogger discards all trace output (useful for production).

func (NullTraceLogger) Log

Log does nothing.

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

func (c *RegexCache) Clear()

Clear removes all cached patterns.

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

func (c *RegexCache) MatchWithTimeout(ctx context.Context, pattern, s string) (bool, error)

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.

func GetRegistry

func GetRegistry() *Registry

GetRegistry returns the global registry.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new function registry.

func (*Registry) Get

func (r *Registry) Get(name string) (eval.FuncDef, bool)

Get retrieves a function by name.

func (*Registry) Has

func (r *Registry) Has(name string) bool

Has checks if a function exists.

func (*Registry) List

func (r *Registry) List() []string

List returns all registered function names.

func (*Registry) Register

func (r *Registry) Register(def eval.FuncDef)

Register adds a function to the registry.

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.

Jump to

Keyboard shortcuts

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