service

package
v1.21.11 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 14 Imported by: 20

Documentation

Index

Constants

View Source
const InitModuleId = 1e9

Variables

This section is empty.

Functions

func Init

func Init()

func NotifyAllServiceRetire added in v1.21.4

func NotifyAllServiceRetire()

func SetMaxServiceChannel

func SetMaxServiceChannel(maxEventChannel int)

func Setup

func Setup(s IService) bool

func Start

func Start()

func StopAllService added in v1.19.3

func StopAllService()

Types

type DiscoveryServiceEvent added in v1.18.3

type DiscoveryServiceEvent struct {
	IsDiscovery bool
	ServiceName []string
	NodeId      int
}

DiscoveryServiceEvent 发现服务结点

func (*DiscoveryServiceEvent) GetEventType added in v1.18.3

func (rpcEventData *DiscoveryServiceEvent) GetEventType() event.EventType

type IModule

type IModule interface {
	concurrent.IConcurrent
	SetModuleId(moduleId uint32) bool
	GetModuleId() uint32
	AddModule(module IModule) (uint32, error)
	GetModule(moduleId uint32) IModule
	GetAncestor() IModule
	ReleaseModule(moduleId uint32)
	NewModuleId() uint32
	GetParent() IModule
	OnInit() error
	OnRelease()

	GetService() IService
	GetModuleName() string
	GetEventProcessor() event.IEventProcessor
	NotifyEvent(ev event.IEvent)
	// contains filtered or unexported methods
}

type IModuleTimer

type IModuleTimer interface {
	AfterFunc(d time.Duration, cb func(*timer.Timer)) *timer.Timer
	CronFunc(cronExpr *timer.CronExpr, cb func(*timer.Cron)) *timer.Cron
	NewTicker(d time.Duration, cb func(*timer.Ticker)) *timer.Ticker
}

type IService

type IService interface {
	concurrent.IConcurrent
	Init(iService IService, getClientFun rpc.FuncRpcClient, getServerFun rpc.FuncRpcServer, serviceCfg interface{})
	Stop()
	Start()

	OnSetup(iService IService)
	OnInit() error
	OnStart()
	OnRetire()
	OnRelease()

	SetName(serviceName string)
	GetName() string
	GetRpcHandler() rpc.IRpcHandler
	GetServiceCfg() interface{}
	GetProfiler() *profiler.Profiler
	GetServiceEventChannelNum() int
	GetServiceTimerChannelNum() int

	SetEventChannelNum(num int)
	OpenProfiler()

	SetRetire()     //设置服务退休状态
	IsRetire() bool //服务是否退休
}

func GetService

func GetService(serviceName string) IService

type Module

type Module struct {
	rpcHandle.IRpcHandler

	concurrent.IConcurrent
	// contains filtered or unexported fields
}

func (*Module) AddModule

func (m *Module) AddModule(module IModule) (uint32, error)

func (*Module) AfterFunc

func (m *Module) AfterFunc(d time.Duration, cb func(*timer.Timer)) *timer.Timer

func (*Module) CancelTimerId

func (m *Module) CancelTimerId(timerId *uint64) bool

func (*Module) CronFunc

func (m *Module) CronFunc(cronExpr *timer.CronExpr, cb func(*timer.Cron)) *timer.Cron

func (*Module) GenTimerId

func (m *Module) GenTimerId() uint64

func (*Module) GetAncestor

func (m *Module) GetAncestor() IModule

func (*Module) GetEventHandler

func (m *Module) GetEventHandler() event.IEventHandler

func (*Module) GetEventProcessor

func (m *Module) GetEventProcessor() event.IEventProcessor

func (*Module) GetModule

func (m *Module) GetModule(moduleId uint32) IModule

func (*Module) GetModuleId

func (m *Module) GetModuleId() uint32

func (*Module) GetModuleName

func (m *Module) GetModuleName() string

func (*Module) GetParent

func (m *Module) GetParent() IModule

func (*Module) GetService

func (m *Module) GetService() IService

func (*Module) NewModuleId

func (m *Module) NewModuleId() uint32

func (*Module) NewTicker

func (m *Module) NewTicker(d time.Duration, cb func(*timer.Ticker)) *timer.Ticker

func (*Module) NotifyEvent

func (m *Module) NotifyEvent(ev event.IEvent)

func (*Module) OnAddTimer

func (m *Module) OnAddTimer(t timer.ITimer)

func (*Module) OnCloseTimer

func (m *Module) OnCloseTimer(t timer.ITimer)

func (*Module) OnInit

func (m *Module) OnInit() error

func (*Module) OnRelease

func (m *Module) OnRelease()

func (*Module) ReleaseModule

func (m *Module) ReleaseModule(moduleId uint32)

func (*Module) SafeAfterFunc

func (m *Module) SafeAfterFunc(timerId *uint64, d time.Duration, AdditionData interface{}, cb func(uint64, interface{}))

