rpc

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(config *ClientConfig) *grpc.ClientConn

Types

type Client

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

func (*Client) ChainUnaryClient

func (c *Client) ChainUnaryClient(interceptors ...grpc.UnaryClientInterceptor) grpc.UnaryClientInterceptor

ChainUnaryClient creates a single interceptor out of a chain of many interceptors.

Execution is done in left-to-right order, including passing of context. For example ChainUnaryClient(one, two, three) will execute one before two before three.

func (*Client) Use

func (c *Client) Use(interceptors ...grpc.UnaryClientInterceptor)

Use attaches a global interceptor to the client. ie. the interceptor attached through Use() will be included in the interceptors chain for every single request. For example, this is the right place for a logger or error management interceptor.

func (*Client) WithUnaryServerChain

func (c *Client) WithUnaryServerChain(interceptors ...grpc.UnaryClientInterceptor) grpc.DialOption

Chain creates a single interceptor out of a chain of many interceptors.

WithUnaryServerChain is a grpc.Client dial option that accepts multiple unary interceptors. Basically syntactic sugar.

type ClientConfig

type ClientConfig struct {
	DialTimeout time.Duration
	Block       bool
	Balancer    string
	Target      string

	Timeout time.Duration

	KeepAliveInterval time.Duration
	KeepAliveTimeout  time.Duration

	SlowRequestDuration time.Duration
}

type Server

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

func NewServer

func NewServer(config *ServerConfig) *Server

func (*Server) ChainUnaryServer

func (s *Server) ChainUnaryServer(interceptors ...grpc.UnaryServerInterceptor) grpc.UnaryServerInterceptor

ChainUnaryServer creates a single interceptor out of a chain of many interceptors.

Execution is done in left-to-right order, including passing of context. For example ChainUnaryServer(one, two, three) will execute one before two before three, and three will see context changes of one and two.

func (*Server) GetValidator

func (s *Server) GetValidator() *validator.Validate

GetValidator returns the underlying validator engine which powers the StructValidator implementation.

func (*Server) Metric

func (s *Server) Metric() grpc.UnaryServerInterceptor

func (*Server) Server

func (s *Server) Server() *grpc.Server

func (*Server) Start

func (s *Server) Start() net.Addr

func (*Server) Stop

func (s *Server) Stop()

GracefulStop stops the gRPC server gracefully. It stops the server from accepting new connections and RPCs and blocks until all the pending RPCs are finished.

func (*Server) Use

func (s *Server) Use(interceptors ...grpc.UnaryServerInterceptor)

Use attaches a global interceptor to the server. ie. the interceptor attached through Use() will be included in the interceptors chain for every single request. For example, this is the right place for a logger or error management interceptor.

func (*Server) WithUnaryServerChain

func (s *Server) WithUnaryServerChain(interceptors ...grpc.UnaryServerInterceptor) grpc.ServerOption

Chain creates a single interceptor out of a chain of many interceptors.

WithUnaryServerChain is a grpc.Server config option that accepts multiple unary interceptors. Basically syntactic sugar.

type ServerConfig

type ServerConfig struct {
	Addr string

	Timeout        time.Duration
	IdleTimeout    time.Duration
	MaxLifeTime    time.Duration
	ForceCloseWait time.Duration

	KeepAliveInterval time.Duration
	KeepAliveTimeout  time.Duration

	SlowRequestDuration time.Duration
	WatchConfig         bool

	EnableMetric bool
}

Jump to

Keyboard shortcuts

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