protocol

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClientClosed     = perrors.New("remoting client has closed")
	ErrNoReply          = perrors.New("request need @response")
	ErrDestroyedInvoker = perrors.New("request Destroyed invoker")
)

Functions

func BeginCount

func BeginCount(url *common.URL, methodName string)

BeginCount gets begin count.

func CleanAllStatus

func CleanAllStatus()

CleanAllStatus is used to clean all status

func CurrentTimeMillis

func CurrentTimeMillis() int64

CurrentTimeMillis get current timestamp

func EndCount

func EndCount(url *common.URL, methodName string, elapsed int64, succeeded bool)

EndCount gets end count.

func GetAndRefreshState

func GetAndRefreshState() bool

func GetInvokerHealthyStatus

func GetInvokerHealthyStatus(invoker Invoker) bool

GetInvokerHealthyStatus get invoker's conn healthy status

func RemoveInvokerUnhealthyStatus

func RemoveInvokerUnhealthyStatus(invoker Invoker)

RemoveInvokerUnhealthyStatus remove unhealthy status of target invoker from blacklist

func RemoveUrlKeyUnhealthyStatus

func RemoveUrlKeyUnhealthyStatus(key string)

RemoveUrlKeyUnhealthyStatus called when event of provider unregister, delete from black list

func SetInvokerUnhealthyStatus

func SetInvokerUnhealthyStatus(invoker Invoker)

SetInvokerUnhealthyStatus add target invoker to black list

func TryRefreshBlackList

func TryRefreshBlackList()

TryRefreshBlackList start 3 gr to check at most block=16 invokers in black list if target invoker is available, then remove it from black list

Types

type BaseExporter

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

BaseExporter is default exporter implement.

func NewBaseExporter

func NewBaseExporter(key string, invoker Invoker, exporterMap *sync.Map) *BaseExporter

NewBaseExporter creates a new BaseExporter

func (*BaseExporter) GetInvoker

func (de *BaseExporter) GetInvoker() Invoker

GetInvoker gets invoker

func (*BaseExporter) Unexport

func (de *BaseExporter) Unexport()

Unexport exported service.

type BaseInvoker

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

BaseInvoker provides default invoker implements Invoker

func NewBaseInvoker

func NewBaseInvoker(url *common.URL) *BaseInvoker

NewBaseInvoker creates a new BaseInvoker

func (*BaseInvoker) Destroy

func (bi *BaseInvoker) Destroy()

Destroy changes available and destroyed flag

func (*BaseInvoker) GetURL

func (bi *BaseInvoker) GetURL() *common.URL

GetURL gets base invoker URL

func (*BaseInvoker) Invoke

func (bi *BaseInvoker) Invoke(context context.Context, invocation Invocation) Result

Invoke provides default invoker implement

func (*BaseInvoker) IsAvailable

func (bi *BaseInvoker) IsAvailable() bool

IsAvailable gets available flag

func (*BaseInvoker) IsDestroyed

func (bi *BaseInvoker) IsDestroyed() bool

IsDestroyed gets destroyed flag

func (*BaseInvoker) String

func (bi *BaseInvoker) String() string

type BaseProtocol

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

BaseProtocol is default protocol implement.

func NewBaseProtocol

func NewBaseProtocol() BaseProtocol

NewBaseProtocol creates a new BaseProtocol

func (*BaseProtocol) Destroy

func (bp *BaseProtocol) Destroy()

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

func (*BaseProtocol) Export

func (bp *BaseProtocol) Export(invoker Invoker) Exporter

Export is default export implement.

func (*BaseProtocol) ExporterMap

func (bp *BaseProtocol) ExporterMap() *sync.Map

ExporterMap gets exporter map.

func (*BaseProtocol) Invokers

func (bp *BaseProtocol) Invokers() []Invoker

Invokers gets all invokers

func (*BaseProtocol) Refer

func (bp *BaseProtocol) Refer(url *common.URL) Invoker

Refer is default refer implement.

func (*BaseProtocol) SetExporterMap

func (bp *BaseProtocol) SetExporterMap(key string, exporter Exporter)

SetExporterMap set @exporter with @key to local memory.

func (*BaseProtocol) SetInvokers

func (bp *BaseProtocol) SetInvokers(invoker Invoker)

SetInvokers sets invoker into local memory

type Exporter

type Exporter interface {
	GetInvoker() Invoker
	Unexport()
}

Exporter is the interface that wraps the basic GetInvoker method and Destroy Unexport.

GetInvoker method is to get invoker.

Unexport method is to unexport a exported service

type Invocation

type Invocation interface {
	// MethodName gets invocation method name.
	MethodName() string
	// ActualMethodName gets actual invocation method name. It returns the method name been called if it's a generic call
	ActualMethodName() string
	// ParameterTypeNames gets invocation parameter type names.
	ParameterTypeNames() []string
	// ParameterTypes gets invocation parameter types.
	ParameterTypes() []reflect.Type
	// ParameterValues gets invocation parameter values.
	ParameterValues() []reflect.Value
	// Arguments gets arguments.
	Arguments() []interface{}
	// Reply gets response of request
	Reply() interface{}

	// Invoker gets the invoker in current context.
	Invoker() Invoker
	// IsGenericInvocation gets if this is a generic invocation
	IsGenericInvocation() bool

	Attachments() map[string]interface{}
	SetAttachment(key string, value interface{})
	GetAttachment(key string) (string, bool)
	GetAttachmentInterface(string) interface{}
	GetAttachmentWithDefaultValue(key string, defaultValue string) string

	// Attributes firstly introduced on dubbo-java 2.7.6. It is
	// used in internal invocation, that is, it's not passed between
	// server and client.
	Attributes() map[string]interface{}
	SetAttribute(key string, value interface{})
	GetAttribute(key string) (interface{}, bool)
	GetAttributeWithDefaultValue(key string, defaultValue interface{}) interface{}
}