func (*Module) SafeCronFunc

func (m *Module) SafeCronFunc(cronId *uint64, cronExpr *timer.CronExpr, AdditionData interface{}, cb func(uint64, interface{}))

func (*Module) SafeNewTicker

func (m *Module) SafeNewTicker(tickerId *uint64, d time.Duration, AdditionData interface{}, cb func(uint64, interface{}))

func (*Module) SetModuleId

func (m *Module) SetModuleId(moduleId uint32) bool

type RegDiscoveryServiceEventFunType added in v1.18.3

type RegDiscoveryServiceEventFunType func(serviceName string)
var RegDiscoveryServiceEventFun RegDiscoveryServiceEventFunType
var UnRegDiscoveryServiceEventFun RegDiscoveryServiceEventFunType

type RegRpcEventFunType

type RegRpcEventFunType func(serviceName string)
var RegRpcEventFun RegRpcEventFunType
var UnRegRpcEventFun RegRpcEventFunType

type RpcConnEvent

type RpcConnEvent struct {
	IsConnect bool
	NodeId    int
}

RpcConnEvent Node结点连接事件

func (*RpcConnEvent) GetEventType

func (rpcEventData *RpcConnEvent) GetEventType() event.EventType

type Service

type Service struct {
	Module
	// contains filtered or unexported fields
}

func (*Service) GetName

func (s *Service) GetName() string

func (*Service) GetProfiler

func (s *Service) GetProfiler() *profiler.Profiler

func (*Service) GetServiceCfg

func (s *Service) GetServiceCfg() interface{}

func (*Service) GetServiceEventChannelNum added in v1.18.3

func (s *Service) GetServiceEventChannelNum() int

func (*Service) GetServiceTimerChannelNum added in v1.18.3

func (s *Service) GetServiceTimerChannelNum() int

func (*Service) Init

func (s *Service) Init(iService IService, getClientFun rpc.FuncRpcClient, getServerFun rpc.FuncRpcServer, serviceCfg interface{})

func (*Service) IsRetire added in v1.21.4

func (s *Service) IsRetire() bool

func (*Service) IsSingleCoroutine

func (s *Service) IsSingleCoroutine() bool

func (*Service) OnDiscoverServiceEvent added in v1.18.3

func (s *Service) OnDiscoverServiceEvent(ev event.IEvent)

func (*Service) OnInit

func (s *Service) OnInit() error

func (*Service) OnNodeEvent added in v1.18.3

func (s *Service) OnNodeEvent(ev event.IEvent)

func (*Service) OnRelease

func (s *Service) OnRelease()

func (*Service) OnRetire added in v1.21.4

func (s *Service) OnRetire()

func (*Service) OnSetup

func (s *Service) OnSetup(iService IService)

func (*Service) OnStart

func (s *Service) OnStart()

func (*Service) OpenProfiler

func (s *Service) OpenProfiler()

func (*Service) PushEvent

func (s *Service) PushEvent(ev event.IEvent) error

func (*Service) PushRpcRequest

func (s *Service) PushRpcRequest(rpcRequest *rpc.RpcRequest) error

func (*Service) PushRpcResponse

func (s *Service) PushRpcResponse(call *rpc.Call) error

func (*Service) RegDiscoverListener added in v1.18.3

func (s *Service) RegDiscoverListener(discoveryServiceListener rpc.IDiscoveryServiceListener)

func (*Service) RegEventReceiverFunc

func (s *Service) RegEventReceiverFunc(eventType event.EventType, receiver event.IEventHandler, callback event.EventCallBack)

func (*Service) RegRawRpc

func (s *Service) RegRawRpc(rpcMethodId uint32, rawRpcCB rpc.RawRpcCallBack)

func (*Service) RegRpcListener

func (s *Service) RegRpcListener(rpcEventLister rpc.INodeListener)

func (*Service) Release

func (s *Service) Release()

func (*Service) Run

func (s *Service) Run()

func (*Service) SetEventChannelNum added in v1.18.3

func (s *Service) SetEventChannelNum(num int)

func (*Service) SetGoRoutineNum

func (s *Service) SetGoRoutineNum(goroutineNum int32) bool

func (*Service) SetName

func (s *Service) SetName(serviceName string)

func (*Service) SetRetire added in v1.21.4

func (s *Service) SetRetire()

func (*Service) Start

func (s *Service) Start()

func (*Service) Stop added in v1.19.3

func (s *Service) Stop()

func (*Service) UnRegDiscoverListener added in v1.18.3

func (s *Service) UnRegDiscoverListener(rpcLister rpc.INodeListener)

func (*Service) UnRegEventReceiverFunc

func (s *Service) UnRegEventReceiverFunc(eventType event.EventType, receiver event.IEventHandler)

func (*Service) UnRegRpcListener

func (s *Service) UnRegRpcListener(rpcLister rpc.INodeListener)

Jump to

Keyboard shortcuts

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