Documentation ¶
Index ¶
- Constants
- Variables
- func BinaryToInt(data []byte) (n int)
- func BuildJobExecuteInfo(jobPlan *datamodels.JobSchedulePlan) (jobExecuteInfo *datamodels.JobExecuteInfo)
- func BuildJobSchedulePlan(job *datamodels.JobEtcd) (jobSchedulePlan *datamodels.JobSchedulePlan, err error)
- func GenerateName() (string, error)
- func GetFirstLocalIpAddress() (ipv4 string, err error)
- func PacketData(message []byte) []byte
- func PacketInterfaceData(object interface{}) (data []byte)
- func ParseConfig() (err error)
- func UnPacketData(data []byte, c chan<- []byte) []byte
- func UnpackByteToJob(value []byte) (job *datamodels.JobEtcd, err error)
- type Config
- type EtcdConfig
- type EtcdTLSConfig
- type HttpConfig
- type JobLock
- type MasterConfig
- type MongoConfig
- type MySQLDatabase
- type RedisDatabase
- type WorkerConfig
Constants ¶
View Source
const ETCD_JOBS_CATEGORY_DIR = "/crontab/categories/" // 计划任务的分类
View Source
const ETCD_JOBS_DIR = "/crontab/jobs/"
View Source
const ETCD_JOBS_LOCK_DIR = "/crontab/lock/"
View Source
const ETCD_JOB_KILL_DIR = "/crontab/kill/"
View Source
const ETCD_WORKER_DIR = "/crontab/workers/"
ETCD相关变量
View Source
const JOB_EVENT_DELETE = 1 // Job Delete事件
View Source
const JOB_EVENT_KILL = 2 // Job Kill事件
View Source
const JOB_EVENT_PUT = 0 // Job PUT事件
View Source
const SocketMessageHeader = "www.codelieche.com" // Socket发送数据包的头部
Variables ¶
View Source
var (
LOCK_IS_USING = errors.New("lock is using")
)
View Source
var NOT_FOUND = fmt.Errorf("404 not found")
错误类
View Source
var NotFountError = fmt.Errorf("404 not fount")
View Source
var SocketDataLength int = 4 // 32位
View Source
var SocketHeaderLength = len([]byte(SocketMessageHeader)) // Socket发送消息
Functions ¶
func BuildJobExecuteInfo ¶
func BuildJobExecuteInfo(jobPlan *datamodels.JobSchedulePlan) (jobExecuteInfo *datamodels.JobExecuteInfo)
构造执行状态信息
func BuildJobSchedulePlan ¶
func BuildJobSchedulePlan(job *datamodels.JobEtcd) (jobSchedulePlan *datamodels.JobSchedulePlan, err error)
构建job执行计划
func PacketData ¶
对要发送的数据打包 打包数据:Header + len(message) + message
func PacketInterfaceData ¶
func PacketInterfaceData(object interface{}) (data []byte)
func ParseConfig ¶
func ParseConfig() (err error)
func UnpackByteToJob ¶
func UnpackByteToJob(value []byte) (job *datamodels.JobEtcd, err error)
反序列化Job
Types ¶
type Config ¶
type Config struct { Master *MasterConfig `json:"master" yaml:"master"` Worker *WorkerConfig `json:"worker" yaml:"worker"` MySQL *MySQLDatabase `json:"mysql" yaml:"mysql"` Redis *RedisDatabase `json:"redis" yaml:"redis"` Etcd *EtcdConfig `json:"etcd" yaml:"etcd"` Mongo *MongoConfig `json:"mongo" yaml:"mongo"` Debug bool `json:"debug" yaml:"debug"` }
Master Worker相关的配置
type EtcdConfig ¶
type EtcdConfig struct { Endpoints []string `json:"endpoints", yaml:"endpoints"` Timeout int `json:"timeout"` // etcd操作的超时时间 秒 TLS *EtcdTLSConfig `json:"tls", yaml:"tls"` }
master etcd的相关配置
type EtcdTLSConfig ¶
type HttpConfig ¶
type HttpConfig struct { Host string `json:"host", yaml:"host"` Port int `json:"port", yaml: "port"` Timeout int `json:"timeout", yaml: "timeout"` // 超时时间 毫秒 }
http Web相关的配置
type JobLock ¶
type JobLock struct { IsLocked bool // 释放上锁成功,也可根据leaseId是否不为0判断 NeedKillChan chan bool // 是否需要杀掉jobLock对应的job程序: 正常退出的请传递个false // contains filtered or unexported fields }
分布式锁
func NewJobLock ¶
初始化一把锁
type MasterConfig ¶
type MasterConfig struct {
Http *HttpConfig `json:"http" yaml:"http"`
}
master相关的配置
type MongoConfig ¶
type MongoConfig struct { Hosts []string `json:"hosts" yaml:"hosts"` // 主机列表 User string `json:"user" yaml:"user"` // 用户名 Password string `json:"password" yaml:"password"` // MongoDB的用户密码 Database string `json:"database" yaml:"database"` // 数据库的名字 }
master mongodb config
type MySQLDatabase ¶
type MySQLDatabase struct { Host string `json:"host" yaml:"host"` // 数据库地址 Port int `json:"port" yaml:"port"` // 端口号 User string `json:"user" yaml:"user"` // 用户 Password string `json:"password" yaml:"password"` // 用户密码 Database string `json:"database" yaml:"database"` // 数据库 }
MySQL数据库相关配置
type RedisDatabase ¶
type RedisDatabase struct { Host string `json:"host" yaml:"host"` // redis主机,不填会是默认的127.0.0.1:6739 Clusters []string `json:"clusters" yaml:"clusters"` // Redis集群地址 Password string `json:"password" yaml:"password"` // redis的密码 DB int `json:"db" yaml:db` // 哪个库 }
Redis配置
type WorkerConfig ¶
type WorkerConfig struct { Http *HttpConfig `json:"http" yaml:"http"` MasterUrl string `json:"master_url" yaml:"master_url"` Categories map[string]bool `json:"categories" yaml: "categories"` }
worker相关的配置
func (*WorkerConfig) GetSocketUrl ¶
func (workerConfig *WorkerConfig) GetSocketUrl() (socketUrl string, err error)
获取socket的连接地址
Source Files ¶
Click to show internal directories.
Click to hide internal directories.