Documentation
¶
Index ¶
- func GetJwtAuthMiddleware(tokenConfig config.TokenConfig) (func(next http.Handler) http.Handler, error)
- type Claims
- type DeleteIntentRequest
- type EmptyResponse
- type ErrorResponse
- type GetPodsPIDsResponse
- type HandleIntentsRequest
- type Handler
- func (h *Handler) DeleteIntent(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ErrorResponse(ctx context.Context, w http.ResponseWriter, status int, errMsg string, ...)
- func (h Handler) GenTokenHandler(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetIntentMerkleRoot(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetPodsPIDs(w http.ResponseWriter, r *http.Request)
- func (h *Handler) HandleError(ctx context.Context, w http.ResponseWriter, err error)
- func (h *Handler) HandleIntents(w http.ResponseWriter, r *http.Request)
- func (h *Handler) HealthCheck(w http.ResponseWriter, r *http.Request)
- func (h *Handler) JSONBind(r *http.Request, dst any) error
- func (h *Handler) JSONResponse(ctx context.Context, w http.ResponseWriter, status int, data any)
- func (h *Handler) ListIntents(w http.ResponseWriter, r *http.Request)
- func (h *Handler) SetupRoutes(engine *echo.Echo) error
- func (h *Handler) UpdateMetrics(w http.ResponseWriter, r *http.Request)
- func (h *Handler) Version(w http.ResponseWriter, r *http.Request)
- type HealthResponse
- type Intent
- type LabelSelector
- type ListIntentsResponse
- type MerkleRootResponse
- type Params
- type PodInfo
- type PodProcess
- type SchedulingIntents
- type SuccessResponse
- type TokenRequest
- type TokenResponse
- type UpdateMetricsRequest
- type VersionResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetJwtAuthMiddleware ¶
Types ¶
type Claims ¶
type Claims struct {
ClientID string `json:"client_id"`
jwt.RegisteredClaims
}
Claims represents JWT token claims
type DeleteIntentRequest ¶ added in v1.1.0
type EmptyResponse ¶
type EmptyResponse struct{}
EmptyResponse is used for endpoints that return no data payload.
type ErrorResponse ¶
ErrorResponse represents error response structure
type GetPodsPIDsResponse ¶ added in v1.2.0
type GetPodsPIDsResponse struct {
Pods []PodInfo `json:"pods"`
Timestamp string `json:"timestamp"`
NodeName string `json:"node_name"`
NodeID string `json:"node_id,omitempty"`
}
GetPodsPIDsResponse is the response structure for the GET /api/v1/pods/pids endpoint
type HandleIntentsRequest ¶
type HandleIntentsRequest struct {
Intents []Intent `json:"intents"`
}
type Handler ¶
type Handler struct {
Service *service.Service
TokenConfig config.TokenConfig
}
func NewHandler ¶
func (*Handler) DeleteIntent ¶ added in v1.1.0
func (h *Handler) DeleteIntent(w http.ResponseWriter, r *http.Request)
func (*Handler) ErrorResponse ¶
func (Handler) GenTokenHandler ¶
func (h Handler) GenTokenHandler(w http.ResponseWriter, r *http.Request)
GenTokenHandler handles JWT token generation upon public key verification
func (*Handler) GetIntentMerkleRoot ¶ added in v1.2.0
func (h *Handler) GetIntentMerkleRoot(w http.ResponseWriter, r *http.Request)
func (*Handler) GetPodsPIDs ¶ added in v1.2.0
func (h *Handler) GetPodsPIDs(w http.ResponseWriter, r *http.Request)
GetPodsPIDs godoc @Summary Get Pod to PID mappings @Description Returns all pods running on this node with their associated process IDs @Tags Pods @Produce json @Security BearerAuth @Success 200 {object} SuccessResponse[GetPodsPIDsResponse] @Failure 401 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /api/v1/pods/pids [get]
func (*Handler) HandleError ¶
func (*Handler) HandleIntents ¶
func (h *Handler) HandleIntents(w http.ResponseWriter, r *http.Request)
func (*Handler) HealthCheck ¶
func (h *Handler) HealthCheck(w http.ResponseWriter, r *http.Request)
HealthCheck godoc @Summary Health check @Description Basic health check for readiness probes. @Tags System @Produce json @Success 200 {object} HealthResponse @Router /health [get]
func (*Handler) JSONResponse ¶
func (*Handler) ListIntents ¶
func (h *Handler) ListIntents(w http.ResponseWriter, r *http.Request)
func (*Handler) UpdateMetrics ¶
func (h *Handler) UpdateMetrics(w http.ResponseWriter, r *http.Request)
UpdateMetrics handles the updating of metrics via a REST endpoint.
type HealthResponse ¶
type HealthResponse struct {
Status string `json:"status"`
Timestamp string `json:"timestamp"`
Service string `json:"service"`
}
HealthResponse describes the health check payload.
type Intent ¶
type Intent struct {
PodName string `json:"podName,omitempty"`
PodID string `json:"podID,omitempty"`
NodeID string `json:"nodeID,omitempty"`
K8sNamespace string `json:"k8sNamespace,omitempty"`
CommandRegex string `json:"commandRegex,omitempty"`
Priority int `json:"priority,omitempty"`
ExecutionTime int64 `json:"executionTime,omitempty"`
PodLabels map[string]string `json:"podLabels,omitempty"`
}
type LabelSelector ¶
type LabelSelector struct {
Key string `json:"key"` // Label key
Value string `json:"value"` // Label value
}
LabelSelector represents a key-value pair for pod label selection
type ListIntentsResponse ¶
type ListIntentsResponse struct {
Success bool `json:"success"`
Message string `json:"message"`
Timestamp string `json:"timestamp"`
Scheduling []*SchedulingIntents `json:"scheduling"`
}
type MerkleRootResponse ¶ added in v1.2.0
type MerkleRootResponse struct {
RootHash string `json:"rootHash"`
}
type PodInfo ¶ added in v1.2.0
type PodInfo struct {
PodUID string `json:"pod_uid"`
PodID string `json:"pod_id,omitempty"`
Processes []PodProcess `json:"processes"`
}
PodInfo represents pod information with associated processes (for API response)
type PodProcess ¶ added in v1.2.0
type PodProcess struct {
PID int `json:"pid"`
Command string `json:"command"`
PPID int `json:"ppid,omitempty"`
ContainerID string `json:"container_id,omitempty"`
}
PodProcess represents a process information within a pod (for API response)
type SchedulingIntents ¶
type SchedulingIntents struct {
Priority int `json:"priority"` // Priority value; higher value means higher priority
ExecutionTime uint64 `json:"execution_time"` // Time slice for this process in nanoseconds
PID int `json:"pid,omitempty"` // Process ID to apply this strategy to
Selectors []LabelSelector `json:"selectors,omitempty"` // Label selectors to match pods
CommandRegex string `json:"command_regex,omitempty"` // Regex to match process command
}
SchedulingStrategy represents a strategy for process scheduling
type SuccessResponse ¶
type SuccessResponse[T any] struct { Success bool `json:"success"` Data *T `json:"data,omitempty"` Timestamp string `json:"timestamp"` }
SuccessResponse represents the success response structure
func NewSuccessResponse ¶
func NewSuccessResponse[T any](data *T) SuccessResponse[T]
type TokenRequest ¶
type TokenRequest struct {
PublicKey string `json:"public_key"` // PEM encoded public key
ClientID string `json:"client_id"` // Client identifier
ExpiredAt int64 `json:"expired_at"` // Expiration timestamp
}
TokenRequest represents the request structure for JWT token generation
type TokenResponse ¶
type TokenResponse struct {
Token string `json:"token,omitempty"`
ExpiredAt int64 `json:"expired_at,omitempty"`
}
TokenResponse represents the response structure for JWT token generation
type UpdateMetricsRequest ¶
type UpdateMetricsRequest struct {
Usersched_last_run_at uint64 `json:"usersched_last_run_at"` // The PID of the userspace scheduler
Nr_queued uint64 `json:"nr_queued"` // Number of tasks queued in the userspace scheduler
Nr_scheduled uint64 `json:"nr_scheduled"` // Number of tasks scheduled by the userspace scheduler
Nr_running uint64 `json:"nr_running"` // Number of tasks currently running in the userspace scheduler
Nr_online_cpus uint64 `json:"nr_online_cpus"` // Number of online CPUs in the system
Nr_user_dispatches uint64 `json:"nr_user_dispatches"` // Number of user-space dispatches
Nr_kernel_dispatches uint64 `json:"nr_kernel_dispatches"` // Number of kernel-space dispatches
Nr_cancel_dispatches uint64 `json:"nr_cancel_dispatches"` // Number of cancelled dispatches
Nr_bounce_dispatches uint64 `json:"nr_bounce_dispatches"` // Number of bounce dispatches
Nr_failed_dispatches uint64 `json:"nr_failed_dispatches"` // Number of failed dispatches
Nr_sched_congested uint64 `json:"nr_sched_congested"` // Number of times the scheduler was congested
}
UpdateMetricsRequest represents the payload for updating metrics.
type VersionResponse ¶
type VersionResponse struct {
Message string `json:"message"`
Version string `json:"version"`
Endpoints string `json:"endpoints"`
}
VersionResponse describes the version endpoint payload.