grpc

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial added in v0.0.3

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

func DialInsecure added in v0.0.3

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

func NewWrappedStream

func NewWrappedStream(ctx context.Context, stream grpc.ServerStream) grpc.ServerStream

Types

type ClientOption added in v0.0.3

type ClientOption func(o *clientOptions)

func WithBalancerName added in v0.0.3

func WithBalancerName(name string) ClientOption

设置负载均衡器

func WithClientOptions added in v0.0.3

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

设置grpc的dial选项

func WithClientStreamInterceptor added in v0.0.3

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

设置stream拦截器

func WithClientTimeout added in v0.0.3

func WithClientTimeout(timeout time.Duration) ClientOption

设置超时时间

func WithClientUnaryInterceptor added in v0.0.3

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

设置拦截器

func WithDiscovery added in v0.0.3

func WithDiscovery(d registry.Discovery) ClientOption

设置服务发现

func WithEnableTracing added in v0.0.3

func WithEnableTracing(enable bool) ClientOption

func WithEndpoint added in v0.0.3

func WithEndpoint(endpoint string) ClientOption

设置地址

func WithMetric added in v0.0.3

func WithMetric(metric metric.GrpcClientMetric) ClientOption

type Server

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

Server is a gRPC server wrapper.

func NewServer

func NewServer(opts ...ServerOption) *Server

NewServer creates a gRPC server by options.

func (*Server) Endpoint

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

Endpoint return a real address to registry endpoint. examples:

grpc://127.0.0.1:9000?isSecure=false

func (*Server) Start

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

Start start the gRPC server.

func (*Server) Stop

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

Stop stop the gRPC server.

type ServerOption

type ServerOption func(o *Server)

ServerOption is gRPC server option.

func WithAddress

func WithAddress(address string) ServerOption

func WithGrpcOpts

func WithGrpcOpts(opts ...grpc.ServerOption) ServerOption

WithGrpcOpts with grpc options.

func WithListener

func WithListener(lis net.Listener) ServerOption

Listener with server lis

func WithNetwork

func WithNetwork(network string) ServerOption

func WithStreamInterceptor

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

WithStreamInterceptor returns a ServerOption that sets the StreamServerInterceptor for the server.

func WithUnaryInterceptor

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

WithUnaryInterceptor returns a ServerOption that sets the UnaryServerInterceptor for the server.

type Transport

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

Transport is a gRPC transport.

func (*Transport) Endpoint

func (tr *Transport) Endpoint() string

Endpoint returns the transport endpoint.

func (*Transport) Kind

func (tr *Transport) Kind() transport.Kind

Kind returns the transport kind.

func (*Transport) Operation

func (tr *Transport) Operation() string

Operation returns the transport operation.

func (*Transport) ReplyHeader

func (tr *Transport) ReplyHeader() transport.Header

ReplyHeader returns the reply header.

func (*Transport) RequestHeader

func (tr *Transport) RequestHeader() transport.Header

RequestHeader returns the request header.

Jump to

Keyboard shortcuts

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