idlrpc

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 13 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallUuid added in v0.3.2

type CallUuid uint32

CallUuid stub call uuid generate by manager

type IProxy added in v0.3.2

type IProxy 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.ITransport)

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

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

	// SetRpc set rpc instance to proxy
	SetRpc(IRpc)
	// GetRpc get rpc instance from proxy
	GetRpc() IRpc
}

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

type IService added in v0.3.1

type IService interface {

	// GetUUID service uuid, generated by rpc-repo
	GetUUID() uint64

	// OnAfterFork init service by framework, user can init some custom data in this function
	OnAfterFork() bool

	// OnTick tick your service the same goroutine
	OnTick() bool

	// OnBeforeDestroy before service unload, you can clean your own data in this func
	OnBeforeDestroy() bool
}

IService user custom service framework interface

type IStub added in v0.3.2

type IStub interface {
	//GetUUID service uuid, generate by rpc-repo
	GetUUID() SvcUuid
	//GetServiceName service name
	GetServiceName() string
	//GetSignature method human-readable name
	GetSignature(methodId uint32) string
	//GetMutipleNum service goroutine num, read from idl keyword multiple
	GetMutipleNum() uint32
	//IsOneWay one way function, not send response
	IsOneWay(methodId uint32) bool
	// Call  call service's method
	// return encode response buffer data and errors
	Call(*StubCall, []byte) ([]byte, error)
	//OnAfterFork invoke by framework after spawned
	//init service data or load db data in this function
	OnAfterFork() bool
	//OnBeforeDestroy invoke by framework before uninitialized
	//clean service data in this function
	OnBeforeDestroy() bool
	//OnTick tick by service manager in logic tick
	OnTick() bool
	//GetStatus get service status
	//TODO: for hot update
	GetStatus() ServiceStatus
	//SetStatus set service status
	SetStatus(status ServiceStatus)
}

IStub rpc stub of service's side

type ProxyBase added in v0.3.2

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

ProxyBase proxy common struct impl

func (*ProxyBase) GetID added in v0.3.2

func (base *ProxyBase) GetID() ProxyId

func (*ProxyBase) GetRpc added in v0.3.2

func (base *ProxyBase) GetRpc() IRpc

func (*ProxyBase) GetTargetID added in v0.3.2

func (base *ProxyBase) GetTargetID() uint32

func (*ProxyBase) GetTransport added in v0.3.2

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

func (*ProxyBase) IsConnected added in v0.3.2

func (base *ProxyBase) IsConnected() bool

func (*ProxyBase) SetID added in v0.3.2

func (base *ProxyBase) SetID(id ProxyId)

func (*ProxyBase) SetRpc added in v0.3.2

func (base *ProxyBase) SetRpc(r IRpc)

func (*ProxyBase) SetTargetID added in v0.3.2

func (base *ProxyBase) SetTargetID(id uint32)

func (*ProxyBase) SetTransport added in v0.3.2

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

SetTransport set network message transport called by creator

type ProxyCreator added in v0.3.2

type ProxyCreator func(transport.ITransport) IProxy

ProxyCreator proxy creator, one client may connect to differently service

type ProxyId added in v0.3.2

type ProxyId proxy2.ProxyUuid

type ProxyManager added in v0.3.2

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 (*ProxyManager) Add added in v0.3.2

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

func (*ProxyManager) Destroy added in v0.3.2

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

func (*ProxyManager) GeneProxyId added in v0.3.2

func (p *ProxyManager) GeneProxyId() ProxyId

func (*ProxyManager) Get added in v0.3.2

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

type ProxyMap added in v0.3.2

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

type ServiceCache added in v0.3.2

type ServiceCache map[SvcUuid]*stubWrapper

ServiceCache service storage struct

type ServiceCreator added in v0.3.1

type ServiceCreator func(interface{}) IService

ServiceCreator service creator

type ServiceStatus added in v0.3.2

type ServiceStatus uint32
const (
	SERVICE_RESOLVED ServiceStatus = iota + 1 //ready for servicing
	SERVICE_UPDATING                          //stop receive message, wait for update
)

type StubCall added in v0.3.2

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

StubCall remote call data

func (*StubCall) CallID added in v0.3.2

func (sc *StubCall) CallID() uint32

CallID rpc remote proxyCall call id

func (*StubCall) GetServiceUUID added in v0.3.2

func (sc *StubCall) GetServiceUUID() uint64

func (*StubCall) GetUUID added in v0.3.2

func (sc *StubCall) GetUUID() CallUuid

GetUUID stub call uuid

func (*StubCall) MethodID added in v0.3.2

func (sc *StubCall) MethodID() uint32

MethodID rpc method call id

type StubCreator added in v0.3.2

type StubCreator func(v interface{}) IStub

StubCreator stub factory

type StubManager added in v0.3.2

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

StubManager stub manager, manager registered service

func (*StubManager) Add added in v0.3.2

func (m *StubManager) Add(impl IStub) (err error)

func (*StubManager) GeneUuid added in v0.3.2

func (m *StubManager) GeneUuid() CallUuid

func (*StubManager) Get added in v0.3.2

func (m *StubManager) Get(uuid SvcUuid) *stubWrapper

func (*StubManager) Init added in v0.3.2

func (m *StubManager) Init(logger log.ILogger)

func (*StubManager) Tick added in v0.3.2

func (m *StubManager) Tick()

type SvcUuid added in v0.3.2

type SvcUuid uint64

SvcUuid service uuid type

type Trans2Proxy added in v0.3.2

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

Directories

Path Synopsis
goidltool module
idl2go module
internal
pkg
log

Jump to

Keyboard shortcuts

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