heca

package module
v0.0.0-...-1cb3af8 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2017 License: GPL-3.0 Imports: 17 Imported by: 0

README

加载的监控配置是json格式,key不分大小写

api 对外提供接口: 查性能 任务操作:增加、删除、修改、查询(单个和全部) 当前实例的信息:实例总数、本实例编号、获得的配置内容

controller: 控制并发(要知道当前活着的 Goroutine 有哪些,应该有哪些,哪些异常退出了,缺了的能创建,多出来的就关掉)

考虑每个任务放在一个go里面,这样一来就需要检测任务是不是挂了,挂了就要重新启动

任务必须写明是否有周期性 如果有周期性,为了保证周期任务的准确性,需要产生新协程来执行,这样就要求,新协程内的代码必须有超时结束机制 即,周期性的执行体必须自带超时结束机制

数据的返回由执行体自身实施,还是controller统一收集呢? 暂定统一收集统一处理

Documentation

Index

Constants

View Source
const (
	JOB_STATUS_AVAILABLE = "available"
	JOB_STATUS_RUNNING   = "running"
	JOB_STATUS_STOPPED   = "stopped"
	JOB_STATUS_BLOCKING  = "blocking"

	JOB_SIGNAL_CACHE_SIZE = 1
	JOB_SIGNAL_STOP       = "exit"

	JOB_EXCUTE_POOL_SIZE = 3
)
View Source
const (
	PUSH_INTERVAL = 1 * time.Millisecond //单位毫秒
)

Variables

View Source
var (
	Home string
)

Functions

func InitConfig

func InitConfig() error

func InitLogger

func InitLogger() error

func NewApiServer

func NewApiServer(controller *Controller) *apiServer

func NewPlugin

func NewPlugin(pluginType string, config *viper.Viper) (plugin plugin, err error)

func ParseConfig

func ParseConfig(configFilePath string) error

func RearrangeJson

func RearrangeJson(i interface{}) (rearrangedJsonString string, err error)

func RenderJson

func RenderJson(w http.ResponseWriter, v interface{})

func SendToArgus

func SendToArgus(dataChan chan interface{})

Types

type ApiConfig

type ApiConfig struct {
	ListenAddress string `json:"listenAddress"` //Api本地监听地址
}

type Controller

type Controller struct {
	Total uint //当前注册的 controller 总数量
	Seq   uint //本 controller 的编号
	// contains filtered or unexported fields
}

func NewController

func NewController() *Controller

func (*Controller) AddJob

func (ct *Controller) AddJob(id string, originConfigString string) (map[string]interface{}, error)

func (*Controller) DelJob

func (ct *Controller) DelJob(id string) (map[string]interface{}, error)

func (*Controller) GetAllJob

func (ct *Controller) GetAllJob() (result map[string]interface{})

func (*Controller) GetAllStatus

func (ct *Controller) GetAllStatus() (result map[string]interface{})

func (*Controller) GetConfig

func (ct *Controller) GetConfig() map[string]interface{}

func (*Controller) GetInstanceSeq

func (ct *Controller) GetInstanceSeq() uint

func (*Controller) GetInstanceTotal

func (ct *Controller) GetInstanceTotal() uint

func (*Controller) GetJob

func (ct *Controller) GetJob(ids []string) (result map[string]interface{})

func (*Controller) GetStatus

func (ct *Controller) GetStatus(ids []string) (result map[string]interface{})

func (*Controller) ReloadAllJobs

func (ct *Controller) ReloadAllJobs() map[string]interface{}

func (*Controller) Start

func (ct *Controller) Start()

func (*Controller) UpdateJob

func (ct *Controller) UpdateJob(id string, originConfigString string) (map[string]interface{}, error)

type ControllerConfig

type ControllerConfig struct {
	ResultQueueLength int  `json:"resultQueueLength"` //结果存放队列
	WatcherEnabled    bool `json:"watcherEnabled"`    //是否使自动监听生效
	WatcherInterval   int  `json:"watcherInterval"`   //自动监听的检查的时间间隔

}

type GlobalConfig

type GlobalConfig struct {
	Push       *PushConfig       `json:"push"`
	Controller *ControllerConfig `json:"controller"`
	Api        *ApiConfig        `json:"api"`
	Job        *JobConfig        `json:"job"`
}

func Config

func Config() *GlobalConfig

type Job

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

func NewJob

func NewJob(id string, v *viper.Viper, resultQueue chan<- interface{}) (*Job, error)

type JobConfig

type JobConfig struct {
	Source string                `json:"source"` //job监控配置的来源,目前可选file或etcd
	File   *JobSourceFileConfig  `json:"file"`   //来源为file的配置
	Argus  *JobSourceArgusConfig `json:"argus"`  //来源为etcd的配置
}

type JobSourceArgusConfig

type JobSourceArgusConfig struct {
}

type JobSourceFileConfig

type JobSourceFileConfig struct {
	Path string `json:"path"` //文件路径
}

type PushConfig

type PushConfig struct {
	Limit    int    `json:"limit"`    //推送一次的最大数量
	TimeWait int64  `json:"timewait"` //推送一次的时间间隔
	Retry    int    `json:"retry"`    //推送的重试次数
	APIUrl   string `json:"apiUrl"`   //推送的接口
}

Directories

Path Synopsis
plugin

Jump to

Keyboard shortcuts

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