api

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2025 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const REDIS_SET_DURATION = 30 * time.Minute

Variables

This section is empty.

Functions

func HashConfig

func HashConfig(config string) string

func NewRouter

func NewRouter(c *core.Core, redisClient *redis.Client, callbackHandler CallbackHandler, configSuccessHandler ConfigSuccessHandler, logger *zap.Logger, updater *github.Updater, worker *workerpool.WorkerPool, versionInfo VersionInfo, redisResultExpiration time.Duration, refreshInterval time.Duration) *mux.Router

Types

type BuildInfo added in v1.1.0

type BuildInfo struct {
	Version   string `json:"version"`
	Commit    string `json:"commit"`
	Date      string `json:"date"`
	GoVersion string `json:"go_version"`
	Platform  string `json:"platform"`
}

type CallbackHandler

type CallbackHandler func(CallbackHandlerResult)

type CallbackHandlerResult

type CallbackHandlerResult struct {
	JobID   string
	Results []core.CheckResult
	Error   error
}

type CheckRequest

type CheckRequest struct {
	Configs []string `json:"configs"`
}

type CheckResponse

type CheckResponse struct {
	Results []CheckResult `json:"results"`
}

type CheckResult

type CheckResult struct {
	Index  int    `json:"index"`
	Status string `json:"status"`
	Delay  int64  `json:"delay_ms"`
	Error  string `json:"error,omitempty"`
}

type ConfigSuccessHandler

type ConfigSuccessHandler func(core.CheckResult)

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(c *core.Core, redisClient *redis.Client, callbackHandler CallbackHandler, configSuccessHandler ConfigSuccessHandler, logger *zap.Logger, updater *github.Updater, worker *workerpool.WorkerPool, versionInfo VersionInfo, redisResultExpiration time.Duration, refreshInterval time.Duration) *Handler

func (*Handler) Close

func (h *Handler) Close()

type HealthResponse

type HealthResponse struct {
	Status     string           `json:"status"`
	Version    string           `json:"version"`
	Build      BuildInfo        `json:"build"`
	WorkerPool WorkerPoolStatus `json:"worker_pool"`
}

type Job

type Job struct {
	ID         string                 `json:"id"`
	Status     JobStatus              `json:"status"`
	Configs    []string               `json:"-"`
	Results    map[string]CheckResult `json:"results"`
	TotalCount int                    `json:"total_count"`
	DoneCount  int                    `json:"done_count"`
	StartTime  *time.Time             `json:"start_time,omitempty"`
	EndTime    *time.Time             `json:"end_time,omitempty"`
	CreatedAt  time.Time              `json:"created_at"`
	Error      string                 `json:"error,omitempty"`
	// contains filtered or unexported fields
}

func NewJob

func NewJob(configs []string) *Job

func (*Job) AddResult

func (j *Job) AddResult(configHash string, result CheckResult)

func (*Job) Complete

func (j *Job) Complete()

func (*Job) Done

func (j *Job) Done()

func (*Job) Fail

func (j *Job) Fail(err error)

func (*Job) Start

func (j *Job) Start()

type JobStatus

type JobStatus string
const (
	JobStatusPending   JobStatus = "pending"
	JobStatusRunning   JobStatus = "running"
	JobStatusCompleted JobStatus = "completed"
	JobStatusFailed    JobStatus = "failed"
)

type MessageResponse

type MessageResponse struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
}

type ScanRequest

type ScanRequest struct {
	Configs []string `json:"configs"`
}

type ScanResponse

type ScanResponse struct {
	JobID string `json:"job_id"`
}

type TaskData

type TaskData struct {
	JobID   string   `json:"job_id"`
	Configs []string `json:"configs"`
	Index   int      `json:"index"`
}

type VersionInfo added in v1.1.0

type VersionInfo struct {
	Version   string
	Commit    string
	Date      string
	GoVersion string
	Platform  string
}

type WorkerPoolStatus

type WorkerPoolStatus struct {
	WorkerCount    int    `json:"worker_count"`
	TotalTasks     int64  `json:"total_tasks"`
	CompletedTasks int64  `json:"completed_tasks"`
	FailedTasks    int64  `json:"failed_tasks"`
	QueueLength    int64  `json:"queue_length"`
	IsRunning      bool   `json:"is_running"`
	Uptime         string `json:"uptime"`
}

Jump to

Keyboard shortcuts

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