|
6 | 6 | "net" |
7 | 7 | "net/http" |
8 | 8 | "reflect" |
9 | | - "time" |
10 | 9 |
|
11 | 10 | a2atype "github.com/a2aproject/a2a-go/v2/a2a" |
12 | 11 | a2aclient "github.com/a2aproject/a2a-go/v2/a2aclient" |
@@ -42,9 +41,6 @@ func NewA2ARegistrar( |
42 | 41 | a2aBaseUrl string, |
43 | 42 | sandboxA2ABaseURL string, |
44 | 43 | authenticator auth.AuthProvider, |
45 | | - _ int, |
46 | | - _ int, |
47 | | - _ time.Duration, |
48 | 44 | ) (*A2ARegistrar, error) { |
49 | 45 | if clientRegistry == nil { |
50 | 46 | return nil, fmt.Errorf("clientRegistry must not be nil") |
@@ -170,7 +166,7 @@ func (a *A2ARegistrar) upsertAgentHandler(ctx context.Context, agent v1alpha2.Ag |
170 | 166 | // Keep legacy fallback during rollout so old agent pods continue to serve traffic. |
171 | 167 | filterInterfacesByVersion(card.SupportedInterfaces, a2atype.ProtocolVersion("0.3")), |
172 | 168 | a2aclient.WithJSONRPCTransport(httpClient), |
173 | | - // TODO(cleanup): Remove the compat transport after legacy runtimes are unsupported. |
| 169 | + // TODO(0.11.0): Remove the compat transport after legacy runtimes are unsupported. |
174 | 170 | a2aclient.WithCompatTransport( |
175 | 171 | a2atype.ProtocolVersion("0.3"), |
176 | 172 | a2atype.TransportProtocolJSONRPC, |
@@ -204,19 +200,22 @@ func (a *A2ARegistrar) upsertAgentHandler(ctx context.Context, agent v1alpha2.Ag |
204 | 200 | return nil |
205 | 201 | } |
206 | 202 |
|
| 203 | +// debugHTTPClient returns nil in normal operation, letting the a2aclient SDK apply its |
| 204 | +// default 3-minute request timeout. In debug mode it overrides the dial target so all |
| 205 | +// A2A traffic is redirected to a fixed address (e.g. a local proxy). |
207 | 206 | func debugHTTPClient() *http.Client { |
208 | 207 | debugAddr := env.KagentA2ADebugAddr.Get() |
209 | | - if debugAddr != "" { |
210 | | - client := new(http.Client) |
211 | | - client.Transport = &http.Transport{ |
| 208 | + if debugAddr == "" { |
| 209 | + return nil |
| 210 | + } |
| 211 | + return &http.Client{ |
| 212 | + Transport: &http.Transport{ |
212 | 213 | DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) { |
213 | 214 | var zeroDialer net.Dialer |
214 | 215 | return zeroDialer.DialContext(ctx, network, debugAddr) |
215 | 216 | }, |
216 | | - } |
217 | | - return client |
| 217 | + }, |
218 | 218 | } |
219 | | - return &http.Client{} |
220 | 219 | } |
221 | 220 |
|
222 | 221 | func (a *A2ARegistrar) a2aRouteURL(agent v1alpha2.AgentObject) string { |
|
0 commit comments