MCPcopy
hub / github.com/grafana/tempo / Build

Function Build

modules/frontend/pipeline/pipeline.go:151–174  ·  view source on GitHub ↗

Builder and Bridge Build takes a slice of async, sync middleware and a http.RoundTripper and builds a request pipeline

(asyncMW []AsyncMiddleware[combiner.PipelineResponse], mw []Middleware, next RoundTripper)

Source from the content-addressed store, hash-verified

149
150// Build takes a slice of async, sync middleware and a http.RoundTripper and builds a request pipeline
151func Build(asyncMW []AsyncMiddleware[combiner.PipelineResponse], mw []Middleware, next RoundTripper) AsyncRoundTripper[combiner.PipelineResponse] {
152 asyncPipeline := AsyncMiddlewareFunc[combiner.PipelineResponse](func(next AsyncRoundTripper[combiner.PipelineResponse]) AsyncRoundTripper[combiner.PipelineResponse] {
153 for i := len(asyncMW) - 1; i >= 0; i-- {
154 next = asyncMW[i].Wrap(next)
155 }
156 return next
157 })
158
159 syncPipeline := MiddlewareFunc(func(next RoundTripper) RoundTripper {
160 for i := len(mw) - 1; i >= 0; i-- {
161 next = mw[i].Wrap(next)
162 }
163 return next
164 })
165
166 // bridge the two pipelines
167 bridge := &pipelineBridge{
168 next: syncPipeline.Wrap(RoundTripperFunc(func(req Request) (*http.Response, error) {
169 return next.RoundTrip(req)
170 })),
171 convert: NewHTTPToAsyncResponse,
172 }
173 return asyncPipeline.Wrap(bridge)
174}
175
176var _ AsyncRoundTripper[combiner.PipelineResponse] = (*pipelineBridge)(nil)
177

Callers 1

NewFunction · 0.92

Calls 4

MiddlewareFuncFuncType · 0.70
RoundTripperFuncFuncType · 0.70
WrapMethod · 0.65
RoundTripMethod · 0.65

Tested by

no test coverage detected