grpc

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
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 *grpcv1.Client, 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 *grpcv1.Server, 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.

Jump to

Keyboard shortcuts

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