rpc

package
v0.0.0-...-bcb190e Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: BSD-3-Clause Imports: 13 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// MDSessID grpc metadata中的session id key
	MDSessID = "x-sess"
	// MDTransactionID grpc metadata中的transaction id key,用于跟踪请求
	MDTransactionID = "x-trans"
	// MDGateway grpc metadata中的gateway key,用于标识请求来自哪个网关
	MDGateway = "x-gw"
)

Variables

This section is empty.

Functions

func GatewayIDInContext

func GatewayIDInContext(ctx context.Context) ulid.ULID

GatewayIDInContext 从context中获取gateway id

func LogUnary

LogUnary 打印unary请求日志

func SessionIDInContext

func SessionIDInContext(ctx context.Context) string

SessionIDInContext 从context中获取session id

Types

type GRPCServer

type GRPCServer struct {
	// contains filtered or unexported fields
}

GRPCServer grpc服务

func BindGRPCServer

func BindGRPCServer(listener net.Listener, opts ...grpc.ServerOption) *GRPCServer

BindGRPCServer 绑定grpc服务器

func NewGRPCServer

func NewGRPCServer(listenAddr string, opts ...grpc.ServerOption) *GRPCServer

NewGRPCServer 构造函数

func (*GRPCServer) CompleteNodeEntry

func (gs *GRPCServer) CompleteNodeEntry(entry *cluster.NodeEntry)

CompleteNodeEntry 设置条目中的grpc信息

func (*GRPCServer) Name

func (gs *GRPCServer) Name() string

Name 服务名称

func (*GRPCServer) RegisterService

func (gs *GRPCServer) RegisterService(code int32, desc grpc.ServiceDesc, impl any, options ...Option) error

RegisterService 注册服务

func (*GRPCServer) Start

func (gs *GRPCServer) Start(ctx context.Context) error

Start 启动服务

func (*GRPCServer) Stop

func (gs *GRPCServer) Stop(ctx context.Context)

Stop 停止服务

type Option

Option 配置

func WithAllocation

func WithAllocation(allocation string) Option

WithAllocation 设置节点分配方式

func WithBalancer

func WithBalancer(balancer string) Option

WithBalancer 设置负载均衡策略

func WithPublic

func WithPublic() Option

WithPublic 设置服务为公开

func WithStateful

func WithStateful() Option

WithStateful 设置服务为有状态

func WithWeight

func WithWeight(weight int) Option

WithWeight 设置节点权重

Jump to

Keyboard shortcuts

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