modules

package
v1.6.7 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

* 一定要记得在confin.json配置这个模块的参数,否则无法使用

* 一定要记得在confin.json配置这个模块的参数,否则无法使用

Index

Constants

This section is empty.

Variables

View Source
var MasterModule = func() module.Module {
	master := new(Master)
	return master
}
View Source
var TimerModule = func() module.Module {
	Timer := new(Timer)
	return Timer
}

Functions

This section is empty.

Types

type HttpResponse

type HttpResponse struct {
	Error  string
	Code   string
	Result interface{}
}

func NewErrorResponse

func NewErrorResponse(Code string, Error string) *HttpResponse

func NewHttpResponse

func NewHttpResponse(Code string, Result interface{}) *HttpResponse

func (*HttpResponse) String

func (h *HttpResponse) String() string

type Master

type Master struct {
	basemodule.BaseModule

	ProcessMap    map[string]*master.Process
	ModuleReports map[string]*ModuleReport //moduleID -- ModuleReport
	// contains filtered or unexported fields
}

func (*Master) GetArgs

func (m *Master) GetArgs(req *http.Request) map[string]string

func (*Master) GetType

func (m *Master) GetType() string

func (*Master) ModuleList

func (m *Master) ModuleList(w http.ResponseWriter, req *http.Request)

* 获取模块状态

func (*Master) OnDestroy

func (m *Master) OnDestroy()

func (*Master) OnInit

func (m *Master) OnInit(app module.App, settings *conf.ModuleSettings)

func (*Master) ProcessList

func (m *Master) ProcessList(w http.ResponseWriter, req *http.Request)

* 获取进程状态

func (*Master) ReportForm

func (m *Master) ReportForm(moduleType string, ProcessID string, Id string, Version string, statistics string, Executing int64) (result string, err string)

* 模块汇报

func (*Master) Run

func (m *Master) Run(closeSig chan bool)

func (*Master) StartProcess

func (m *Master) StartProcess(w http.ResponseWriter, req *http.Request)

* 启动进程

func (*Master) StopProcess

func (m *Master) StopProcess(w http.ResponseWriter, req *http.Request)

* 停止进程

func (*Master) UpdateProcessState

func (m *Master) UpdateProcessState(w http.ResponseWriter, req *http.Request)

* 刷新进程状态

func (*Master) Version

func (m *Master) Version() string

type ModuleReport

type ModuleReport struct {
	ModuleType string
	Id         string
	Version    string
	ProcessID  string
	Executing  int64                                    //当前正在执行的函数数量,暂态的,下一次上报时刷新
	ReportForm map[string]*basemodule.StatisticalMethod //运行状态报表
}

* 每一个模块的最新汇报信息

type Timer

type Timer struct {
	module.Module
}

func (*Timer) GetType

func (m *Timer) GetType() string

func (*Timer) OnDestroy

func (m *Timer) OnDestroy()

func (*Timer) OnInit

func (m *Timer) OnInit(app module.App, settings *conf.ModuleSettings)

func (*Timer) Run

func (m *Timer) Run(closeSig chan bool)
func (m *Timer)callback2(args interface{}) {
	//每次在当前时间点之后5s插入一个定时器,这样就能形成每隔5秒调用一次callback2回调函数,可以用于周期性事件
	SetTimer("callback2", 60, m.callback2, time.Now().UnixNano())
	log.Debug("time",(time.Now().UnixNano()-args.(int64))/1000000)
	fmt.Println(time.Now().Format("2006-01-02 15:04:05"))
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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