grpc

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 24 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)

Dial returns a GRPC connection.

func DialInsecure

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

DialInsecure returns an insecure GRPC connection.

func NewWrappedStream

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

Types

type Client

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

Client is gRPC Client

func ApplyClient added in v0.2.0

func ApplyClient(opts ...ClientOption) *Client

type ClientOption

type ClientOption func(o *Client)

ClientOption is gRPC client option.

func WithBalancerName

func WithBalancerName(name string) ClientOption

WithBalancerName with balancer name

func WithDialOptions added in v0.2.1

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

WithDialOptions with gRPC client connection options.

func WithDiscovery

func WithDiscovery(d registry.Discovery) ClientOption

WithDiscovery with client discovery.

func WithEndpoint

func WithEndpoint(endpoint string) ClientOption

WithEndpoint ...

func WithMiddleware

func WithMiddleware(ms ...middleware.Middleware) ClientOption

WithMiddleware with client middleware.

func WithPrintDiscoveryDebugLog

func WithPrintDiscoveryDebugLog(p bool) ClientOption

func WithStreamInterceptor

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

WithStreamInterceptor returns a DialOption that specifies the interceptor for streaming RPCs.

func WithTLSConfig

func WithTLSConfig(conf *tls.Config) ClientOption

WithTLSConfig with TLS config.

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

WithTimeout with client timeout.

func WithUnaryInterceptor

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

WithUnaryInterceptor returns a DialOption that specifies the interceptor for unary RPCs.

type Server

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

func ApplyServer added in v0.2.0

func ApplyServer(opts ...ServerOption) *Server

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 the gRPC server.

func (*Server) Stop

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

Stop stop the gRPC server.

func (*Server) Use

func (s *Server) Use(selector string, m ...middleware.Middleware)

Use uses a service middleware with selector. selector:

  • '/*'
  • '/helloworld.v1.Greeter/*'
  • '/helloworld.v1.Greeter/SayHello'

type ServerOption

type ServerOption func(o *Server)

ServerOption is gRPC server option.

func Address

func Address(addr string) ServerOption

Address with server address.

func CustomHealth

func CustomHealth() ServerOption

CustomHealth Checks server.

func Endpoint

func Endpoint(endpoint *url.URL) ServerOption

Endpoint with server endpoint.

func GrpcOptions

func GrpcOptions(opts ...grpc.ServerOption) ServerOption

GrpcOptions with grpc options.

func Listener

func Listener(lis net.Listener) ServerOption

Listener with server lis

func Middleware

func Middleware(m ...middleware.Middleware) ServerOption

Middleware with server middleware.

func Network

func Network(network string) ServerOption

Network with server network.

func StreamInterceptor

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

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

func TLSConfig

func TLSConfig(c *tls.Config) ServerOption

TLSConfig with TLS config.

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