Documentation
¶
Index ¶
- Constants
- func DefaultClientMiddlewares() []middleware.Middleware
- func DefaultServerMiddlewares() []middleware.Middleware
- func NewClient(ctx context.Context, grpcConfig *transportv1.GrpcClientConfig, ...) (*grpc.ClientConn, error)
- func NewServer(grpcConfig *transportv1.GrpcServerConfig, serverOpts *ServerOptions) (*transgrpc.Server, error)
- func WithGrpcDialOptions(opts ...grpcx.DialOption) options.Option
- func WithGrpcServerOptions(opts ...kgprc.ServerOption) options.Option
- type ClientOptions
- type ServerOptions
Constants ¶
const Module = "transport.grpc"
Variables ¶
This section is empty.
Functions ¶
func DefaultClientMiddlewares ¶
func DefaultClientMiddlewares() []middleware.Middleware
DefaultClientMiddlewares provides a default set of client-side middlewares for gRPC services.
func DefaultServerMiddlewares ¶
func DefaultServerMiddlewares() []middleware.Middleware
DefaultServerMiddlewares provides a default set of server-side middlewares for gRPC services. These are essential for ensuring basic stability and observability.
func NewClient ¶ added in v0.2.7
func NewClient(ctx context.Context, grpcConfig *transportv1.GrpcClientConfig, clientOpts *ClientOptions) (*grpc.ClientConn, error)
NewClient creates a new concrete gRPC client connection based on the provided configuration. It returns *transgrpc.ClientConn.
func NewServer ¶ added in v0.2.7
func NewServer(grpcConfig *transportv1.GrpcServerConfig, serverOpts *ServerOptions) (*transgrpc.Server, error)
NewServer creates a new concrete gRPC server instance based on the provided configuration. It returns *transgrpc.Server, not the generic interfaces.Server.
func WithGrpcDialOptions ¶
func WithGrpcDialOptions(opts ...grpcx.DialOption) options.Option
WithGrpcDialOptions appends native gRPC client dial options.
func WithGrpcServerOptions ¶
func WithGrpcServerOptions(opts ...kgprc.ServerOption) options.Option
WithGrpcServerOptions appends Kratos gRPC server options.
Types ¶
type ClientOptions ¶
type ClientOptions struct {
// ServiceOptions holds common service-level configurations.
ServiceOptions *service.Options
// GrpcDialOptions allows passing native gRPC client dial options.
GrpcDialOptions []grpcx.DialOption
}
ClientOptions is a container for gRPC client-specific options.
func FromClientOptions ¶
func FromClientOptions(opts []options.Option) *ClientOptions
FromClientOptions creates a new gRPC ClientOptions struct by applying a slice of functional options. It also initializes and includes the common service-level options, ensuring they are applied only once.
type ServerOptions ¶
type ServerOptions struct {
// ServiceOptions holds common service-level configurations.
ServiceOptions *service.Options
// GrpcServerOptions allows passing native Kratos gRPC server options.
GrpcServerOptions []kgprc.ServerOption
}
ServerOptions is a container for gRPC server-specific options.
func FromServerOptions ¶
func FromServerOptions(opts []options.Option) *ServerOptions
FromServerOptions creates a new gRPC ServerOptions struct by applying a slice of functional options. It also initializes and includes the common service-level options, ensuring they are applied only once.