Returns an HTTP timeout (408) error if the Database's Context has an expired timeout or has been explicitly canceled. (See WithTimeout.)
(ctx context.Context)
| 2147 | |
| 2148 | // Returns an HTTP timeout (408) error if the Database's Context has an expired timeout or has been explicitly canceled. (See WithTimeout.) |
| 2149 | func CheckTimeout(ctx context.Context) error { |
| 2150 | if ctx == nil { |
| 2151 | return nil |
| 2152 | } |
| 2153 | select { |
| 2154 | case <-ctx.Done(): |
| 2155 | return base.HTTPErrorf(http.StatusRequestTimeout, "Request timed out") |
| 2156 | default: |
| 2157 | return nil |
| 2158 | } |
| 2159 | } |
| 2160 | |
| 2161 | // / LOGGING |
| 2162 |
no test coverage detected