events

package
v0.0.0-...-1142a2b Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package events *

  • @Title: 事件业务处理
  • @Description: *
  • 事件业务处理 * *

Index

Constants

View Source
const (
	// EventResourceType 事件上报的资源类型
	EventResourceType = "polardb-o"
	// EventSourceFrom 事件上报的资源类型
	EventSourceFrom = "Polardbstack-Daemon"
	// EventHeader1 事件上报请求头部信息 1
	EventHeader1 = "event_resource;log;20210220001;POLAR_STACK"
	// EventHeader2 事件上报请求头部信息 2
	EventHeader2 = "event"

	// EventLevelInfo 提示信息
	EventLevelInfo EventLevel = "INFO"
	// EventLevelWarn 不影响系统正常流程
	EventLevelWarn EventLevel = "WARN"
	// EventLevelError 系统错误,流程还能继续
	EventLevelError EventLevel = "ERROR"
	// EventLevelCritical 不可逆错误,等同系统宕机
	EventLevelCritical EventLevel = "CRITICAL"

	// EventFloatingIPAddSuccess 浮动IP添加成功
	EventFloatingIPAddSuccess EventCode = "FloatingIPAddSuccess"
	// EventFloatingIPAddFailed 浮动IP添加失败
	EventFloatingIPAddFailed EventCode = "FloatingIPAddFailed"
	// EventFloatingIPDeleteSuccess 浮动IP删除成功
	EventFloatingIPDeleteSuccess EventCode = "FloatingIPDeleteSuccess"
	// EventFloatingIPDeleteFailed 浮动IP删除失败
	EventFloatingIPDeleteFailed EventCode = "FloatingIPDeleteFailed"

	// EventNeedToAddFloatingIP 应该存在该ip, 但却不存在 需要添加
	EventNeedToAddFloatingIP EventCode = "EventNeedToAddFloatingIP"
	// EventRemoveUnUseFloatingIPSuccess 删除不应该存在的IP成功
	EventRemoveUnUseFloatingIPSuccess EventCode = "EventRemoveUnUseFloatingIPSuccess"
	// EventRemoveUnUseFloatingIPFailed 删除不应该存在的IP失败
	EventRemoveUnUseFloatingIPFailed EventCode = "EventRemoveUnUseFloatingIPFailed"
)

Variables

This section is empty.

Functions

func Init

func Init()

Init *

  • @Title: 初使化事件上报对象
  • @Description: *
  • 初使化事件上报的请求对象及参数:
  • - 上报地址
  • - 上报超时时间
  • - 是否开启事件上报 *

Types

type Body

type Body struct {
	// 描述,告警时会使用
	Describe string `json:"describe"`
}

type EventBody

type EventBody struct {
	// 事件发生时业务域内唯一ID
	EventId string `json:"eventId"`
	// 事件规则编码
	EventCode EventCode `json:"eventCode"`
	// 来源
	Source Source `json:"source"`
	// 事件的级别
	//  - CRITICAL : "不可逆错误,等同系统宕机"
	//  - ERROR    : "系统错误,流程还能继续"
	//  - WARN     : "不影响系统正常流程"
	//  - INFO     : "提示信息"
	Level EventLevel `json:"level"`
	// 事件发生时间 毫秒级时间戳
	Time int64 `json:"time"`
	// 事件内容,json格式
	Body Body `json:"body"`
}

EventBody *

  • @Title: 上报日志的请求消息体 *

type EventCode

type EventCode string

EventCode 事件代码

func (EventCode) ToString

func (ec EventCode) ToString() string

ToString *

  • @Title: EventCode.ToString
  • @Description: *
  • 将事件代码由枚举类型转字符型 * *

type EventLevel

type EventLevel string

EventLevel 事件级别

func (EventLevel) ToString

func (el EventLevel) ToString() string

ToString *

  • @Title: EventLevel.ToString
  • @Description: *
  • 将 EventLevel 由枚举类型转字符型,默认为 "INFO" * *

type EventResponse

type EventResponse struct {
	Success  bool        `json:"success"`
	Msg      string      `json:"msg"`
	DataList interface{} `json:"dataList"`
}

EventResponse *

  • @Title: 事件上报的响应结果 *

func UploadEvent

func UploadEvent(eventCode EventCode, insName string, ip string, describe string) (er EventResponse, err error)

UploadEvent *

  • @Title: 事件上报 *

type Source

type Source struct {
	// 资源类型
	ResourceType string `json:"resourceType"`
	// 实例Name
	InsName string `json:"insName"`
	// 发现问题的组件类型,英文编码(各组件自己命名)
	From string `json:"from"`
	// 发生的IP地址,如果拿不到发生的IP地址,可以置空。
	Ip string `json:"ip"`
}

Jump to

Keyboard shortcuts

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