Documentation
¶
Index ¶
- type BaseMiddleware
- func (m *BaseMiddleware) AfterIndex(ctx context.Context, chunks []core.Chunk) error
- func (m *BaseMiddleware) AfterQuery(ctx context.Context, response *Response) error
- func (m *BaseMiddleware) BeforeIndex(ctx context.Context, source *Source) error
- func (m *BaseMiddleware) BeforeQuery(ctx context.Context, query *Query) error
- func (m *BaseMiddleware) Name() string
- type Cache
- type CacheMiddleware
- type Chain
- func (c *Chain) Add(middleware Middleware)
- func (c *Chain) AfterIndex(ctx context.Context, chunks []core.Chunk) error
- func (c *Chain) AfterQuery(ctx context.Context, response *Response) error
- func (c *Chain) BeforeIndex(ctx context.Context, source *Source) error
- func (c *Chain) BeforeQuery(ctx context.Context, query *Query) error
- type Logger
- type LoggingMiddleware
- func (m *LoggingMiddleware) AfterIndex(ctx context.Context, chunks []core.Chunk) error
- func (m *LoggingMiddleware) AfterQuery(ctx context.Context, response *Response) error
- func (m *LoggingMiddleware) BeforeIndex(ctx context.Context, source *Source) error
- func (m *LoggingMiddleware) BeforeQuery(ctx context.Context, query *Query) error
- type Metrics
- type MetricsMiddleware
- func (m *MetricsMiddleware) AfterIndex(ctx context.Context, chunks []core.Chunk) error
- func (m *MetricsMiddleware) AfterQuery(ctx context.Context, response *Response) error
- func (m *MetricsMiddleware) BeforeIndex(ctx context.Context, source *Source) error
- func (m *MetricsMiddleware) BeforeQuery(ctx context.Context, query *Query) error
- type Middleware
- type Query
- type RateLimitMiddleware
- type RateLimiter
- type Response
- type Source
- type TransformMiddleware
- type ValidationMiddleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseMiddleware ¶
type BaseMiddleware struct {
// contains filtered or unexported fields
}
BaseMiddleware provides a default implementation of Middleware Embed this in your custom middleware to only implement the methods you need
func NewBaseMiddleware ¶
func NewBaseMiddleware(name string) *BaseMiddleware
NewBaseMiddleware creates a new base middleware
func (*BaseMiddleware) AfterIndex ¶
AfterIndex is a no-op by default
func (*BaseMiddleware) AfterQuery ¶
func (m *BaseMiddleware) AfterQuery(ctx context.Context, response *Response) error
AfterQuery is a no-op by default
func (*BaseMiddleware) BeforeIndex ¶
func (m *BaseMiddleware) BeforeIndex(ctx context.Context, source *Source) error
BeforeIndex is a no-op by default
func (*BaseMiddleware) BeforeQuery ¶
func (m *BaseMiddleware) BeforeQuery(ctx context.Context, query *Query) error
BeforeQuery is a no-op by default
func (*BaseMiddleware) Name ¶
func (m *BaseMiddleware) Name() string
Name returns the middleware name
type Cache ¶
type Cache interface {
Get(ctx context.Context, key string) (*Response, bool)
Set(ctx context.Context, key string, response *Response, ttl time.Duration) error
}
Cache defines the cache interface
type CacheMiddleware ¶
type CacheMiddleware struct {
*BaseMiddleware
// contains filtered or unexported fields
}
CacheMiddleware provides caching for query results
func NewCacheMiddleware ¶
func NewCacheMiddleware(cache Cache) *CacheMiddleware
NewCacheMiddleware creates a new cache middleware
func (*CacheMiddleware) AfterQuery ¶
func (m *CacheMiddleware) AfterQuery(ctx context.Context, response *Response) error
AfterQuery stores response in cache
func (*CacheMiddleware) BeforeQuery ¶
func (m *CacheMiddleware) BeforeQuery(ctx context.Context, query *Query) error
BeforeQuery checks cache before query
type Chain ¶
type Chain struct {
// contains filtered or unexported fields
}
Chain represents a middleware chain
func NewChain ¶
func NewChain(middlewares ...Middleware) *Chain
NewChain creates a new middleware chain
func (*Chain) AfterIndex ¶
AfterIndex executes all AfterIndex middleware
func (*Chain) AfterQuery ¶
AfterQuery executes all AfterQuery middleware
func (*Chain) BeforeIndex ¶
BeforeIndex executes all BeforeIndex middleware
type Logger ¶
type Logger interface {
Info(ctx context.Context, message string, fields map[string]interface{})
Debug(ctx context.Context, message string, fields map[string]interface{})
Error(ctx context.Context, message string, err error, fields map[string]interface{})
}
Logger defines the logging interface
type LoggingMiddleware ¶
type LoggingMiddleware struct {
*BaseMiddleware
// contains filtered or unexported fields
}
LoggingMiddleware logs indexing and query operations
func NewLoggingMiddleware ¶
func NewLoggingMiddleware(logger Logger) *LoggingMiddleware
NewLoggingMiddleware creates a new logging middleware
func (*LoggingMiddleware) AfterIndex ¶
AfterIndex logs after indexing
func (*LoggingMiddleware) AfterQuery ¶
func (m *LoggingMiddleware) AfterQuery(ctx context.Context, response *Response) error
AfterQuery logs after query
func (*LoggingMiddleware) BeforeIndex ¶
func (m *LoggingMiddleware) BeforeIndex(ctx context.Context, source *Source) error
BeforeIndex logs before indexing
func (*LoggingMiddleware) BeforeQuery ¶
func (m *LoggingMiddleware) BeforeQuery(ctx context.Context, query *Query) error
BeforeQuery logs before query
type Metrics ¶
type Metrics interface {
RecordIndexLatency(ctx context.Context, duration time.Duration)
RecordIndexCount(ctx context.Context, status string)
RecordQueryLatency(ctx context.Context, duration time.Duration)
RecordQueryCount(ctx context.Context, status string)
}
Metrics defines the metrics collection interface
type MetricsMiddleware ¶
type MetricsMiddleware struct {
*BaseMiddleware
// contains filtered or unexported fields
}
MetricsMiddleware collects metrics for indexing and query operations
func NewMetricsMiddleware ¶
func NewMetricsMiddleware(metrics Metrics) *MetricsMiddleware
NewMetricsMiddleware creates a new metrics middleware
func (*MetricsMiddleware) AfterIndex ¶
AfterIndex records index metrics
func (*MetricsMiddleware) AfterQuery ¶
func (m *MetricsMiddleware) AfterQuery(ctx context.Context, response *Response) error
AfterQuery records query metrics
func (*MetricsMiddleware) BeforeIndex ¶
func (m *MetricsMiddleware) BeforeIndex(ctx context.Context, source *Source) error
BeforeIndex records index start time
func (*MetricsMiddleware) BeforeQuery ¶
func (m *MetricsMiddleware) BeforeQuery(ctx context.Context, query *Query) error
BeforeQuery records query start time
type Middleware ¶
type Middleware interface {
// Name returns the middleware name
Name() string
// BeforeIndex is called before indexing a document
BeforeIndex(ctx context.Context, source *Source) error
// AfterIndex is called after indexing a document
AfterIndex(ctx context.Context, chunks []core.Chunk) error
// BeforeQuery is called before executing a query
BeforeQuery(ctx context.Context, query *Query) error
// AfterQuery is called after executing a query
AfterQuery(ctx context.Context, response *Response) error
}
Middleware defines the interface for middleware components Middleware can intercept and modify the indexing and query pipeline
type RateLimitMiddleware ¶
type RateLimitMiddleware struct {
*BaseMiddleware
// contains filtered or unexported fields
}
RateLimitMiddleware implements rate limiting
func NewRateLimitMiddleware ¶
func NewRateLimitMiddleware(limiter RateLimiter) *RateLimitMiddleware
NewRateLimitMiddleware creates a new rate limit middleware
func (*RateLimitMiddleware) BeforeQuery ¶
func (m *RateLimitMiddleware) BeforeQuery(ctx context.Context, query *Query) error
BeforeQuery checks rate limit before query
type RateLimiter ¶
RateLimiter defines the rate limiting interface
type TransformMiddleware ¶
type TransformMiddleware struct {
*BaseMiddleware
// contains filtered or unexported fields
}
TransformMiddleware transforms queries and responses
func NewTransformMiddleware ¶
func NewTransformMiddleware( queryTransformer func(ctx context.Context, query *Query) error, responseTransformer func(ctx context.Context, response *Response) error, ) *TransformMiddleware
NewTransformMiddleware creates a new transform middleware
func (*TransformMiddleware) AfterQuery ¶
func (m *TransformMiddleware) AfterQuery(ctx context.Context, response *Response) error
AfterQuery transforms response
func (*TransformMiddleware) BeforeQuery ¶
func (m *TransformMiddleware) BeforeQuery(ctx context.Context, query *Query) error
BeforeQuery transforms query
type ValidationMiddleware ¶
type ValidationMiddleware struct {
*BaseMiddleware
// contains filtered or unexported fields
}
ValidationMiddleware validates input before processing
func NewValidationMiddleware ¶
func NewValidationMiddleware(maxQueryLength int, maxFileSize int64) *ValidationMiddleware
NewValidationMiddleware creates a new validation middleware
func (*ValidationMiddleware) BeforeIndex ¶
func (m *ValidationMiddleware) BeforeIndex(ctx context.Context, source *Source) error
BeforeIndex validates source before indexing
func (*ValidationMiddleware) BeforeQuery ¶
func (m *ValidationMiddleware) BeforeQuery(ctx context.Context, query *Query) error
BeforeQuery validates query before execution