rest

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2026 License: Apache-2.0 Imports: 18 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 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 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) 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) 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 Params

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

type SchedulingIntents

type SchedulingIntents struct {
	Priority      bool            `json:"priority"`                // If true, set vtime to minimum vtime
	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