service

package
v0.0.0-...-83adff0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2020 License: GPL-3.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CPUPerformace   = 1 // CPU性能图
	CPUFrame        = 2 // CPU火焰图
	HeapPerformance = 3 // 内存性能图
	HeapFrame       = 4 // 内存火焰图
)

kind .

Variables

This section is empty.

Functions

func CreateTopic

func CreateTopic(addrs []string, topic string, partitions int32, factor int16) (err error)

CreateTopic to kafka

func Diff

func Diff(cluster, topic, group string) (records []*databus.Record, err error)

Diff offset

func FetchMessage

func FetchMessage(c context.Context, cluster, topic, group, key string, start, end int64, limit int) (res []*databus.Message, err error)

FetchMessage fetch topic message by timestamp or offset.

func NewtonScore

func NewtonScore(maxMtime xtime.Time) (score float64)

NewtonScore . Newton's Law of Cooling 冷却因子经我们需求计算 a = 0.02 deltaDays<7 day -a*x^2+b >7 NewTonScore

func WilsonScore

func WilsonScore(pos int, total int) (score float64)

WilsonScore Wilson-score-interval

Types

type ChatResult

type ChatResult struct {
	Code int `json:"code"`
	Data struct {
		WebOnline int64 `json:"web_online"`
	} `json:"data"`
}

ChatResult .

type Client

type Client struct {
	sarama.Client
	// contains filtered or unexported fields
}

Client kafka client

func NewClient

func NewClient(addrs []string, topic, group string) (c *Client, err error)

NewClient returns a new kafka client instance

func (*Client) Close

func (c *Client) Close()

Close close kafka client

func (*Client) NewOffset

func (c *Client) NewOffset(partition int32, offset int64) (err error)

NewOffset commit new offset to kafka

func (*Client) NewTime

func (c *Client) NewTime(time int64) (err error)

NewTime commit new time offset to kafka

func (*Client) OffsetMarked

func (c *Client) OffsetMarked() (marked map[int32]int64, err error)

OffsetMarked fetch marked offset

func (*Client) OffsetNew

func (c *Client) OffsetNew() (info map[int32]int64, err error)

OffsetNew return newest offset for given topic

func (*Client) OffsetNewTime

func (c *Client) OffsetNewTime(time int64) (info map[int32]int64, err error)

OffsetNewTime return newest offset for given topic

func (*Client) OffsetOld

func (c *Client) OffsetOld() (info map[int32]int64, err error)

OffsetOld return newest oldset for given topic

func (*Client) Partitions

func (c *Client) Partitions() []int32

Partitions returns the list of parititons for the given topic, as registered with SetMetadata

func (*Client) ResetOffset

func (c *Client) ResetOffset(partition int32, offset int64) (err error)

ResetOffset commit offset of partition to kafka

func (*Client) SeekBegin

func (c *Client) SeekBegin() (err error)

SeekBegin commit newest offset to kafka

func (*Client) SeekEnd

func (c *Client) SeekEnd() (err error)

SeekEnd commit newest offset to kafka

func (*Client) SetOffset

func (c *Client) SetOffset(partition int32, offset int64) (err error)

SetOffset commit offset of partition to kafka

func (*Client) Topics

func (c *Client) Topics() []string

Topics return the list of topics for the given kafka cluster

type Common

type Common struct {
	Metric struct {
		InstanceName string `json:"instance_name"`
	} `json:"metric"`
	Value []interface{} `json:"value"`
}

Common .

type CommonRes

type CommonRes struct {
	RetCode int       `json:"RetCode"`
	Data    []*Common `json:"data"`
}

CommonRes packet or bound result data

type Max

type Max struct {
	K string
	V int64
}

Max max value

type Prometheus

type Prometheus struct {
	Metric struct {
		Method string `json:"method"`
	} `json:"metric"`
	Values [][]interface{} `json:"values"`
}

Prometheus .

type PrometheusRes

type PrometheusRes struct {
	RetCode int           `json:"RetCode"`
	Data    []*Prometheus `json:"data"`
}

PrometheusRes http result

type Ret

type Ret struct {
	ReqID    string   `json:"ReqId"`
	Action   string   `json:"Action"`
	RetCode  int      `json:"RetCode"`
	Data     []string `json:"Data"`
	Response struct {
		Status int `json:"status"`
	} `json:"Response"`
}

Ret .

type SQLLog

type SQLLog struct {
	SQLType string
	Content interface{}
}

SQLLog log

