grpc

package
v2.0.0-alpha6 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2021 License: MIT Imports: 13 Imported by: 801

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)

Dial returns a GRPC connection.

func DialInsecure

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

DialInsecure returns an insecure GRPC connection.

func NewClientContext

func NewClientContext(ctx context.Context, info ClientInfo) context.Context

NewClientContext returns a new Context that carries value.

func NewServerContext

func NewServerContext(ctx context.Context, info ServerInfo) context.Context

NewServerContext returns a new Context that carries value.

Types

type ClientInfo

type ClientInfo struct {
	// FullMethod is the full RPC method string, i.e., /package.service/method.
	FullMethod string
}

ClientInfo is gRPC server infomation.

func FromClientContext

func FromClientContext(ctx context.Context) (info ClientInfo, ok bool)

FromClientContext returns the Transport value stored in ctx, if any.

type ClientOption

type ClientOption func(o *clientOptions)

ClientOption is gRPC client option.

func WithEndpoint

func WithEndpoint(endpoint string) ClientOption

WithEndpoint with client endpoint.

func WithMiddleware

func WithMiddleware(m middleware.Middleware) ClientOption

WithMiddleware with client middleware.

func WithOptions

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

WithOptions with gRPC options.

func WithRegistry

func WithRegistry(d registry.Discoverer) ClientOption

WithRegistry with client registry.

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

WithTimeout with client timeout.

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() (string, 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() error

Start start the gRPC server.

func (*Server) Stop

func (s *Server) Stop() error

Stop stop the gRPC server.

type ServerInfo

type ServerInfo struct {
	// Server is the service implementation the user provides. This is read-only.
	Server interface{}
	// FullMethod is the full RPC method string, i.e., /package.service/method.
	FullMethod string
}

ServerInfo is gRPC server infomation.

func FromServerContext

func FromServerContext(ctx context.Context) (info ServerInfo, ok bool)

FromServerContext returns the Transport value stored in ctx, if any.

type ServerOption

type ServerOption func(o *Server)

ServerOption is gRPC server option.

func Address

func Address(addr string) ServerOption

Address with server address.

func Logger

func Logger(logger log.Logger) ServerOption

Logger with server logger.

func Middleware

func Middleware(m middleware.Middleware) ServerOption

Middleware with server middleware.

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.

Directories

Path Synopsis
resolver

Jump to

Keyboard shortcuts

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