Invocation is a interface which is invocation for each remote method.

type Invoker

type Invoker interface {
	common.Node
	// Invoke the invocation and return result.
	Invoke(context.Context, Invocation) Result
}

Invoker the service invocation interface for the consumer Extension - Invoker

func GetBlackListInvokers

func GetBlackListInvokers(blockSize int) []Invoker

GetBlackListInvokers get at most size of blockSize invokers from black list

type Protocol

type Protocol interface {
	Export(invoker Invoker) Exporter
	Refer(url *common.URL) Invoker
	Destroy()
}

Protocol is the interface that wraps the basic Export、 Refer and Destroy method.

Export method is to export service for remote invocation

Refer method is to refer a remote service

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

type RPCResult

type RPCResult struct {
	Attrs map[string]interface{}
	Err   error
	Rest  interface{}
}

RPCResult is default RPC result.

func (*RPCResult) AddAttachment

func (r *RPCResult) AddAttachment(key string, value interface{})

AddAttachment adds the specified map to existing attachments in this instance.

func (*RPCResult) Attachment

func (r *RPCResult) Attachment(key string, defaultValue interface{}) interface{}

Attachment gets attachment by key with default value.

func (*RPCResult) Attachments

func (r *RPCResult) Attachments() map[string]interface{}

Attachments gets all attachments

func (*RPCResult) Error

func (r *RPCResult) Error() error

Error gets error.

func (*RPCResult) Result

func (r *RPCResult) Result() interface{}

Result gets invoker result.

func (*RPCResult) SetAttachments

func (r *RPCResult) SetAttachments(attr map[string]interface{})

SetAttachments replaces the existing attachments with the specified param.

func (*RPCResult) SetError

func (r *RPCResult) SetError(err error)

SetError sets error.

func (*RPCResult) SetResult

func (r *RPCResult) SetResult(rest interface{})

SetResult sets invoker result.

func (*RPCResult) String

func (r *RPCResult) String() string

type RPCStatus

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

RPCStatus is URL statistics.

func GetMethodStatus

func GetMethodStatus(url *common.URL, methodName string) *RPCStatus

GetMethodStatus get method RPC status.

func GetURLStatus

func GetURLStatus(url *common.URL) *RPCStatus

GetURLStatus get URL RPC status.

func (*RPCStatus) GetActive

func (rpc *RPCStatus) GetActive() int32

GetActive gets active.

func (*RPCStatus) GetFailed

func (rpc *RPCStatus) GetFailed() int32

GetFailed gets failed.

func (*RPCStatus) GetFailedElapsed

func (rpc *RPCStatus) GetFailedElapsed() int64

GetFailedElapsed gets failed elapsed.

func (*RPCStatus) GetFailedMaxElapsed

func (rpc *RPCStatus) GetFailedMaxElapsed() int64

GetFailedMaxElapsed gets failed max elapsed.

func (*RPCStatus) GetLastRequestFailedTimestamp

func (rpc *RPCStatus) GetLastRequestFailedTimestamp() int64

GetLastRequestFailedTimestamp gets last request failed timestamp.

func (*RPCStatus) GetMaxElapsed

func (rpc *RPCStatus) GetMaxElapsed() int64

GetMaxElapsed gets max elapsed.

func (*RPCStatus) GetSucceededMaxElapsed

func (rpc *RPCStatus) GetSucceededMaxElapsed() int64

GetSucceededMaxElapsed gets succeeded max elapsed.

func (*RPCStatus) GetSuccessiveRequestFailureCount

func (rpc *RPCStatus) GetSuccessiveRequestFailureCount() int32

GetSuccessiveRequestFailureCount gets successive request failure count.

func (*RPCStatus) GetTotal

func (rpc *RPCStatus) GetTotal() int32

GetTotal gets total.

func (*RPCStatus) GetTotalElapsed

func (rpc *RPCStatus) GetTotalElapsed() int64

GetTotalElapsed gets total elapsed.

type Result

type Result interface {
	SetError(error)
	Error() error
	SetResult(interface{})
	Result() interface{}
	SetAttachments(map[string]interface{})
	Attachments() map[string]interface{}
	AddAttachment(string, interface{})
	Attachment(string, interface{}) interface{}
}

Result is a interface that represents RPC result

SetError method sets error.

Error method gets error.

SetResult method sets invoker result.

Result method gets invoker result.

SetAttachments method replaces the existing attachments with the specified param.

Attachments method gets all attachments

AddAttachment method adds the specified map to existing attachments in this instance.

Attachment method gets attachment by key with default value.

Directories

Path Synopsis
Package dubbo implements dubbo rpc protocol.
Package dubbo implements dubbo rpc protocol.
Package dubbo3 implements dubbo3.0 rpc protocol.
Package dubbo3 implements dubbo3.0 rpc protocol.
reflection
Package reflection implements server reflection service.
Package reflection implements server reflection service.
Package grpc implements grpc rpc protocol.
Package grpc implements grpc rpc protocol.
Package jsonrpc implements json rpc protocol.
Package jsonrpc implements json rpc protocol.
Package mock is a generated GoMock package.
Package mock is a generated GoMock package.
Package rest implements restful rpc protocol.
Package rest implements restful rpc protocol.

Jump to

Keyboard shortcuts

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