Documentation ¶
Index ¶
- Constants
- Variables
- func RegisterRouter(r *gin.RouterGroup, auth *user.AuthService, s *Service)
- type CreateTaskGroupRequest
- type LogLevel
- type PreviewModel
- type Scheduler
- type SearchLogRequest
- type Service
- func (s *Service) CancelTask(c *gin.Context)
- func (s *Service) CreateTaskGroup(c *gin.Context)
- func (s *Service) DeleteTaskGroup(c *gin.Context)
- func (s *Service) DownloadLogs(c *gin.Context)
- func (s *Service) GetAllTaskGroups(c *gin.Context)
- func (s *Service) GetDownloadToken(c *gin.Context)
- func (s *Service) GetTaskGroup(c *gin.Context)
- func (s *Service) GetTaskGroupPreview(c *gin.Context)
- func (s *Service) RetryTask(c *gin.Context)
- type Task
- type TaskGroup
- type TaskGroupModel
- type TaskGroupResponse
- type TaskGroupState
- type TaskModel
- type TaskState
Constants ¶
const ( TaskMaxPreviewLines = 500 TaskGroupMaxPreviewLines = 5000 )
Variables ¶
var MaxRecvMsgSize = math.MaxInt64
MaxRecvMsgSize set max gRPC receive message size received from server. If any message size is larger than current value, an error will be reported from gRPC.
var PBLogLevelSlice = []diagnosticspb.LogLevel{ diagnosticspb.LogLevel(LogLevelUnknown), diagnosticspb.LogLevel(LogLevelDebug), diagnosticspb.LogLevel(LogLevelInfo), diagnosticspb.LogLevel(LogLevelWarn), diagnosticspb.LogLevel(LogLevelTrace), diagnosticspb.LogLevel(LogLevelCritical), diagnosticspb.LogLevel(LogLevelError), }
Functions ¶
func RegisterRouter ¶
func RegisterRouter(r *gin.RouterGroup, auth *user.AuthService, s *Service)
Types ¶
type CreateTaskGroupRequest ¶
type CreateTaskGroupRequest struct { Request SearchLogRequest `json:"request" binding:"required"` Targets []model.RequestTargetNode `json:"targets" binding:"required"` }
type PreviewModel ¶
type PreviewModel struct { ID uint `json:"id" grom:"primary_key"` TaskID uint `json:"task_id" gorm:"index:task"` TaskGroupID uint `json:"task_group_id" gorm:"index:task_group"` Time int64 `json:"time" gorm:"index:task,task_group"` Level diagnosticspb.LogLevel `json:"level" gorm:"type:integer"` Message string `json:"message" gorm:"type:text"` }
func (PreviewModel) TableName ¶
func (PreviewModel) TableName() string
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
func NewScheduler ¶
func (*Scheduler) AsyncAbort ¶
func (*Scheduler) AsyncStart ¶
func (s *Scheduler) AsyncStart(taskGroupModel *TaskGroupModel, tasksModel []*TaskModel) bool
type SearchLogRequest ¶
type SearchLogRequest struct { StartTime int64 `json:"start_time"` EndTime int64 `json:"end_time"` MinLevel LogLevel `json:"min_level"` // We use a string array to represent multiple CNF pattern sceniaor like: // SELECT * FROM t WHERE c LIKE '%s%' and c REGEXP '.*a.*' because // Golang and Rust don't support perl-like (?=re1)(?=re2) Patterns []string `json:"patterns"` }
func (*SearchLogRequest) ConvertToPB ¶
func (r *SearchLogRequest) ConvertToPB(target diagnosticspb.SearchLogRequest_Target) *diagnosticspb.SearchLogRequest
func (*SearchLogRequest) Scan ¶
func (r *SearchLogRequest) Scan(src interface{}) error
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) CancelTask ¶
@Summary Cancel running tasks in a log search task group @Param id path string true "task group id" @Security JwtAuth @Success 200 {object} utils.APIEmptyResponse @Failure 401 {object} utils.APIError "Unauthorized failure" @Failure 400 {object} utils.APIError @Router /logs/taskgroups/{id}/cancel [post]
func (*Service) CreateTaskGroup ¶
@Summary Create and run a new log search task group @Param request body CreateTaskGroupRequest true "Request body" @Security JwtAuth @Success 200 {object} TaskGroupResponse @Failure 400 {object} utils.APIError "Bad request" @Failure 401 {object} utils.APIError "Unauthorized failure" @Failure 500 {object} utils.APIError @Router /logs/taskgroup [put]
func (*Service) DeleteTaskGroup ¶
@Summary Delete a log search task group @Param id path string true "task group id" @Security JwtAuth @Success 200 {object} utils.APIEmptyResponse @Failure 401 {object} utils.APIError "Unauthorized failure" @Failure 500 {object} utils.APIError @Router /logs/taskgroups/{id} [delete]
func (*Service) DownloadLogs ¶
@Summary Download logs @Produce application/x-tar,application/zip @Param token query string true "download token" @Failure 400 {object} utils.APIError @Failure 401 {object} utils.APIError "Unauthorized failure" @Failure 500 {object} utils.APIError @Router /logs/download [get]
func (*Service) GetAllTaskGroups ¶
@Summary List all log search task groups @Security JwtAuth @Success 200 {array} TaskGroupModel @Failure 401 {object} utils.APIError "Unauthorized failure" @Failure 500 {object} utils.APIError @Router /logs/taskgroups [get]
func (*Service) GetDownloadToken ¶
@Summary Generate a download token for downloading logs @Produce plain @Param id query []string false "task id" collectionFormat(csv) @Security JwtAuth @Success 200 {string} string "xxx" @Failure 400 {object} utils.APIError @Failure 401 {object} utils.APIError "Unauthorized failure" @Router /logs/download/acquire_token [get]
func (*Service) GetTaskGroup ¶
@Summary List tasks in a log search task group @Param id path string true "Task Group ID" @Security JwtAuth @Success 200 {object} TaskGroupResponse @Failure 401 {object} utils.APIError "Unauthorized failure" @Failure 500 {object} utils.APIError @Router /logs/taskgroups/{id} [get]
func (*Service) GetTaskGroupPreview ¶
@Summary Preview a log search task group @Param id path string true "task group id" @Security JwtAuth @Success 200 {array} PreviewModel @Failure 401 {object} utils.APIError "Unauthorized failure" @Failure 500 {object} utils.APIError @Router /logs/taskgroups/{id}/preview [get]
func (*Service) RetryTask ¶
@Summary Retry failed tasks in a log search task group @Param id path string true "task group id" @Security JwtAuth @Success 200 {object} utils.APIEmptyResponse @Failure 400 {object} utils.APIError @Failure 401 {object} utils.APIError "Unauthorized failure" @Failure 500 {object} utils.APIError @Router /logs/taskgroups/{id}/retry [post]
type TaskGroup ¶
type TaskGroup struct {
// contains filtered or unexported fields
}
type TaskGroupModel ¶
type TaskGroupModel struct { ID uint `json:"id" gorm:"primary_key"` SearchRequest *SearchLogRequest `json:"search_request" gorm:"type:text"` State TaskGroupState `json:"state" gorm:"index"` TargetStats model.RequestTargetStatistics `json:"target_stats" gorm:"embedded;embedded_prefix:target_stats_"` LogStoreDir *string `json:"log_store_dir" gorm:"type:text"` }
func (*TaskGroupModel) Delete ¶
func (tg *TaskGroupModel) Delete(db *dbstore.DB)
func (TaskGroupModel) TableName ¶
func (TaskGroupModel) TableName() string
type TaskGroupResponse ¶
type TaskGroupResponse struct { TaskGroup TaskGroupModel `json:"task_group"` Tasks []*TaskModel `json:"tasks"` }
type TaskGroupState ¶
type TaskGroupState int
const ( TaskGroupStateRunning TaskGroupState = 1 TaskGroupStateFinished TaskGroupState = 2 )
type TaskModel ¶
type TaskModel struct { ID uint `json:"id" gorm:"primary_key"` TaskGroupID uint `json:"task_group_id" gorm:"index"` Target *model.RequestTargetNode `json:"target" gorm:"embedded;embedded_prefix:target_"` State TaskState `json:"state" gorm:"index"` LogStorePath *string `json:"log_store_path" gorm:"type:text"` SlowLogStorePath *string `json:"slow_log_store_path" gorm:"type:text"` Size int64 `json:"size" gorm:"index"` Error *string `json:"error" gorm:"type:text"` }
func (*TaskModel) RemoveDataAndPreview ¶
Note: this function does not save model itself.