rest

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: Apache-2.0 Imports: 19 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetJwtAuthMiddleware

func GetJwtAuthMiddleware(tokenConfig config.TokenConfig) (func(next http.Handler) http.Handler, error)

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 DeleteIntentRequest struct {
	PodID string `json:"podId,omitempty"` // If provided, deletes all intents for this pod
	PID   *int   `json:"pid,omitempty"`   // If provided with PodID, deletes specific intent
	All   bool   `json:"all,omitempty"`   // If true, deletes all intents
}

type EmptyResponse

type EmptyResponse struct{}

EmptyResponse is used for endpoints that return no data payload.

type ErrorResponse

type ErrorResponse struct {
	Success bool   `json:"success"`
	Error   string `json:"error"`
}

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 NewHandler(params Params) (*Handler, error)

func (*Handler) DeleteIntent added in v1.1.0

func (h *Handler) DeleteIntent(w http.ResponseWriter, r *http.Request)

func (*Handler) ErrorResponse

func (h *Handler) ErrorResponse(ctx context.Context, w http.ResponseWriter, status int, errMsg string, err error)

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 (h *Handler) HandleError(ctx context.Context, w http.ResponseWriter, err error)

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) JSONBind

func (h *Handler) JSONBind(r *http.Request, dst any) error

func (*Handler) JSONResponse

func (h *Handler) JSONResponse(ctx context.Context, w http.ResponseWriter, status int, data any)

func (*Handler) ListIntents

func (h *Handler) ListIntents(w http.ResponseWriter, r *http.Request)

func (*Handler) SetupRoutes

func (h *Handler) SetupRoutes(engine *echo.Echo) error

func (*Handler) UpdateMetrics

func (h *Handler) UpdateMetrics(w http.ResponseWriter, r *http.Request)

UpdateMetrics handles the updating of metrics via a REST endpoint.

func (*Handler) Version

func (h *Handler) Version(w http.ResponseWriter, r *http.Request)

Version godoc @Summary Get service version @Description Returns service version and exposed endpoints. @Tags System @Produce json @Success 200 {object} VersionResponse @Router /version [get]

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 Params

type Params struct {
	fx.In
	Service     *service.Service
	TokenConfig config.TokenConfig
}

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.

Jump to

Keyboard shortcuts

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