rpc

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2025 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server interface {
	RegisterService(serviceMetadata metadata.ServiceRegister, grpcRegister interface{}) error
	Serve() error
	Stop() error
}

Server grpc服务

func NewServer

func NewServer(conf *config.ServerConfig, registry naming.Registry, opts ...ServerOption) Server

type ServerOption

type ServerOption func(s *serverOption)

func WithServerGrpcServerOption

func WithServerGrpcServerOption(opts ...grpc.ServerOption) ServerOption

WithServerGrpcServerOption grpc服务配置

func WithServiceLimiter

func WithServiceLimiter(rateLimiter limiter.RateLimiter) ServerOption

WithServiceLimiter 服务端限流

type ServiceDiscovery

type ServiceDiscovery interface {
	// ServiceConn 获取服务连接信息
	ServiceConn(serviceName string, opts ...ServiceDiscoveryOption) (*grpc.ClientConn, error)
}

ServiceDiscovery 服务发现

func NewServiceDiscovery

func NewServiceDiscovery(appName string, resolverBuilder resolver.Builder) ServiceDiscovery

type ServiceDiscoveryLB

type ServiceDiscoveryLB string

ServiceDiscoveryLB 负载均衡

const (
	PickFirst  ServiceDiscoveryLB = "pick_first"  // 选择第一个
	RoundRobin ServiceDiscoveryLB = "round_robin" // 轮询
)

type ServiceDiscoveryOption

type ServiceDiscoveryOption func(s *serviceDiscoveryOption)

func WithServiceDiscoveryBreaker

func WithServiceDiscoveryBreaker(cb breaker.CircuitBreaker) ServiceDiscoveryOption

WithServiceDiscoveryBreaker 设置熔断器

func WithServiceDiscoveryGrpcDialOption

func WithServiceDiscoveryGrpcDialOption(opts ...grpc.DialOption) ServiceDiscoveryOption

func WithServiceDiscoveryGrpcDialTransportCredentials

func WithServiceDiscoveryGrpcDialTransportCredentials(credentials *credentials.TransportCredentials) ServiceDiscoveryOption

func WithServiceDiscoveryLB

func WithServiceDiscoveryLB(lb ServiceDiscoveryLB) ServiceDiscoveryOption

WithServiceDiscoveryLB 添加负载均衡选项

func WithServiceDiscoveryRetry

func WithServiceDiscoveryRetry(retryPolicy *retry.Policy) ServiceDiscoveryOption

WithServiceDiscoveryRetry 设置重试

func WithServiceDiscoveryTimeout

func WithServiceDiscoveryTimeout(timeout time.Duration) ServiceDiscoveryOption

WithServiceDiscoveryTimeout 添加超时设置选项

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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