rpcserver

package
v0.0.0-...-ed26981 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(ctx context.Context, opts ...ClientOption) (*grpc.ClientConn, error)

func DialInsecure

func DialInsecure(ctx context.Context, opts ...ClientOption) (*grpc.ClientConn, error)

拨号

func InitBuilder

func InitBuilder()

Types

type ClientOption

type ClientOption func(o *clientOptions)

func WithBalancerName

func WithBalancerName(name string) ClientOption

设置负载均衡器

func WithClientEnableTracing

func WithClientEnableTracing(enable bool) ClientOption

设置是否开启链路追踪

func WithClientMetrics

func WithClientMetrics(enable bool) ClientOption

设置是否开启指标Metrics

func WithClientOptions

func WithClientOptions(opts ...grpc.DialOption) ClientOption

设置grpc的dial选项

func WithClientStreamInterceptor

func WithClientStreamInterceptor(in ...grpc.StreamClientInterceptor) ClientOption

设置stream拦截器

func WithClientTimeout

func WithClientTimeout(timeout time.Duration) ClientOption

设置超时时间

func WithClientUnaryInterceptor

func WithClientUnaryInterceptor(in ...grpc.UnaryClientInterceptor) ClientOption

设置拦截器

func WithDiscovery

func WithDiscovery(d registry.Discovery) ClientOption

设置服务发现

func WithEndpoint

func WithEndpoint(endpoint string) ClientOption

设置地址

type Server

type Server struct {
	*grpc.Server
	// contains filtered or unexported fields
}

func NewServer

func NewServer(opts ...ServerOption) *Server

func (*Server) Address

func (s *Server) Address() string

func (*Server) Endpoint

func (s *Server) Endpoint() *url.URL

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

完成ip和port的提取

func (s *Server) listenAndEndpoint() error {
	if s.lis == nil {
		lis, err := net.Listen("tpc", s.address)
		if err != nil {
			return err
		}
		s.lis = lis
	}
	addr, err := host.Extract(s.address, s.lis)
	if err != nil {
		_ = s.lis.Close()
		return err
	}
	s.endpoint = &url.URL{Scheme: "grpc", Host: addr}
	return nil
}

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

type ServerOption

type ServerOption func(o *Server)

func WithAddress

func WithAddress(address string) ServerOption

func WithLis

func WithLis(lis net.Listener) ServerOption

func WithOptions

func WithOptions(opts ...grpc.ServerOption) ServerOption

func WithServerEnableTracing

func WithServerEnableTracing(ok bool) ServerOption

func WithStreamInterceptor

func WithStreamInterceptor(in ...grpc.StreamServerInterceptor) ServerOption

func WithTimeout

func WithTimeout(timeout time.Duration) ServerOption

func WithUnaryInterceptor

func WithUnaryInterceptor(in ...grpc.UnaryServerInterceptor) ServerOption

func WithenableMetrics

func WithenableMetrics(metrics bool) ServerOption

type Trailer

type Trailer metadata.MD

Trailer is a grpc trailder MD.

func (Trailer) Get

func (t Trailer) Get(k string) string

Get get a grpc trailer value.

Directories

Path Synopsis
resolver
p2c
wrr

Jump to

Keyboard shortcuts

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