type Service

type Service struct {
	DB        *gorm.DB
	DBDatabus *gorm.DB
	DBCanal   *gorm.DB
	// contains filtered or unexported fields
}

Service is a service.

func New

func New(c *conf.Config) (s *Service)

New new a service

func (*Service) ActiveWarning

func (s *Service) ActiveWarning(c context.Context, text string) (err error)

ActiveWarning active

func (*Service) AddMonitor

func (s *Service) AddMonitor(c context.Context) (err error)

AddMonitor get monitor data and insert

func (*Service) AddPprofWarn

func (s *Service) AddPprofWarn(c context.Context, pws []*pprof.Warn) (err error)

AddPprofWarn .

func (*Service) AddUT

func (s *Service) AddUT(c context.Context, pkg *ut.PkgAnls, files []*ut.File, request *ut.UploadRes, dataURL, reportURL, HTMLURL string) (err error)

AddUT store ut data with a transaction

func (*Service) AddUTApp

func (s *Service) AddUTApp(c context.Context, apps []*ut.App) (err error)

AddUTApp add path to ut_app

func (*Service) AddUTCommit

func (s *Service) AddUTCommit(c context.Context, tx *gorm.DB, request *ut.UploadRes) (err error)

AddUTCommit insert commit if not exist

func (*Service) AddUTFiles

func (s *Service) AddUTFiles(c context.Context, tx *gorm.DB, files []*ut.File) (err error)

AddUTFiles add files in table ut_file

func (*Service) AddUTMerge

func (s *Service) AddUTMerge(c context.Context, tx *gorm.DB, request *ut.UploadRes) (err error)

AddUTMerge insert merge if not exist

func (*Service) AddUTPKG

func (s *Service) AddUTPKG(c context.Context, tx *gorm.DB, pkg *ut.PkgAnls, request *ut.UploadRes, reportURL, HTMLURL, dataURL string) (err error)

AddUTPKG if not exists pkg.commit_id then insert,otherwise,update

func (*Service) AppAdd

func (s *Service) AppAdd(c *bm.Context, username string, AppTreeID int64, AppID string, Limit int64) (err error)

AppAdd Appadd

func (*Service) AppNameList

func (s *Service) AppNameList(c context.Context) (apps []string)

AppNameList return app list

func (*Service) Appids

func (s *Service) Appids(c context.Context, username, cookie string) (appids []string, err error)

Appids get appid by username.

func (*Service) ApplyAdd

func (s *Service) ApplyAdd(c *bm.Context, v *cml.Canal, username string) (err error)

ApplyAdd canal apply

func (*Service) ApplyDelete

func (s *Service) ApplyDelete(c *bm.Context, v *cml.ScanReq, username string) (err error)

ApplyDelete canal delete

func (*Service) ApplyEdit

func (s *Service) ApplyEdit(c *bm.Context, v *cml.EditReq, username string) (err error)

ApplyEdit canal edit

func (*Service) AppsCache

func (s *Service) AppsCache(c context.Context) (err error)

AppsCache flush cache for apps.

func (*Service) BroadCast

func (s *Service) BroadCast(c context.Context, appName []string, app string) (mts []*monitor.Monitor, err error)

BroadCast return monitor data

func (*Service) BroadCastList

func (s *Service) BroadCastList(c context.Context) (ret *monitor.MoniRet, err error)

BroadCastList return BroadCastList data

func (*Service) CalcCount

func (s *Service) CalcCount(c context.Context, body []byte) (pkg *ut.PkgAnls, err error)

CalcCount calc count

func (*Service) CalcCountFiles

func (s *Service) CalcCountFiles(c context.Context, res *ut.UploadRes, body []byte) (utFiles []*ut.File, err error)

CalcCountFiles calculating lines and statements in files

func (*Service) ChatProxy

func (s *Service) ChatProxy(c context.Context) (ret *ChatResult, err error)

ChatProxy chat proxy

func (*Service) CheckMaster

func (s *Service) CheckMaster(c context.Context, v *cml.ConfigReq) (err error)

CheckMaster canal check

func (*Service) CheckUT

func (s *Service) CheckUT(c context.Context, cid string) (t *ut.Tyrant, err error)

CheckUT .coverage>=30% && pass_rate=100% && increase >=0

func (*Service) Close

func (s *Service) Close()

Close close resource.

func (*Service) CommentOnMR

func (s *Service) CommentOnMR(c context.Context, projID, mrID int, msg string) (err error)

