It returns a new weight request middleware
(rt RequestType, cfg WeightsConfig)
| 49 | |
| 50 | // It returns a new weight request middleware |
| 51 | func NewWeightRequestWare(rt RequestType, cfg WeightsConfig) AsyncMiddleware[combiner.PipelineResponse] { |
| 52 | weights := Weights{ |
| 53 | DefaultWeight: 1, |
| 54 | TraceQLSearchWeight: 1, |
| 55 | TraceByIDWeight: 2, |
| 56 | MaxTraceQLConditions: cfg.MaxTraceQLConditions, |
| 57 | MaxRegexConditions: cfg.MaxRegexConditions, |
| 58 | } |
| 59 | return AsyncMiddlewareFunc[combiner.PipelineResponse](func(next AsyncRoundTripper[combiner.PipelineResponse]) AsyncRoundTripper[combiner.PipelineResponse] { |
| 60 | return &weightRequestWare{ |
| 61 | requestType: rt, |
| 62 | enabled: cfg.RequestWithWeights, |
| 63 | weights: weights, |
| 64 | next: next, |
| 65 | } |
| 66 | }) |
| 67 | } |
| 68 | |
| 69 | func (c weightRequestWare) RoundTrip(req Request) (Responses[combiner.PipelineResponse], error) { |
| 70 | c.setWeight(req) |
no outgoing calls