Documentation
¶
Index ¶
- func StartConfigWatcher(ctx context.Context, path string, rcv ConfigReceiver, l *slog.Logger, ...) error
- type ConfigReceiver
- type Processor
- type ProcessorFactory
- type Server
- func (s *Server) Check(context.Context, *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error)
- func (s *Server) LoadConfig(ctx context.Context, config *filterapi.Config) error
- func (s *Server) Process(stream extprocv3.ExternalProcessor_ProcessServer) error
- func (s *Server) Register(path string, newProcessor ProcessorFactory)
- func (s *Server) Watch(*grpc_health_v1.HealthCheckRequest, grpc_health_v1.Health_WatchServer) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StartConfigWatcher ¶
func StartConfigWatcher(ctx context.Context, path string, rcv ConfigReceiver, l *slog.Logger, tick time.Duration) error
StartConfigWatcher starts a watcher for the given path and Receiver. Periodically checks the file for changes and calls the Receiver's UpdateConfig method.
Types ¶
type ConfigReceiver ¶
type ConfigReceiver interface {
// LoadConfig updates the configuration.
LoadConfig(ctx context.Context, config *filterapi.Config) error
}
ConfigReceiver is an interface that can receive *filterapi.Config updates. This is mostly for decoupling and testing purposes.
type Processor ¶
type Processor interface {
// ProcessRequestHeaders processes the request headers message.
ProcessRequestHeaders(context.Context, *corev3.HeaderMap) (*extprocv3.ProcessingResponse, error)
// ProcessRequestBody processes the request body message.
ProcessRequestBody(context.Context, *extprocv3.HttpBody) (*extprocv3.ProcessingResponse, error)
// ProcessResponseHeaders processes the response headers message.
ProcessResponseHeaders(context.Context, *corev3.HeaderMap) (*extprocv3.ProcessingResponse, error)
// ProcessResponseBody processes the response body message.
ProcessResponseBody(context.Context, *extprocv3.HttpBody) (*extprocv3.ProcessingResponse, error)
}
Processor is the interface for the processor. This decouples the processor implementation detail from the server implementation.
type ProcessorFactory ¶
ProcessorFactory is the factory function used to create new instances of a processor.
func ChatCompletionProcessorFactory ¶ added in v0.1.3
func ChatCompletionProcessorFactory(ccm metrics.ChatCompletion) ProcessorFactory
ChatCompletionProcessorFactory returns a factory method to instantiate the chat completion processor.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server implements the external processor server.
func (*Server) Check ¶
func (s *Server) Check(context.Context, *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error)
Check implements grpc_health_v1.HealthServer.
func (*Server) LoadConfig ¶
LoadConfig updates the configuration of the external processor.
func (*Server) Process ¶
func (s *Server) Process(stream extprocv3.ExternalProcessor_ProcessServer) error
Process implements extprocv3.ExternalProcessorServer.
func (*Server) Register ¶
func (s *Server) Register(path string, newProcessor ProcessorFactory)
Register a new processor for the given request path.
func (*Server) Watch ¶
func (s *Server) Watch(*grpc_health_v1.HealthCheckRequest, grpc_health_v1.Health_WatchServer) error
Watch implements grpc_health_v1.HealthServer.