CommentOnMR create or modify comment on relavent merge request

func (*Service) CommitHistory

func (s *Service) CommitHistory(c context.Context, username string, times int64) (pkgs []*ut.PkgAnls, err error)

CommitHistory .

func (*Service) ConfigProxy

func (s *Service) ConfigProxy(c context.Context, method string, uri string, params url.Values, cookie string, args ...interface{}) (data json.RawMessage, err error)

ConfigProxy config proxy

func (*Service) DapperProxy

func (s *Service) DapperProxy(rw http.ResponseWriter, r *http.Request)

DapperProxy dapper proxy.

func (*Service) DashCurveGraph

func (s *Service) DashCurveGraph(c context.Context, username string, req *ut.PCurveReq) (res []*ut.PCurveResp, err error)

DashCurveGraph is a curve graph for leader to show the team members' code coverage

func (*Service) DashGraphDetail

func (s *Service) DashGraphDetail(c context.Context, username string, req *ut.PCurveReq) (res []*ut.PCurveDetailResp, err error)

DashGraphDetail project graph detail for members.

func (*Service) DashGraphDetailSingle

func (s *Service) DashGraphDetailSingle(c context.Context, username string, req *ut.PCurveReq) (res []*ut.PCurveDetailResp, err error)

DashGraphDetailSingle project graph detail for Single member.

func (*Service) DashPkgsTree

func (s *Service) DashPkgsTree(c context.Context, path string, username string) (pkgs []*ut.PkgAnls, err error)

DashPkgsTree get all the lastest committed pkgs by username

func (*Service) DataBus

func (s *Service) DataBus(c context.Context) (mts []*monitor.Monitor, err error)

DataBus return DataBus monitor data

func (*Service) DataBusList

func (s *Service) DataBusList(c context.Context) (ret *monitor.MoniRet, err error)

DataBusList return DataBusList data

func (*Service) DatabusConsumerAddrs

func (s *Service) DatabusConsumerAddrs(c context.Context, group string) (addrs []string, err error)

DatabusConsumerAddrs databus consumer addrs.

func (*Service) DiscoveryID

func (s *Service) DiscoveryID(c context.Context, username, cookie string) (appids []string, err error)

DiscoveryID get appid by username.

func (*Service) DiscoveryProxy

func (s *Service) DiscoveryProxy(c context.Context, method, loc string, params url.Values) (data interface{}, err error)

DiscoveryProxy discovery proxy.

func (*Service) DiscoveryTreeSync

func (s *Service) DiscoveryTreeSync(c context.Context, username, cookie string)

DiscoveryTreeSync sync tree cache by username discoverykey.

func (*Service) GetAllErrors

func (s *Service) GetAllErrors(c context.Context) (errs map[string]string, err error)

GetAllErrors 调用x/internal/canal/errors 查询错误信息

func (*Service) GetCodes

func (s *Service) GetCodes(c context.Context, Interval1, Interval2 string) (data []*codes.Codes, err error)

GetCodes ...

func (*Service) GetDefaultPermission

func (s *Service) GetDefaultPermission(c context.Context) (modules []string, rules []string)

GetDefaultPermission get the modules and rules which have default permission

func (*Service) GetInterfaces

func (s *Service) GetInterfaces(c context.Context) (string, error)

GetInterfaces .

func (*Service) GetScanInfo

func (s *Service) GetScanInfo(c context.Context, v *cml.ScanReq, username string, cookie string) (confData *cml.Results, err error)

GetScanInfo is

func (*Service) GetUser

func (s *Service) GetUser(c context.Context, username string) (usr *user.User, err error)

GetUser get user info by username if it exists, otherwise create the user info

func (*Service) GitReport

func (s *Service) GitReport(c context.Context, projID int, mrID int, commitID string) (err error)

GitReport post simple report using SAGA account

func (*Service) HTTPMonitor

func (s *Service) HTTPMonitor(c context.Context) ([]*monitor.Monitor, error)

HTTPMonitor get http monitor data

func (*Service) KingSoft

func (s *Service) KingSoft(c context.Context) (mts []*monitor.Monitor, err error)

KingSoft return KingSoft monitor data

func (*Service) LogAdd

func (s *Service) LogAdd(c context.Context, lg *mlog.Log) (err error)

LogAdd add log

func (*Service) Members

func (s *Service) Members(c context.Context) (mt *monitor.Monitor, err error)

Members get current online members

func (*Service) NeedInfoAdd

