rpc

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 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 WithServerKeepalive added in v0.2.1

WithServerKeepalive grpc服务端心跳配置

func WithServerLimiter added in v0.2.1

func WithServerLimiter(rateLimiter limiter.RateLimiter) ServerOption

WithServerLimiter 服务端限流

type ServiceDiscovery

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

ServiceDiscovery 服务发现

func NewServiceDiscovery

func NewServiceDiscovery(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 WithServiceDiscoveryKeepalive added in v0.2.1

func WithServiceDiscoveryKeepalive(keepaliveTime, timeout time.Duration, backoffConf backoff.Config) ServiceDiscoveryOption

WithServiceDiscoveryKeepalive 添加保活与超时选项

func WithServiceDiscoveryLB

func WithServiceDiscoveryLB(lb ServiceDiscoveryLB) ServiceDiscoveryOption

WithServiceDiscoveryLB 添加负载均衡选项

func WithServiceDiscoveryRetry

func WithServiceDiscoveryRetry(retryPolicy *retry.Policy) ServiceDiscoveryOption

WithServiceDiscoveryRetry 设置重试

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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