proxy

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallMethod

func CallMethod(pImpl Proxy, call *ProxyCall, methodId uint32, msg proto.Message) (resp *protocol.ResponsePackage, err error)

CallMethod proxy call helper rpc proxy call remote stub, create proxy call and wait for response

Types

type CallMap

type CallMap map[uint32]*ProxyCall

type Proxy

type Proxy interface {

	// GetUUID service uuid
	// @detail get service uuid id which generated by rpc-repo
	GetUUID() uint64

	// GetSignature
	// get method human-readable name
	GetSignature(uint32) string

	// GetID
	//get proxy instance ID, priority delivery service instance
	GetID() ProxyId

	// SetID
	// set proxy instance ID
	SetID(ProxyId)

	// SetTargetID
	// last return service id, maybe some service box need
	SetTargetID(uint32)

	// GetTargetID
	// return last return service id
	GetTargetID() uint32

	// IsOneWay oneway
	//@detail is one way function which not wait for return
	//@param method id
	IsOneWay(uint32) bool

	// GetSrvName
	//@detail get proxy name
	GetSrvName() string

	// SetTransport
	// @detail set transport
	SetTransport(transport transport.Transport)

	// GetTransport
	//@detail get transport
	GetTransport() transport.Transport

	// IsConnected
	// check transport valid state
	IsConnected() bool
}

Proxy Proxy, user's idl proxy interface, using as client to call remote function; rpc framewrok set transport to it

type ProxyBase

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

ProxyBase proxy common struct impl

func (*ProxyBase) GetID

func (base *ProxyBase) GetID() ProxyId

func (*ProxyBase) GetTargetID

func (base *ProxyBase) GetTargetID() uint32

func (*ProxyBase) GetTransport

func (base *ProxyBase) GetTransport() transport.Transport

func (*ProxyBase) IsConnected

func (base *ProxyBase) IsConnected() bool

func (*ProxyBase) SetID

func (base *ProxyBase) SetID(id ProxyId)

func (*ProxyBase) SetTargetID

func (base *ProxyBase) SetTargetID(id uint32)

func (*ProxyBase) SetTransport

func (base *ProxyBase) SetTransport(trans transport.Transport)

SetTransport set network message transport @detail been called by proxy creater

type ProxyCall

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

ProxyCall rpc-proxy call information of remote call description

func (*ProxyCall) DecRetryTime

func (pc *ProxyCall) DecRetryTime()

DecRetryTime decrease retry time, read & write in worker goroutine

func (*ProxyCall) DoRet

func (pc *ProxyCall) DoRet(resp *protocol.ResponsePackage)

func (*ProxyCall) GetID

func (pc *ProxyCall) GetID() uint32

func (*ProxyCall) GetProxyId

func (pc *ProxyCall) GetProxyId() ProxyId

func (*ProxyCall) GetRetryTime

func (pc *ProxyCall) GetRetryTime() int32

GetRetryTime get left retry time

func (*ProxyCall) GetTimeOut

func (pc *ProxyCall) GetTimeOut() uint32

GetTimeOut timeout millisecond

func (*ProxyCall) SetErrorCode

func (pc *ProxyCall) SetErrorCode(errCode uint32)

type ProxyCallManager

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

ProxyCallManager manager proxy call for multi goroutine

func NewCallManager

func NewCallManager() *ProxyCallManager

func (*ProxyCallManager) Add

func (pcm *ProxyCallManager) Add(pc *ProxyCall) error

func (*ProxyCallManager) CreateProxyCall

func (pcm *ProxyCallManager) CreateProxyCall(proxyId ProxyId, timeOut uint32, retryTime int32) *ProxyCall

func (*ProxyCallManager) Destroy

func (pcm *ProxyCallManager) Destroy(callId uint32)

func (*ProxyCallManager) GenCallID

func (pcm *ProxyCallManager) GenCallID() uint32

func (*ProxyCallManager) Get

func (pcm *ProxyCallManager) Get(callId uint32) *ProxyCall

type ProxyCreator

type ProxyCreator func(transport.Transport) Proxy

ProxyCreator proxy creator, one client may connect to differently service

type ProxyCreatorMap

type ProxyCreatorMap map[uint64]ProxyCreator

type ProxyId

type ProxyId uint32

type ProxyManager

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

ProxyManager manager connect proxy for rpc framework, multiple may be read & write TODO add tranport id 2 service uid cache

func NewProxyManager

func NewProxyManager() *ProxyManager

NewProxyManager create new proxy manager, init proxymap and mutex

func (*ProxyManager) Add

func (p *ProxyManager) Add(proxy Proxy) error

func (*ProxyManager) AddCreator

func (p *ProxyManager) AddCreator(srvUid uint64, creator ProxyCreator)

AddCreator add proxy creator while init package, goroutine not start yet

func (*ProxyManager) Destroy

func (p *ProxyManager) Destroy(proxyId uint32) error

func (*ProxyManager) GeneProxyId

func (p *ProxyManager) GeneProxyId() ProxyId

func (*ProxyManager) Get

func (p *ProxyManager) Get(proxyId ProxyId) (Proxy, error)

func (*ProxyManager) GetOrCreateByTrans

func (p *ProxyManager) GetOrCreateByTrans(srvUid uint64, trans transport.Transport) (pInst Proxy, err error)

type ProxyMap

type ProxyMap map[ProxyId]Proxy //key, proxyid, value proxy interface

type Trans2Proxy

type Trans2Proxy map[uint64]Proxy //service uuid, proxy interface

Jump to

Keyboard shortcuts

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