grpc

package
v1.5.9 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2022 License: Apache-2.0 Imports: 25 Imported by: 16

Documentation

Index

Constants

View Source
const (
	// GRPC module name
	GRPC = "grpc"
)

Variables

This section is empty.

Functions

func GetProtocol

func GetProtocol() protocol.Protocol

GetProtocol gets gRPC protocol , will create if null.

Types

type Client

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

Client is gRPC client include client connection and invoker

func NewClient

func NewClient(url *common.URL) (*Client, error)

NewClient creates a new gRPC client.

type ClientConfig added in v1.5.0

type ClientConfig struct {
	// content type, more information refer by https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#requests
	ContentSubType string `default:"proto" yaml:"content_sub_type" json:"content_sub_type,omitempty"`
}

ClientConfig wrap client call parameters

func GetClientConfig added in v1.5.0

func GetClientConfig() ClientConfig

GetClientConfig return grpc client custom call options

func GetDefaultClientConfig added in v1.5.0

func GetDefaultClientConfig() ClientConfig

GetDefaultClientConfig return grpc client default call options

func (*ClientConfig) Validate added in v1.5.0

func (c *ClientConfig) Validate() error

Validate check if custom config encoding is supported in dubbo grpc

type DubboGrpcService

type DubboGrpcService interface {
	// SetProxyImpl sets proxy.
	SetProxyImpl(impl protocol.Invoker)
	// GetProxyImpl gets proxy.
	GetProxyImpl() protocol.Invoker
	// ServiceDesc gets an RPC service's specification.
	ServiceDesc() *grpc.ServiceDesc
}

DubboGrpcService is gRPC service

type GrpcExporter

type GrpcExporter struct {
	*protocol.BaseExporter
}

nolint

func NewGrpcExporter

func NewGrpcExporter(key string, invoker protocol.Invoker, exporterMap *sync.Map) *GrpcExporter

NewGrpcExporter creates a new gRPC exporter

func (*GrpcExporter) Unexport

func (gg *GrpcExporter) Unexport()

Unexport and unregister gRPC service from registry and memory.

type GrpcInvoker

type GrpcInvoker struct {
	protocol.BaseInvoker
	// contains filtered or unexported fields
}

nolint

func NewGrpcInvoker

func NewGrpcInvoker(url *common.URL, client *Client) *GrpcInvoker

NewGrpcInvoker returns a Grpc invoker instance

func (*GrpcInvoker) Destroy

func (gi *GrpcInvoker) Destroy()

Destroy will destroy gRPC's invoker and client, so it is only called once

func (*GrpcInvoker) Invoke

func (gi *GrpcInvoker) Invoke(ctx context.Context, invocation protocol.Invocation) protocol.Result

Invoke is used to call service method by invocation

func (*GrpcInvoker) IsAvailable

func (gi *GrpcInvoker) IsAvailable() bool

IsAvailable get available status

func (*GrpcInvoker) IsDestroyed

func (gi *GrpcInvoker) IsDestroyed() bool

IsDestroyed get destroyed status

type GrpcProtocol

type GrpcProtocol struct {
	protocol.BaseProtocol
	// contains filtered or unexported fields
}

GrpcProtocol is gRPC protocol

func NewGRPCProtocol

func NewGRPCProtocol() *GrpcProtocol

NewGRPCProtocol creates new gRPC protocol

func (*GrpcProtocol) Destroy

func (gp *GrpcProtocol) Destroy()

Destroy will destroy gRPC all invoker and exporter, so it only is called once.

func (*GrpcProtocol) Export

func (gp *GrpcProtocol) Export(invoker protocol.Invoker) protocol.Exporter

Export gRPC service for remote invocation

func (*GrpcProtocol) Refer

func (gp *GrpcProtocol) Refer(url *common.URL) protocol.Invoker

Refer a remote gRPC service

type Server

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

Server is a gRPC server

func NewServer

func NewServer() *Server

NewServer creates a new server

func (*Server) SetBufferSize added in v1.5.5

func (s *Server) SetBufferSize(n int)

func (*Server) Start

func (s *Server) Start(url *common.URL)

Start gRPC server with @url

func (*Server) Stop

func (s *Server) Stop()

Stop gRPC server

type ServerConfig added in v1.5.0

type ServerConfig struct {
}

ServerConfig currently is empty struct,for future expansion

func GetDefaultServerConfig added in v1.5.0

func GetDefaultServerConfig() ServerConfig

GetDefaultServerConfig currently return empty struct,for future expansion

func (*ServerConfig) Validate added in v1.5.0

func (c *ServerConfig) Validate() error

Validate currently return empty struct,for future expansion

Directories

Path Synopsis
just for test, never use internal for production.
just for test, never use internal for production.
plugin/dubbo
Package dubbo plugin for protobuf.
Package dubbo plugin for protobuf.

Jump to

Keyboard shortcuts

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