func (s *Service) NeedInfoAdd(c context.Context, req *need.NAddReq, username string) (err error)

NeedInfoAdd is

func (*Service) NeedInfoEdit

func (s *Service) NeedInfoEdit(c context.Context, arg *need.NEditReq, username string) (err error)

NeedInfoEdit is

func (*Service) NeedInfoList

func (s *Service) NeedInfoList(c context.Context, arg *need.NListReq, username string) (res []*need.NInfo, count int64, err error)

NeedInfoList is

func (*Service) NeedInfoVerify

func (s *Service) NeedInfoVerify(c context.Context, arg *need.NVerifyReq) (ni *need.NInfo, err error)

NeedInfoVerify is

func (*Service) NeedInfoVote

func (s *Service) NeedInfoVote(c context.Context, arg *need.Likereq, username string) (err error)

NeedInfoVote is

func (*Service) NeedVoteList

func (s *Service) NeedVoteList(c context.Context, arg *need.Likereq) (res []*need.UserLikes, count int64, err error)

NeedVoteList is show votelist

func (*Service) OnlineList

func (s *Service) OnlineList(c context.Context) (ret *monitor.MoniRet, err error)

OnlineList return online data

func (*Service) OpenProxy

func (s *Service) OpenProxy(c context.Context, method, loc string, params url.Values) (data interface{}, err error)

OpenProxy proxy.

func (*Service) Opsmind

func (s *Service) Opsmind(c context.Context, project, group, action, Owners string, percentage, fortime int64, silence bool) (result *databus.Res, err error)

Opsmind ...

func (*Service) OpsmindQuery

func (s *Service) OpsmindQuery(c context.Context, group, action string) (result *databus.ResQuery, err error)

OpsmindQuery ...

func (*Service) OpsmindRemove

func (s *Service) OpsmindRemove(c context.Context, adjustid, action string) (result *databus.Res, err error)

OpsmindRemove ...

func (*Service) ParseContent

func (s *Service) ParseContent(c context.Context, body []byte) (content []byte, err error)

ParseContent parse go test output to go convey result json. If result not contains "=== RUN", that means execute ut err.

func (*Service) Permit

func (s *Service) Permit(c context.Context, username string, rule string) (err error)

Permit check user permission.

func (*Service) Ping

func (s *Service) Ping(c context.Context) (err error)

Ping ping db,

func (*Service) PlatformProxy

func (s *Service) PlatformProxy(c context.Context, method, loc string, params url.Values) (data interface{}, err error)

PlatformProxy proxy.

func (*Service) Pprof

func (s *Service) Pprof(url, uri, svgName, hostName string, time int64, sType int8) (err error)

Pprof ...

func (*Service) PprofWarn

func (s *Service) PprofWarn(c context.Context, req *pprof.Params) (pws []*pprof.Warn, err error)

PprofWarn .

func (*Service) ProcessApplyList

func (s *Service) ProcessApplyList(c context.Context, v *cml.ListReq) (listdata *cml.Paper, err error)

ProcessApplyList get apply list

func (*Service) ProcessCanalInfo

func (s *Service) ProcessCanalInfo(c context.Context, v *cml.ConfigReq, username string) (err error)

ProcessCanalInfo is

func (*Service) ProcessCanalList

func (s *Service) ProcessCanalList(c context.Context, v *cml.ListReq) (listdata *cml.Paper, err error)

ProcessCanalList get canal list

func (*Service) ProcessConfigInfo

func (s *Service) ProcessConfigInfo(c context.Context, v *cml.ConfigReq, cookie string, username string) (err error)

ProcessConfigInfo process info to config center

func (*Service) Projects

func (s *Service) Projects(c context.Context, username, cookie string) (projects []string, err error)

Projects get projects by username.

func (*Service) PrometheusList

func (s *Service) PrometheusList(c context.Context, app, method, mType string) (ret *monitor.MoniRet, err error)

PrometheusList return PrometheusList data

func (*Service) PrometheusProxy

func (s *Service) PrometheusProxy(c context.Context, params url.Values, res interface{}) (err error)

PrometheusProxy Get Prometheus Data

func (*Service) QATrend

func (s *Service) QATrend(c context.Context, arg *ut.QATrendReq) (trend *ut.QATrendResp, err error)

QATrend give single user's coverage ,passrate and score data

func (*Service) RPCMonitor

func (s *Service) RPCMonitor(c context.Context) ([]*monitor.Monitor, error)

RPCMonitor get rpc monitor data

func (*Service) RankTen

