v2

package
v1.18.1-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 3 more Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorNoSuchPayloadType      = errors.New("not such payload type")
	ErrorInvalidRequestBodyType = errors.New("invalid request body type")
)

Functions

func WithAuthSvr

func WithAuthSvr(userSvr auth.UserServer, checkerSvr auth.StrategyServer) option

WithAuthSvr 设置鉴权 Server

func WithConfigSvr

func WithConfigSvr(configSvr config.ConfigCenterServer, originSvr config.ConfigCenterServer) option

func WithConnLimitConfig

func WithConnLimitConfig(connLimitConfig *connlimit.Config) option

func WithDiscoverSvr

func WithDiscoverSvr(discoverSvr service.DiscoverServer, originDiscoverSvr service.DiscoverServer,
	healthSvr *healthcheck.Server) option

func WithNamespaceSvr

func WithNamespaceSvr(namespaceSvr namespace.NamespaceOperateServer) option

func WithTLS

func WithTLS(tlsInfo *secure.TLSInfo) option

func WithVirtualStreamBaseServer

func WithVirtualStreamBaseServer(server *NacosV2Server) initVirtualStream

WithVirtualStreamBaseServer 设置 BaseGrpcServer

func WithVirtualStreamLogger

func WithVirtualStreamLogger(log *commonlog.Scope) initVirtualStream

WithVirtualStreamLogger 设置 Logger

func WithVirtualStreamMethod

func WithVirtualStreamMethod(method string) initVirtualStream

WithVirtualStreamMethod 设置 method

func WithVirtualStreamPostProcessFunc

func WithVirtualStreamPostProcessFunc(postprocess PostProcessFunc) initVirtualStream

WithVirtualStreamPostProcessFunc 设置 PostProcessFunc

func WithVirtualStreamPreProcessFunc

func WithVirtualStreamPreProcessFunc(preprocess PreProcessFunc) initVirtualStream

WithVirtualStreamPreProcessFunc 设置 PreProcessFunc

func WithVirtualStreamServerStream

func WithVirtualStreamServerStream(stream grpc.ServerStream) initVirtualStream

WithVirtualStreamServerStream 设置 grpc.ServerStream

Types

type NacosV2Server

type NacosV2Server struct {
	OpenMethod map[string]bool
	// contains filtered or unexported fields
}

NacosV2Server gRPC API服务器

func NewNacosV2Server

func NewNacosV2Server(v1Svr *v1.NacosV1Server, store *core.NacosDataStorage, options ...option) (*NacosV2Server, error)

func (*NacosV2Server) AllowAccess

func (h *NacosV2Server) AllowAccess(method string) bool

AllowAccess api allow access

func (*NacosV2Server) ConvertContext

func (h *NacosV2Server) ConvertContext(ctx context.Context) context.Context

ConvertContext 将GRPC上下文转换成内部上下文

func (*NacosV2Server) DescribeConnectionDetail

func (n *NacosV2Server) DescribeConnectionDetail(req *restful.Request, rsp *restful.Response)

DescribeConnectionDetail 查询某一个连接ID的详细信息

func (*NacosV2Server) DescribeConnections

func (n *NacosV2Server) DescribeConnections(req *restful.Request, rsp *restful.Response)

DescribeConnections 查询 V2 客户端的连接

func (*NacosV2Server) EnterRatelimit

func (h *NacosV2Server) EnterRatelimit(ip string, method string) uint32

EnterRatelimit api ratelimit

func (*NacosV2Server) GetPort

func (h *NacosV2Server) GetPort() uint32

GetPort get the connector listen port value

func (*NacosV2Server) GetProtocol

func (h *NacosV2Server) GetProtocol() string

GetProtocol 获取Server的协议

func (*NacosV2Server) Initialize

func (h *NacosV2Server) Initialize(ctx context.Context, option map[string]interface{}, port uint32,
	apiConf map[string]apiserver.APIConfig) error

Initialize 初始化HTTP API服务器

func (*NacosV2Server) RegistryDebugRoute

func (n *NacosV2Server) RegistryDebugRoute()

func (*NacosV2Server) Request

func (h *NacosV2Server) Request(ctx context.Context, payload *nacospb.Payload) (*nacospb.Payload, error)

func (*NacosV2Server) RequestBiStream

func (*NacosV2Server) Run

func (h *NacosV2Server) Run(errCh chan error)

Run 启动GRPC API服务器

func (*NacosV2Server) Stop

func (h *NacosV2Server) Stop()

Stop stopping the gRPC server

func (*NacosV2Server) UnmarshalPayload

func (h *NacosV2Server) UnmarshalPayload(payload *nacospb.Payload) (remote.RequestHandler, nacospb.CustomerPayload, error)

UnmarshalPayload .

type PostProcessFunc

type PostProcessFunc func(stream *VirtualStream, m interface{})

PostProcessFunc postprocess function define

type PreProcessFunc

type PreProcessFunc func(stream *VirtualStream, isPrint bool) error

PreProcessFunc preprocess function define

type RequestHandler

RequestHandler

type RequestHandlerWarrper

type RequestHandlerWarrper struct {
	Handler        RequestHandler
	PayloadBuilder func() nacospb.CustomerPayload
}

RequestHandlerWarrper

type VirtualStream

type VirtualStream struct {
	Method        string
	ClientAddress string
	ClientIP      string
	UserAgent     string
	RequestID     string

	Code int

	StartTime time.Time
	// contains filtered or unexported fields
}

VirtualStream 虚拟Stream 继承ServerStream

func (*VirtualStream) Context

func (v *VirtualStream) Context() context.Context

Context returns the context for this stream.

func (*VirtualStream) RecvMsg

func (v *VirtualStream) RecvMsg(m interface{}) error

RecvMsg blocks until it receives a message into m or the stream is done. It returns io.EOF when the client has performed a CloseSend. On any non-EOF error, the stream is aborted and the error contains the RPC status.

It is safe to have a goroutine calling SendMsg and another goroutine calling RecvMsg on the same stream at the same time, but it is not safe to call RecvMsg on the same stream in different goroutines.

func (*VirtualStream) SendHeader

func (v *VirtualStream) SendHeader(md metadata.MD) error

SendHeader sends the header metadata. The provided md and headers set by SetHeader() will be sent. It fails if called multiple times.

func (*VirtualStream) SendMsg

func (v *VirtualStream) SendMsg(m interface{}) error

SendMsg sends a message. On error, SendMsg aborts the stream and the error is returned directly.

SendMsg blocks until:

  • There is sufficient flow control to schedule m with the transport, or
  • The stream is done, or
  • The stream breaks.

SendMsg does not wait until the message is received by the client. An untimely stream closure may result in lost messages.

It is safe to have a goroutine calling SendMsg and another goroutine calling RecvMsg on the same stream at the same time, but it is not safe to call SendMsg on the same stream in different goroutines.

func (*VirtualStream) SetHeader

func (v *VirtualStream) SetHeader(md metadata.MD) error

SetHeader sets the header metadata. It may be called multiple times. When call multiple times, all the provided metadata will be merged. All the metadata will be sent out when one of the following happens:

  • ServerStream.SendHeader() is called;
  • The first response is sent out;
  • An RPC status is sent out (error or success).

func (*VirtualStream) SetTrailer

func (v *VirtualStream) SetTrailer(md metadata.MD)

SetTrailer sets the trailer metadata which will be sent with the RPC status. When called more than once, all the provided metadata will be merged.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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