grpc

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionManager

type ConnectionManager interface {
	// Connect establishes a connection to the gRPC server
	Connect(ctx context.Context) error

	// GetConnection returns the current connection
	GetConnection() *grpcLib.ClientConn

	// IsConnected checks if the connection is healthy
	IsConnected() bool

	// Reconnect attempts to reconnect to the server
	Reconnect(ctx context.Context) error

	// HealthCheck performs a health check on the connection
	HealthCheck(ctx context.Context) error

	// Close closes the connection
	Close() error
}

ConnectionManager manages gRPC connections with health checking and reconnection

func NewConnectionManager

func NewConnectionManager(config ConnectionManagerConfig, logger *zap.Logger) ConnectionManager

NewConnectionManager creates a new connection manager

type ConnectionManagerConfig

type ConnectionManagerConfig struct {
	Host           string          `json:"host"`
	Port           int             `json:"port"`
	ConnectTimeout time.Duration   `json:"connect_timeout"`
	KeepAlive      KeepAliveConfig `json:"keep_alive"`
	MaxMessageSize int             `json:"max_message_size"`
}

ConnectionManagerConfig contains configuration for connection management

type KeepAliveConfig

type KeepAliveConfig struct {
	Time                time.Duration `json:"time"`
	Timeout             time.Duration `json:"timeout"`
	PermitWithoutStream bool          `json:"permit_without_stream"`
}

KeepAliveConfig contains keep-alive settings for gRPC connections

type MethodInfo

type MethodInfo = types.MethodInfo

type ReflectionClient

type ReflectionClient interface {
	// DiscoverMethods discovers all methods using reflection
	DiscoverMethods(ctx context.Context) ([]types.MethodInfo, error)

	// InvokeMethod invokes a method using dynamic protobuf messages with optional headers
	InvokeMethod(ctx context.Context, headers map[string]string, method types.MethodInfo, inputJSON string) (string, error)

	// HealthCheck performs a health check
	HealthCheck(ctx context.Context) error

	// Close closes the reflection client
	Close() error
}

ReflectionClient handles gRPC reflection API

func NewReflectionClient

func NewReflectionClient(conn *grpc.ClientConn, logger *zap.Logger) ReflectionClient

NewReflectionClient creates a new reflection client

type ServiceDiscoverer

type ServiceDiscoverer interface {
	// Connect establishes connection to the gRPC server
	Connect(ctx context.Context) error

	// DiscoverServices discovers all available services
	DiscoverServices(ctx context.Context) error

	// GetMethods returns all discovered methods in a flat list
	GetMethods() []types.MethodInfo

	// InvokeMethodByTool invokes a gRPC method by tool name with optional headers
	InvokeMethodByTool(ctx context.Context, headers map[string]string, toolName string, inputJSON string) (string, error)

	// HealthCheck performs a health check
	HealthCheck(ctx context.Context) error

	// Close closes the service discoverer
	Close() error

	// GetMethodCount returns the total number of discovered methods
	GetMethodCount() int

	// GetServiceStats returns statistics about discovered services
	GetServiceStats() map[string]interface{}
}

ServiceDiscoverer discovers and manages gRPC services

func NewServiceDiscoverer

func NewServiceDiscoverer(host string, port int, logger *zap.Logger, descriptorConfig config.DescriptorSetConfig) (ServiceDiscoverer, error)

NewServiceDiscoverer creates a new service discoverer with descriptor support

type SourceLocation

type SourceLocation = types.SourceLocation

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL