Documentation
¶
Index ¶
- Variables
- func GetAttr(elem xml.StartElement, name string) string
- func GetResults[T any](rs *ResultStore, resultType string) []T
- func LoadFromScope[T any](hctx *HandlerContext, key string) (T, bool)
- func ScopeLoad[T any](scope *ScopeContext, key string) (T, bool)
- func ScopeStore[T any](scope *ScopeContext, key string, value T)
- func SessionLoad[T any](sm *SessionManager, path string) (T, bool)
- func SessionStore[T any](sm *SessionManager, path string, value T)
- func StoreInScope[T any](hctx *HandlerContext, key string, value T)
- type ContextServices
- type FuncHandler
- type Handler
- type HandlerContext
- type HandlerFunc
- type MetricsCollector
- type Middleware
- type ParseOptions
- type ParseResult
- type Parser
- func (p *Parser) Close(time.Duration) error
- func (p *Parser) Metrics() map[string]interface{}
- func (p *Parser) Parse(ctx context.Context, r io.Reader) (*ParseResult, error)
- func (p *Parser) ParseFile(ctx context.Context, filename string) (*ParseResult, error)
- func (p *Parser) Register(handler Handler, selector Selector) *Parser
- func (p *Parser) RegisterHandler(handler Handler) *Parser
- type ProcessingEngine
- type ResultStore
- type Route
- type Router
- type ScopeContext
- type ScopeStack
- type Selectable
- type Selector
- type SessionManager
- type StreamingHandler
- type TypedHandler
- type TypedHandlerBuilder
- func (b *TypedHandlerBuilder[T, R]) Build() Handler
- func (b *TypedHandlerBuilder[T, R]) WithContextCreator(f func(*HandlerContext) T) *TypedHandlerBuilder[T, R]
- func (b *TypedHandlerBuilder[T, R]) WithEndProcessor(f func(context.Context, T, *HandlerContext) (R, error)) *TypedHandlerBuilder[T, R]
- func (b *TypedHandlerBuilder[T, R]) WithResultHandler(f func(context.Context, R, *HandlerContext) error) *TypedHandlerBuilder[T, R]
- func (b *TypedHandlerBuilder[T, R]) WithStartMiddleware(m ...Middleware) *TypedHandlerBuilder[T, R]
- func (b *TypedHandlerBuilder[T, R]) WithStartProcessor(f func(context.Context, T, *HandlerContext) error) *TypedHandlerBuilder[T, R]
Constants ¶
This section is empty.
Variables ¶
var Select = struct { Element func(...string) Selector }{ Element: func(elements ...string) Selector { return func(path string) bool { name := path if slash := strings.LastIndexByte(path, '/'); slash >= 0 { name = path[slash+1:] } for _, element := range elements { if name == element { return true } } return false } }, }
Functions ¶
func GetResults ¶
func GetResults[T any](rs *ResultStore, resultType string) []T
func LoadFromScope ¶
func LoadFromScope[T any](hctx *HandlerContext, key string) (T, bool)
func ScopeStore ¶
func ScopeStore[T any](scope *ScopeContext, key string, value T)
func SessionLoad ¶
func SessionLoad[T any](sm *SessionManager, path string) (T, bool)
func SessionStore ¶
func SessionStore[T any](sm *SessionManager, path string, value T)
Type-safe session storage
func StoreInScope ¶
func StoreInScope[T any](hctx *HandlerContext, key string, value T)
Types ¶
type ContextServices ¶
type ContextServices struct {
// contains filtered or unexported fields
}
type FuncHandler ¶
type FuncHandler struct {
// contains filtered or unexported fields
}
func (*FuncHandler) End ¶
func (f *FuncHandler) End() HandlerFunc
func (*FuncHandler) Selector ¶
func (f *FuncHandler) Selector() Selector
func (*FuncHandler) Start ¶
func (f *FuncHandler) Start() HandlerFunc
type Handler ¶
type Handler interface {
Start() HandlerFunc
End() HandlerFunc
}
func NewFuncHandler ¶
func NewFuncHandler(selector Selector, start, end HandlerFunc) Handler
type HandlerContext ¶
type HandlerContext struct {
Path string
Element xml.StartElement
Text string
// contains filtered or unexported fields
}
HandlerContext is the immutable XML view plus the small set of shared services handlers need while a token is processed.
func NewHandlerContext ¶
func NewHandlerContext(path string, element xml.StartElement, text string, services *ContextServices) *HandlerContext
func (*HandlerContext) IncrementCounter ¶
func (hctx *HandlerContext) IncrementCounter(name string)
func (*HandlerContext) RecordDuration ¶
func (hctx *HandlerContext) RecordDuration(name string, duration time.Duration)
func (*HandlerContext) RecordError ¶
func (hctx *HandlerContext) RecordError(err error)
func (*HandlerContext) StoreResult ¶
func (hctx *HandlerContext) StoreResult(resultType string, result any)
type HandlerFunc ¶
type HandlerFunc func(ctx context.Context, hctx *HandlerContext) error
HandlerFunc is the basic handler signature for both Start and End
type MetricsCollector ¶
type MetricsCollector struct {
// contains filtered or unexported fields
}
func NewMetricsCollector ¶
func NewMetricsCollector() *MetricsCollector
func (*MetricsCollector) IncrementCounter ¶
func (m *MetricsCollector) IncrementCounter(name string)
func (*MetricsCollector) RecordDuration ¶
func (m *MetricsCollector) RecordDuration(name string, duration time.Duration)
func (*MetricsCollector) RecordError ¶
func (m *MetricsCollector) RecordError(error, string)
func (*MetricsCollector) ToJSON ¶
func (m *MetricsCollector) ToJSON() map[string]any
type Middleware ¶
type Middleware func(HandlerFunc) HandlerFunc
Middleware wraps a HandlerFunc to add behavior
func Chain ¶
func Chain(middlewares ...Middleware) Middleware
Chain combines multiple middleware into one
func MetricsMiddleware ¶
func MetricsMiddleware(metricName string) Middleware
MetricsMiddleware now uses the clean API
type ParseOptions ¶
type ParseOptions struct {
// Middleware to apply to all handlers
GlobalStartMiddleware []Middleware
GlobalEndMiddleware []Middleware
// Performance tuning
EnableMetrics bool
// Error handling
StopOnError bool
}
ParseOptions configures the parsing behavior
func DefaultParseOptions ¶
func DefaultParseOptions() ParseOptions
DefaultParseOptions provides sensible defaults
type ParseResult ¶
type ParseResult struct {
StartTime time.Time
EndTime time.Time
Duration time.Duration
Engine *ProcessingEngine
Errors []error
}
func (*ParseResult) Results ¶
func (pr *ParseResult) Results() *ResultStore
Results returns the result collector
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
func NewParser ¶
func NewParser(opts ParseOptions) *Parser
func (*Parser) Close ¶
Close preserves a symmetric lifecycle for callers. All parser resources are synchronous, so there is nothing to drain.
func (*Parser) RegisterHandler ¶
RegisterHandler registers a handler that exposes its own Selector().
type ProcessingEngine ¶
type ProcessingEngine struct {
// contains filtered or unexported fields
}
func NewProcessingEngine ¶
func NewProcessingEngine() *ProcessingEngine
func (*ProcessingEngine) CreateContext ¶
func (pe *ProcessingEngine) CreateContext(path string, element xml.StartElement, text string) *HandlerContext
type ResultStore ¶
type ResultStore struct {
// contains filtered or unexported fields
}
ResultStore is the deliberately small handoff between streaming Pass 1 handlers and the ARM pipeline.
func NewResultStore ¶
func NewResultStore() *ResultStore
func (*ResultStore) StoreWithPath ¶
func (rs *ResultStore) StoreWithPath(resultType, _ string, result any)
type ScopeContext ¶
type ScopeContext struct {
Parent *ScopeContext
// contains filtered or unexported fields
}
type ScopeStack ¶
type ScopeStack struct {
// contains filtered or unexported fields
}
func NewScopeStack ¶
func NewScopeStack() *ScopeStack
func (*ScopeStack) Current ¶
func (sm *ScopeStack) Current() *ScopeContext
func (*ScopeStack) Pop ¶
func (sm *ScopeStack) Pop()
func (*ScopeStack) Push ¶
func (sm *ScopeStack) Push(_ string)
type Selectable ¶
type Selectable interface {
Selector() Selector
}
Selectable is implemented by handlers that carry their own path selector.
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
func NewSessionManager ¶
func NewSessionManager() *SessionManager
func (*SessionManager) Delete ¶
func (sm *SessionManager) Delete(path string)
func (*SessionManager) Store ¶
func (sm *SessionManager) Store(path string, data any)
type StreamingHandler ¶
type StreamingHandler struct {
// contains filtered or unexported fields
}
func NewStreamingHandler ¶
func NewStreamingHandler(router *Router, engine *ProcessingEngine) *StreamingHandler
func (*StreamingHandler) HandleCharData ¶
func (*StreamingHandler) HandleEndElement ¶
func (h *StreamingHandler) HandleEndElement(ctx context.Context, ee xml.EndElement) error
func (*StreamingHandler) HandleStartElement ¶
func (h *StreamingHandler) HandleStartElement(ctx context.Context, se xml.StartElement) error
type TypedHandler ¶
TypedHandler now composes middleware with typed processing
func (*TypedHandler[T, R]) End ¶
func (h *TypedHandler[T, R]) End() HandlerFunc
func (*TypedHandler[T, R]) Selector ¶
func (h *TypedHandler[T, R]) Selector() Selector
Selector returns the path selector for this handler.
func (*TypedHandler[T, R]) Start ¶
func (h *TypedHandler[T, R]) Start() HandlerFunc
type TypedHandlerBuilder ¶
type TypedHandlerBuilder[TContext any, TResult any] struct { // contains filtered or unexported fields }
Builder pattern for clean configuration
func NewTypedHandlerBuilder ¶
func NewTypedHandlerBuilder[TContext any, TResult any](name string, selector Selector) *TypedHandlerBuilder[TContext, TResult]
func (*TypedHandlerBuilder[T, R]) Build ¶
func (b *TypedHandlerBuilder[T, R]) Build() Handler
func (*TypedHandlerBuilder[T, R]) WithContextCreator ¶
func (b *TypedHandlerBuilder[T, R]) WithContextCreator(f func(*HandlerContext) T) *TypedHandlerBuilder[T, R]
func (*TypedHandlerBuilder[T, R]) WithEndProcessor ¶
func (b *TypedHandlerBuilder[T, R]) WithEndProcessor(f func(context.Context, T, *HandlerContext) (R, error)) *TypedHandlerBuilder[T, R]
func (*TypedHandlerBuilder[T, R]) WithResultHandler ¶
func (b *TypedHandlerBuilder[T, R]) WithResultHandler(f func(context.Context, R, *HandlerContext) error) *TypedHandlerBuilder[T, R]
func (*TypedHandlerBuilder[T, R]) WithStartMiddleware ¶
func (b *TypedHandlerBuilder[T, R]) WithStartMiddleware(m ...Middleware) *TypedHandlerBuilder[T, R]
func (*TypedHandlerBuilder[T, R]) WithStartProcessor ¶
func (b *TypedHandlerBuilder[T, R]) WithStartProcessor(f func(context.Context, T, *HandlerContext) error) *TypedHandlerBuilder[T, R]