加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
scraper.go 1.78 KB
一键复制 编辑 原始数据 按行查看 历史
package influxdb
import (
"context"
)
// ErrScraperTargetNotFound is the error msg for a missing scraper target.
const ErrScraperTargetNotFound = "scraper target not found"
// ops for ScraperTarget Store
const (
OpListTargets = "ListTargets"
OpAddTarget = "AddTarget"
OpGetTargetByID = "GetTargetByID"
OpRemoveTarget = "RemoveTarget"
OpUpdateTarget = "UpdateTarget"
)
// ScraperTarget is a target to scrape
type ScraperTarget struct {
ID ID `json:"id,omitempty"`
Name string `json:"name"`
Type ScraperType `json:"type"`
URL string `json:"url"`
OrgID ID `json:"orgID,omitempty"`
BucketID ID `json:"bucketID,omitempty"`
}
// ScraperTargetStoreService defines the crud service for ScraperTarget.
type ScraperTargetStoreService interface {
ListTargets(ctx context.Context, filter ScraperTargetFilter) ([]ScraperTarget, error)
AddTarget(ctx context.Context, t *ScraperTarget, userID ID) error
GetTargetByID(ctx context.Context, id ID) (*ScraperTarget, error)
RemoveTarget(ctx context.Context, id ID) error
UpdateTarget(ctx context.Context, t *ScraperTarget, userID ID) (*ScraperTarget, error)
}
// ScraperTargetFilter represents a set of filter that restrict the returned results.
type ScraperTargetFilter struct {
IDs map[ID]bool `json:"ids"`
Name *string `json:"name"`
OrgID *ID `json:"orgID"`
Org *string `json:"org"`
}
// ScraperType defines the scraper methods.
type ScraperType string
// Scraper types
const (
// PrometheusScraperType parses metrics from a prometheus endpoint.
PrometheusScraperType = "prometheus"
)
// ValidScraperType returns true is the type string is valid
func ValidScraperType(s string) bool {
switch s {
case PrometheusScraperType:
return true
default:
return false
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化