DoH через DoWithRetry; CDN preview через UpstreamHTTPDo; частичный fail CDN (EVOBGP_CDN_PARTIAL_OK); безопасный доступ к Job.Meta; drain jobs при SIGTERM; ValidateProductionEnforce при EVOBGP_PRODUCTION=1. Co-authored-by: Cursor <[email protected]>
29 lines
710 B
Go
29 lines
710 B
Go
package pipeline
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"evobgp/internal/httpclient"
|
|
)
|
|
|
|
// UpstreamHTTPDo performs an outbound GET/POST with circuit breaker + retries (CDN, previews).
|
|
func UpstreamHTTPDo(ctx context.Context, hc *http.Client, req *http.Request) (*http.Response, error) {
|
|
return upstreamHTTPDo(ctx, hc, req)
|
|
}
|
|
|
|
func upstreamHTTPDo(ctx context.Context, hc *http.Client, req *http.Request) (*http.Response, error) {
|
|
if hc == nil {
|
|
hc = httpclient.New(httpclient.DefaultTimeout)
|
|
}
|
|
resp, err := httpclient.DoWithBreaker(ctx, hc, req, 3)
|
|
if err != nil {
|
|
if req.URL != nil {
|
|
return nil, fmt.Errorf("cdn fetch %s: %w", req.URL.String(), err)
|
|
}
|
|
return nil, err
|
|
}
|
|
return resp, nil
|
|
}
|