Documentation
¶
Overview ¶
Package grpc provides gRPC upstream integration.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewGrpcPool ¶
func NewGrpcPool( minSize, maxSize int, idleTimeout time.Duration, dialer func(context.Context, string) (net.Conn, error), creds credentials.PerRPCCredentials, config *configv1.UpstreamServiceConfig, disableHealthCheck bool, ) (pool.Pool[*client.GrpcClientWrapper], error)
NewGrpcPool creates a new connection pool for gRPC clients. It configures the pool with a factory function that establishes new gRPC connections with the specified address, dialer, and credentials.
minSize is the initial number of connections to create. maxSize is the maximum number of connections the pool can hold. idleTimeout is the duration after which an idle connection may be closed (not currently implemented). address is the target address of the gRPC service. dialer is an optional custom dialer for creating network connections. creds is the per-RPC credentials to be used for authentication. It returns a new gRPC client pool or an error if the pool cannot be created.
Types ¶
type ConnectionFactory ¶
type ConnectionFactory struct {
// contains filtered or unexported fields
}
ConnectionFactory is responsible for creating new gRPC client connections. It can be configured with a custom dialer for testing or special connection scenarios.
func NewConnectionFactory ¶
func NewConnectionFactory() *ConnectionFactory
NewConnectionFactory creates and returns a new ConnectionFactory with default settings.
func (*ConnectionFactory) NewConnection ¶
func (f *ConnectionFactory) NewConnection(_ context.Context, targetAddress string) (*grpc.ClientConn, error)
NewConnection establishes a new gRPC client connection to the specified target address. It uses insecure credentials by default. If a custom dialer has been set, it will be used for the connection.
ctx is the context for the connection attempt. targetAddress is the address of the gRPC service to connect to. It returns a new *grpc.ClientConn or an error if the connection fails.
func (*ConnectionFactory) WithDialer ¶
WithDialer sets a custom dialer function for the ConnectionFactory. This is useful for tests that need to mock the network connection.
dialer is the function to be used for creating network connections.
type Upstream ¶
type Upstream struct {
// contains filtered or unexported fields
}
Upstream implements the upstream.Upstream interface for gRPC services. It uses gRPC reflection to discover services and methods, and creates tools for them. It also manages a connection pool and a cache for reflection data.
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 handles the registration of a gRPC upstream service. It establishes a connection pool, uses gRPC reflection to discover the service's protobuf definitions, and then creates and registers tools based on the discovered methods and any MCP annotations.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package protobufparser provides a parser for Protocol Buffers.
|
Package protobufparser provides a parser for Protocol Buffers. |