func (s *Service) RankTen(c context.Context, order string) (ranks []*ut.RankResp, err error)

RankTen find data and avg(coverage)

func (*Service) RankWechatReport

func (s *Service) RankWechatReport(c context.Context) (err error)

RankWechatReport send rank to wechat group 19:00 everyday

func (*Service) RanksCache

func (s *Service) RanksCache(c context.Context) (err error)

RanksCache flush cache for ranks.

func (*Service) ScanByAddrFromConfig

func (s *Service) ScanByAddrFromConfig(c context.Context, addr string, cookie string) (res *cml.Conf, err error)

ScanByAddrFromConfig 根据addr查询配置信息

func (*Service) SendLog

func (s *Service) SendLog(c context.Context, username string, uid int64, tp int, oid int64, action string, context interface{}) (err error)

SendLog log

func (*Service) SendWeChat

func (s *Service) SendWeChat(c context.Context, title, msg, treeID, users string) (err error)

SendWeChat send message to WeChat users: zhangsan,lisi,wangwu

func (*Service) SendWeMessage

func (s *Service) SendWeMessage(c context.Context, title, task, result, sender string, receiver []string) (err error)

SendWeMessage send wechat message

func (*Service) SendWechatMessage

func (s *Service) SendWechatMessage(c context.Context, addr, aType, result, sender, note string, receiver []string) (err error)

SendWechatMessage send wechat message

func (*Service) SetMerged

func (s *Service) SetMerged(c context.Context, mrid int64) (err error)

SetMerged set is_merged = 1 in ut_merge

func (*Service) SummaryWechatReport

func (s *Service) SummaryWechatReport(c context.Context) (err error)

SummaryWechatReport send depts' summary to ut wechat group every Friday(19:00)

func (*Service) TableInfo

func (s *Service) TableInfo(table string) (infos []*cml.Table, err error)

TableInfo get array table info

func (*Service) TenCent

func (s *Service) TenCent(c context.Context) (mts []*monitor.Monitor, err error)

TenCent return TenCent monitor data

func (*Service) Torch

func (s *Service) Torch(c context.Context, url, uri, svgName, hostName string, time int64, sType int8) (err error)

Torch ...

func (*Service) TreeSync

func (s *Service) TreeSync(c context.Context, username, cookie string)

TreeSync sync tree cache by username.

func (*Service) Trees

func (s *Service) Trees(c context.Context, username, cookie string) (nodem []*tree.Node, err error)

Trees tree list

func (*Service) UTApps

func (s *Service) UTApps(c context.Context, v *ut.AppReq) (result []*ut.App, count int, err error)

UTApps .

func (*Service) UTGernalCommit

func (s *Service) UTGernalCommit(c context.Context, commits string) (cmInfos []*ut.CommitInfo, err error)

UTGernalCommit get singe or all users' general commit infos

func (*Service) UpdateProcessTag

func (s *Service) UpdateProcessTag(c context.Context, configID int, cookie string) (err error)

UpdateProcessTag canal审核通过之后,调用/x/admin/config/canal/tag/update,同步到配置中心发版

func (*Service) UpdateUTApp

func (s *Service) UpdateUTApp(c context.Context, pkg *ut.PkgAnls) (err error)

UpdateUTApp update has_ut=1

func (*Service) Upload

func (s *Service) Upload(c context.Context, fileType string, expire int64, body []byte) (url string, err error)

Upload upload file to bfs with no filename

func (*Service) UserRank

func (s *Service) UserRank(c context.Context, username string) (rank *ut.RankResp, err error)

UserRank return one's rank

func (*Service) UtDetailList

func (s *Service) UtDetailList(c context.Context, arg *ut.DetailReq) (utpkgs []*ut.PkgAnls, err error)

UtDetailList get ut pkganls by commit_id&pkg

func (*Service) UtHistoryCommit

func (s *Service) UtHistoryCommit(c context.Context, arg *ut.HistoryCommitReq) (utcmts []*ut.Commit, count int, err error)

UtHistoryCommit get commits history list by merge_id

func (*Service) UtList

func (s *Service) UtList(c context.Context, arg *ut.MergeReq) (mrInfs []*ut.Merge, count int, err error)

UtList return ut_list by merge_id or username

func (*Service) WechatReport

func (s *Service) WechatReport(c context.Context, mrid int64, cid, src, des string) (err error)

WechatReport send wechat msg to a group when mr is merged

Jump to

Keyboard shortcuts

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