NewAdjustStartEndWare creates middleware that adjusts the "end" parameter of incoming requests. It is assumed that all request pipelines it exists in expect a "start" and "end" parameter. Traditionally some of these endpoints supported no start/end parameter which simply meant "search all recent dat
(defStart time.Duration, endBuffer time.Duration, sendNanos bool)
| 35 | // This prevents queries from using "now" as an end time, which may hit incomplete data. |
| 36 | // - sendNanos: If true, times are encoded as Unix nanoseconds. Otherwise, Unix seconds are used. |
| 37 | func NewAdjustStartEndWare(defStart time.Duration, endBuffer time.Duration, sendNanos bool) AsyncMiddleware[combiner.PipelineResponse] { |
| 38 | return AsyncMiddlewareFunc[combiner.PipelineResponse](func(next AsyncRoundTripper[combiner.PipelineResponse]) AsyncRoundTripper[combiner.PipelineResponse] { |
| 39 | return &adjustStartEndWare{ |
| 40 | next: next, |
| 41 | defStart: defStart, |
| 42 | endBuffer: endBuffer, |
| 43 | sendNanos: sendNanos, |
| 44 | } |
| 45 | }) |
| 46 | } |
| 47 | |
| 48 | func (c adjustStartEndWare) RoundTrip(req Request) (Responses[combiner.PipelineResponse], error) { |
| 49 | var ( |
no outgoing calls