Documentation
¶
Index ¶
- Constants
- func AdaptGrpcRoundTripperToHTTPRoundTripper(r GrpcRoundTripper) http.RoundTripper
- func HTTPRequest(r *http.Request) (*frontend_v1pb.HTTPRequest, error)
- func NewHandler(cfg HandlerConfig, roundTripper http.RoundTripper, log log.Logger, ...) http.Handler
- func NewSplittingRoundTripper(rules ...*SplitRule) http.RoundTripper
- type GrpcRoundTripper
- type Handler
- type HandlerConfig
- type SplitRule
Constants ¶
View Source
const ( // StatusClientClosedRequest is the status code for when a client request cancellation of an http request StatusClientClosedRequest = 499 ServiceTimingHeaderName = "Server-Timing" )
Variables ¶
This section is empty.
Functions ¶
func AdaptGrpcRoundTripperToHTTPRoundTripper ¶
func AdaptGrpcRoundTripperToHTTPRoundTripper(r GrpcRoundTripper) http.RoundTripper
func HTTPRequest ¶
func HTTPRequest(r *http.Request) (*frontend_v1pb.HTTPRequest, error)
HTTPRequest wraps an ordinary HTTPRequest with a gRPC one
func NewHandler ¶
func NewHandler(cfg HandlerConfig, roundTripper http.RoundTripper, log log.Logger, reg prometheus.Registerer) http.Handler
NewHandler creates a new frontend handler.
func NewSplittingRoundTripper ¶
func NewSplittingRoundTripper(rules ...*SplitRule) http.RoundTripper
NewSplittingRoundTripper creates a new round tripper with rules
Types ¶
type GrpcRoundTripper ¶
type GrpcRoundTripper func(context.Context, *frontend_v1pb.HTTPRequest) (*frontend_v1pb.HTTPResponse, error)
GrpcRoundTripper is similar to http.RoundTripper, but works with HTTP requests converted to protobuf messages.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler accepts queries and forwards them to RoundTripper. It can log slow queries, but all other logic is inside the RoundTripper.
type HandlerConfig ¶
type HandlerConfig struct {
LogQueriesLongerThan time.Duration `yaml:"log_queries_longer_than"`
MaxBodySize int64 `yaml:"max_body_size"`
QueryStatsEnabled bool `yaml:"query_stats_enabled"`
}
Config for a Handler.
func (*HandlerConfig) RegisterFlags ¶
func (cfg *HandlerConfig) RegisterFlags(f *flag.FlagSet)
type SplitRule ¶
type SplitRule struct {
Rules []string
RoundTripper http.RoundTripper
}
SplitRule allows controlling which requests go to this roundtripper
Click to show internal directories.
Click to hide internal directories.