kexecutor

package
v0.0.0-...-df7806a Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

type Executor struct {
	*process.ProcessPlus                 // Executor 对应的进程
	Pid                  int             // 在主进程中,缓存Executor对应的子进程的Pid
	Keeper               IKeeper         // Executor所属的管理者
	Name                 string          // 执行器名称
	AppList              *gmap.StrAnyMap // 保存的App列表,key: appName, value: appContainer
	AppsRunning          *gmap.StrAnyMap // 当前正在运行中的App
}

Executor 用于保存和运行App;一个Executor可以保存多个App。 在多进程模式下,一个Executor会开启一个新的进程来运行其下的所有App,一个App在新进程中对应一个goroutine。 在单进程模式下,EXecutor只会开启新的goroute来运行行App,所有的goroutine都在一个进程中。

func NewExecutor

func NewExecutor(execName string, k IKeeper) *Executor

Executor工厂

func (*Executor) AddApp

func (that *Executor) AddApp(a kapp.IApp) error

AddApp 添加App到Executor

func (*Executor) Clone

func (that *Executor) Clone() (process.IProc, error)

Clone 克隆Executor

func (*Executor) GetAppNeedToStart

func (that *Executor) GetAppNeedToStart() []string

GetAppCanStart 获取本Executor中需要在子进程中启动的AppNames

func (*Executor) GracefulReload

func (that *Executor) GracefulReload(wait bool) (bool, error)

GracefulReload 平滑重启Executor

func (*Executor) MakeApp

func (that *Executor) MakeApp(a kapp.IApp) (kapp.IApp, error)

通过反射生成私有app对象

func (*Executor) NewChildProcForStart

func (that *Executor) NewChildProcForStart(configFilePath string)

CreateNewProcess 启动新的子进程来执行start命令; 本方法只在主进程中执行; 一个子进程对应于一个Executor。

func (*Executor) RemoveApp

func (that *Executor) RemoveApp(name string)

RemoveApp 从Executor移除App

func (*Executor) StartAllApps

func (that *Executor) StartAllApps()

StartApps 启动Executor中需要启动的App; 多进程模式下,本方法在子进程中执行; 单进程模式下,本方法在主进程中执行(因为只有一个进程);

func (*Executor) StartApp

func (that *Executor) StartApp(name string) error

StartApp 启动指定的App

func (*Executor) StopApp

func (that *Executor) StopApp(name string) error

StopApp 关闭指定的App

func (*Executor) StopExecutor

func (that *Executor) StopExecutor()
TODO:

StopExecutor 停止执行当前Executor; 会关闭所有正在运行的App。

type IKeeper

type IKeeper interface {
	Config() *gcfg.Config
	IsMaster() bool
	ListOfAppsToStart() *garray.StrArray
	Mode() ktype.ProcMode
	NewProcess(name string, opts ...process.Option) (*process.ProcessPlus, error)
	ProcManager() *process.Manager
	GetExecutorsRunning() *gmap.StrAnyMap
}

Keeper实现本接口的方法在ki_executor.go中

Jump to

Keyboard shortcuts

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