grpc

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2022 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MetadataClientAPIVersionKey = "client-api-version"
)

Functions

func Dial

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

Dial

func DialInsecure

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

Types

type ClientOption

type ClientOption func(o *clientOptions)

ClientOption is a gRPC client option.

func WithDiscovery

func WithDiscovery(d registry.Discovery) ClientOption

func WithEndpoint

func WithEndpoint(endpoint string) ClientOption

WithEndpoint with a endpoint.

func WithGzip

func WithGzip() ClientOption

WithGzip enable gzip.

func WithLog

func WithLog() ClientOption

WithLog enable log.

func WithMetric

func WithMetric() ClientOption

WithMetric enable metric.

func WithOptions

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

WithOptions with gRPC dial option.

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

WithTimeout with a client timeout.

func WithUnaryInterceptor

func WithUnaryInterceptor(inter ...grpc.UnaryClientInterceptor) ClientOption

WithUnaryInterceptor with unary client interceptor.

func WithoutRetry

func WithoutRetry() ClientOption

WithoutRetry disable retry.

type Server

type Server struct {
	*grpc.Server

	// TracerOptions are options for OpenTelemetry gRPC interceptor.
	TracerOptions []otelgrpc.Option
	// contains filtered or unexported fields
}

Server is a gRPC server wrapper. nolint

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:9090

func (*Server) Start

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

Start start the gRPC server.

func (*Server) Stop

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

Stop stop the gRPC server.

type ServerOption

type ServerOption func(o *Server)

ServerOption is gRPC server option.

func Address

func Address(addr string) ServerOption

Address with server address.

func EnableLog

func EnableLog() ServerOption

EnableLog enable log for server.

func EnableTracing

func EnableTracing() ServerOption

EnableTracing enable tracing.

func Network

func Network(network string) ServerOption

Network with server network.

func Options

func Options(opts ...grpc.ServerOption) ServerOption

Options with grpc options.

func Timeout

func Timeout(timeout time.Duration) ServerOption

Timeout with server timeout.

func UnaryInterceptor

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

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

Directories

Path Synopsis
resolver

Jump to

Keyboard shortcuts

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