Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var NewHTTPPool = func( minSize, maxSize int, idleTimeout time.Duration, config *configv1.UpstreamServiceConfig, ) (pool.Pool[*client.HTTPClientWrapper], error) { factory := func(_ context.Context) (*client.HTTPClientWrapper, error) { tlsConfig := &tls.Config{ MinVersion: tls.VersionTLS12, InsecureSkipVerify: config.GetHttpService().GetTlsConfig().GetInsecureSkipVerify(), } if mtlsConfig := config.GetUpstreamAuthentication().GetMtls(); mtlsConfig != nil { cert, err := tls.LoadX509KeyPair(mtlsConfig.GetClientCertPath(), mtlsConfig.GetClientKeyPath()) if err != nil { return nil, err } tlsConfig.Certificates = []tls.Certificate{cert} caCert, err := os.ReadFile(mtlsConfig.GetCaCertPath()) if err != nil { return nil, err } caCertPool := x509.NewCertPool() caCertPool.AppendCertsFromPEM(caCert) tlsConfig.RootCAs = caCertPool } return client.NewHTTPClientWrapper( &http.Client{ Transport: otelhttp.NewTransport(&http.Transport{ TLSClientConfig: tlsConfig, DialContext: (&net.Dialer{ Timeout: 30 * time.Second, }).DialContext, }), }, config, ), nil } return pool.New(factory, minSize, maxSize, idleTimeout, false) }
NewHTTPPool creates a new connection pool for HTTP clients. It is defined as a variable to allow for easy mocking in tests.
minSize is the initial number of clients to create. maxSize is the maximum number of clients the pool can hold. idleTimeout is the duration after which an idle client may be closed (not currently implemented). healthCheck is the configuration for the health check. It returns a new HTTP client pool or an error if the pool cannot be created.
Functions ¶
Types ¶
type Upstream ¶
type Upstream struct {
// contains filtered or unexported fields
}
Upstream implements the upstream.Upstream interface for services that are exposed via standard HTTP endpoints. It handles the registration of tools defined in the service configuration.
func (*Upstream) Register ¶
func (u *Upstream) Register( ctx context.Context, serviceConfig *configv1.UpstreamServiceConfig, toolManager tool.ManagerInterface, promptManager prompt.ManagerInterface, resourceManager resource.ManagerInterface, isReload bool, ) (string, []*configv1.ToolDefinition, []*configv1.ResourceDefinition, error)
Register processes the configuration for an HTTP service, creates a connection pool for it, and then creates and registers tools for each call definition specified in the configuration.