Füge Modelle für Flows, FlowRuns, TaskRuns, WorkPools, WorkQueues, Deployments, Variablen, FlowRunStates, Logs, und Blocks samt zugehöriger Unmarshal-Logik und Zeitfeld-Unterstützung hinzu; ergänze Tests für die FlowRunStates-Service-Methoden.

This commit is contained in:
Gregor Schulte
2026-03-27 14:02:32 +01:00
parent 3aff707116
commit 57531a7d95
36 changed files with 3165 additions and 0 deletions

62
pkg/models/work_queues.go Normal file
View File

@@ -0,0 +1,62 @@
package models
import (
"encoding/json"
"time"
"github.com/google/uuid"
)
// WorkQueue represents a Prefect work queue.
type WorkQueue struct {
ID uuid.UUID `json:"id"`
Created *time.Time `json:"created"`
Updated *time.Time `json:"updated"`
Name string `json:"name"`
Description *string `json:"description"`
IsPaused bool `json:"is_paused"`
Priority int `json:"priority"`
}
// WorkQueueCreate represents the request to create a work queue.
type WorkQueueCreate struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
IsPaused bool `json:"is_paused,omitempty"`
ConcurrencyLimit *int `json:"concurrency_limit,omitempty"`
Priority *int `json:"priority,omitempty"`
}
// WorkQueueUpdate represents the request to update a work queue.
type WorkQueueUpdate struct {
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
IsPaused *bool `json:"is_paused,omitempty"`
ConcurrencyLimit *int `json:"concurrency_limit,omitempty"`
Priority *int `json:"priority,omitempty"`
}
// WorkQueueFilter represents filter criteria for querying work queues.
type WorkQueueFilter struct {
Name *string `json:"name,omitempty"`
Offset int `json:"offset,omitempty"`
Limit int `json:"limit,omitempty"`
}
// UnmarshalJSON implements custom JSON unmarshaling for time fields.
func (wq *WorkQueue) UnmarshalJSON(data []byte) error {
type Alias WorkQueue
aux := &struct {
Created optTime `json:"created"`
Updated optTime `json:"updated"`
*Alias
}{
Alias: (*Alias)(wq),
}
if err := json.Unmarshal(data, aux); err != nil {
return err
}
wq.Created = aux.Created.V
wq.Updated = aux.Updated.V
return nil
}