Documentation ¶
Index ¶
- Constants
- func EncodeConfData(cd ConfData) (string, error)
- func FormatEvent(modelEvent *Event) (*pb.ConfigEvent, error)
- func GetRawKey(key, typ string) string
- func GetStructName(fname string) string
- func ToCamlCase(key string) string
- func ToUpperFirst(s string) string
- type ConfData
- type Event
- type MachineCpu
- type MachineInfo
- type Node
- func (n *Node) AddEvent(evt Event) error
- func (n *Node) Exit()
- func (n *Node) GetProc() *ProcInfo
- func (n *Node) GetStructDatas() []StructData
- func (n *Node) GetSubscription() []string
- func (n *Node) Info() NodeInfo
- func (n *Node) SetProc(proc *ProcInfo)
- func (n *Node) SetStructDatas(structDatas []StructData, version int)
- func (n *Node) SetSubscription(subscription []string)
- type NodeInfo
- func (n *NodeInfo) GetComponent() string
- func (n *NodeInfo) GetDomain() string
- func (n *NodeInfo) GetID() string
- func (n *NodeInfo) GetKeeperAddr() string
- func (n *NodeInfo) GetRawSubscription() []string
- func (n *NodeInfo) GetUpdateTime() int64
- func (n *NodeInfo) GetVersion() int
- func (n *NodeInfo) SetComponentTag(tag map[string]string)
- func (n *NodeInfo) SetRawSubscription(rawSubscription []string)
- func (n *NodeInfo) SetStartTime(t int64)
- func (n *NodeInfo) SetStatus(status NodeStatus)
- func (n *NodeInfo) SetUpdateTime(t int64)
- func (n *NodeInfo) SetVersion(version int)
- type NodeStatus
- type ObjContainer
- type Opcode
- type Operate
- type ProcBase
- type ProcCpu
- type ProcInfo
- type ProcMem
- type StructData
Constants ¶
View Source
const ( EventError = iota - 2 EventNone EventSync EventNodeConfChanged EventNodeRegister EventNodeStatus EventNodeProc EventNodeExit EventCmdStart EventCmdStop EventCmdRestart EventOperate EventOperateBatch EventOperateRollback )
EventType
View Source
const ( PkgPrefix string = "github.com/huajiao-tv/gokeeper/model." StatusStop NodeStatus = 0 StatusRunning NodeStatus = 1 )
Variables ¶
This section is empty.
Functions ¶
func EncodeConfData ¶
func FormatEvent ¶
func FormatEvent(modelEvent *Event) (*pb.ConfigEvent, error)
将model格式的event转化为pb格式的event
func GetStructName ¶
Types ¶
type ConfData ¶
type ConfData struct { Type string `json:"type"` RawKey string `json:"raw_key"` RawValue string `json:"raw_value"` Key string `json:"key"` Value interface{} `json:"value"` StructKey string `json:"struct_key"` IsJson bool `json:"is_json"` }
func DecodeConfData ¶
func NewConfData ¶
type Event ¶
type Event struct { EventType int Data interface{} }
Event .
func ParseEvent ¶
func ParseEvent(pbEvent *pb.ConfigEvent) (*Event, error)
将pb格式的event转化为model格式的event
type MachineCpu ¶
type MachineCpu struct { User uint64 Nice uint64 System uint64 Idle uint64 Iowait uint64 Irq uint64 SoftIrq uint64 Stealstolen uint64 Guest uint64 Uptime uint64 }
func (*MachineCpu) ReSet ¶
func (this *MachineCpu) ReSet()
func (*MachineCpu) Refresh ¶
func (this *MachineCpu) Refresh() error
type MachineInfo ¶
type MachineInfo struct { Uptime float64 Hertz int Host string Cpu *MachineCpu }
func NewMachineInfo ¶
func NewMachineInfo() *MachineInfo
*
- 获取Hertz值:C.sysconf(C._SC_CLK_TCK),sysconf具体实现参见glibc源码:
- x86_64平台:glibc/sysdeps/posix/sysconf.c
- glibc/sysdeps/unix/sysv/linux/getclktck.c
func (*MachineInfo) GetUptime ¶
func (this *MachineInfo) GetUptime() float64
type Node ¶
type Node struct { *NodeInfo Subscription []string `json:"subscription"` StructDatas []StructData `json:"struct_datas"` Proc *ProcInfo `json:"proc"` Event chan Event `json:"-"` }
Node stores the information about a node
func (*Node) GetStructDatas ¶
func (n *Node) GetStructDatas() []StructData
func (*Node) GetSubscription ¶
func (*Node) SetStructDatas ¶
func (n *Node) SetStructDatas(structDatas []StructData, version int)
func (*Node) SetSubscription ¶
type NodeInfo ¶
type NodeInfo struct { ID string `json:"id"` KeeperAddr string `json:"keeper_addr"` Domain string `json:"domain"` Component string `json:"component"` Hostname string `json:"hostname"` StartTime int64 `json:"start_time"` UpdateTime int64 `json:"update_time"` RawSubscription []string `json:"raw_subscription"` Status NodeStatus `json:"status"` Version int `json:"version"` ComponentTags map[string]string `json:"component_tags"` // contains filtered or unexported fields }
func NewNodeInfo ¶
func (*NodeInfo) GetComponent ¶
func (*NodeInfo) GetKeeperAddr ¶
func (*NodeInfo) GetRawSubscription ¶
func (*NodeInfo) GetUpdateTime ¶
func (*NodeInfo) GetVersion ¶
func (*NodeInfo) SetComponentTag ¶
func (*NodeInfo) SetRawSubscription ¶
func (*NodeInfo) SetStartTime ¶
func (*NodeInfo) SetStatus ¶
func (n *NodeInfo) SetStatus(status NodeStatus)
func (*NodeInfo) SetUpdateTime ¶
func (*NodeInfo) SetVersion ¶
type NodeStatus ¶
type NodeStatus int
type ObjContainer ¶
type ObjContainer interface { Update(name string, st interface{}) error GetStructs() map[string]interface{} }
ObjContainer is function to update data
type Operate ¶
type ProcCpu ¶
type ProcCpu struct { Utime uint64 Stime uint64 Cutime uint64 Cstime uint64 StartTime uint64 LastUS uint64 //Utime+Stime LastTimer time.Time //time.Now() CpuUsage string ProcBase }
type ProcInfo ¶
func NewProcInfo ¶
func NewProcInfo() *ProcInfo
type ProcMem ¶
type StructData ¶
type StructData struct { Name string `json:"name"` Version int `json:"version"` Data map[string]ConfData `json:"data"` //only for gokeeper-cli Libraries []string }
func NewStructData ¶
func NewStructData(name string, version int, data map[string]ConfData) StructData
func (*StructData) SetVersion ¶
func (s *StructData) SetVersion(version int)
Click to show internal directories.
Click to hide internal directories.