Documentation
¶
Index ¶
- Constants
- func ErrorHandler(c *gin.Context, message string, statusCode int)
- func MultiErrorHandler(me openapi3.MultiError) error
- func ParseBody[B any](ctx context.Context, c *gin.Context) (body B, err error)
- func ParseCursor(cursor string) (time.Time, string, error)
- func ParseMetadata(ctx context.Context, metadata *string) (*map[string]string, error)
- func ParseNextToken(token *string) (time.Time, string, error)
- func SandboxChangingStateMsg(sandboxID string, state sandbox.State) string
- func SandboxNotFoundMsg(sandboxID string) string
- func ShortID(compositeID string) (string, error)
- func SortPaginatedSandboxesDesc(sandboxes []PaginatedSandbox)
- func UnwrapGRPCError(err error) error
- type Cursor
- type NoOpWriter
- type PaginatedSandbox
- type Pagination
- type PaginationConfig
- type PaginationParams
- type Result
- type TemplateCounter
- type TemplateSpawnCounter
Constants ¶
const (
MaxSandboxID = "zzzzzzzzzzzzzzzzzzzz"
)
Variables ¶
This section is empty.
Functions ¶
func MultiErrorHandler ¶
func MultiErrorHandler(me openapi3.MultiError) error
MultiErrorHandler handles wrapped SecurityRequirementsError, so there are no multiple errors returned to the user.
func ParseMetadata ¶
func SandboxChangingStateMsg ¶
func SandboxNotFoundMsg ¶
func SortPaginatedSandboxesDesc ¶
func SortPaginatedSandboxesDesc(sandboxes []PaginatedSandbox)
SortPaginatedSandboxesDesc sorts the sandboxes by StartedAt (descending), then by SandboxID (ascending) for stability
func UnwrapGRPCError ¶
Types ¶
type NoOpWriter ¶
type NoOpWriter struct{}
NoOpWriter is an io.Writer implementation that discards anything written to it.
type PaginatedSandbox ¶
type PaginatedSandbox struct {
api.ListedSandbox
PaginationTimestamp time.Time `json:"-"`
}
PaginatedSandbox extends the api.ListedSandbox with a timestamp to use for pagination
func FilterBasedOnCursor ¶
func FilterBasedOnCursor(sandboxes []PaginatedSandbox, cursorTime time.Time, cursorID string) []PaginatedSandbox
func FilterSandboxesOnMetadata ¶
func FilterSandboxesOnMetadata(sandboxes []PaginatedSandbox, metadata *map[string]string) []PaginatedSandbox
type Pagination ¶
type Pagination[T any] struct { // contains filtered or unexported fields }
Pagination handles pagination logic for list endpoints
func NewPagination ¶
func NewPagination[T any](params PaginationParams, config PaginationConfig) (*Pagination[T], error)
NewPagination creates a new pagination instance from request parameters
func (*Pagination[T]) CursorID ¶
func (p *Pagination[T]) CursorID() string
CursorID returns the cursor ID
func (*Pagination[T]) CursorTime ¶
func (p *Pagination[T]) CursorTime() time.Time
CursorTime returns the cursor timestamp
func (*Pagination[T]) ProcessResultsWithHeader ¶
func (p *Pagination[T]) ProcessResultsWithHeader(c *gin.Context, results []T, getTimestampAndID func(T) (time.Time, string)) []T
ProcessResultsWithHeader handles pagination and sets the X-Next-Token header in one call. This is a convenience method that combines ProcessResults and SetHeader.
func (*Pagination[T]) QueryLimit ¶
func (p *Pagination[T]) QueryLimit() int32
QueryLimit returns the limit to use for database queries (limit + 1 to detect more results)
type PaginationConfig ¶
type PaginationConfig struct {
DefaultLimit int32
MaxLimit int32
DefaultID string // Default cursor ID when no token is provided (e.g., max UUID or max sandbox ID)
}
PaginationConfig holds configuration for pagination behavior
type PaginationParams ¶
PaginationParams holds pagination parameters from the API request
type TemplateCounter ¶
type TemplateCounter struct {
// contains filtered or unexported fields
}
type TemplateSpawnCounter ¶
type TemplateSpawnCounter struct {
// contains filtered or unexported fields
}
func NewTemplateSpawnCounter ¶
func (*TemplateSpawnCounter) Close ¶
func (t *TemplateSpawnCounter) Close(ctx context.Context)
func (*TemplateSpawnCounter) IncreaseTemplateSpawnCount ¶
func (t *TemplateSpawnCounter) IncreaseTemplateSpawnCount(templateID string, time time.Time)