Documentation
¶
Index ¶
- Constants
- type GORMStore
- func (s *GORMStore) Close() error
- func (s *GORMStore) CreateAPIKey(ctx context.Context, name string) (*pb.APIKey, string, error)
- func (s *GORMStore) CreateDeployment(ctx context.Context, req *pb.CreateDeploymentRequest) (*pb.Deployment, error)
- func (s *GORMStore) CreateModel(ctx context.Context, m *pb.Model) (*pb.Model, error)
- func (s *GORMStore) CreateModelDeploymentTemplate(ctx context.Context, req *pb.CreateModelDeploymentTemplateRequest) (*pb.ModelDeploymentTemplate, error)
- func (s *GORMStore) CreateSecret(ctx context.Context, name, value string) (*pb.Secret, error)
- func (s *GORMStore) DeleteAPIKey(ctx context.Context, id string) error
- func (s *GORMStore) DeleteDeployment(ctx context.Context, id string) error
- func (s *GORMStore) DeleteJob(ctx context.Context, id string) error
- func (s *GORMStore) DeleteModelDeploymentTemplate(ctx context.Context, modelID, id string) error
- func (s *GORMStore) DeleteProvision(ctx context.Context, provisionId string) error
- func (s *GORMStore) DeleteSecret(ctx context.Context, id string) error
- func (s *GORMStore) ExistsProvision(ctx context.Context, provisionId string) (bool, error)
- func (s *GORMStore) GetDemoJob(id string) (*pb.Job, bool)
- func (s *GORMStore) GetDeployment(ctx context.Context, id string) (*pb.Deployment, error)
- func (s *GORMStore) GetJob(ctx context.Context, id string) (*models.Job, error)
- func (s *GORMStore) GetModel(ctx context.Context, id string) (*pb.Model, error)
- func (s *GORMStore) GetModelDeploymentTemplate(ctx context.Context, modelID, id string) (*pb.ModelDeploymentTemplate, error)
- func (s *GORMStore) GetProvision(ctx context.Context, provisionId string) (*types.ProvisionResult, error)
- func (s *GORMStore) GetProvisionByIdempotencyKey(ctx context.Context, idempotencyKey string) (*types.ProvisionResult, error)
- func (s *GORMStore) ListAPIKeys(ctx context.Context) ([]*pb.APIKey, error)
- func (s *GORMStore) ListAllJobs(ctx context.Context, after string, limit int) ([]*models.Job, bool, error)
- func (s *GORMStore) ListDemoJobs() []*pb.Job
- func (s *GORMStore) ListDeployments(ctx context.Context, search string) ([]*pb.Deployment, error)
- func (s *GORMStore) ListJobs(ctx context.Context, ids []string) (map[string]*models.Job, error)
- func (s *GORMStore) ListJobsByBatchIDs(ctx context.Context, batchIDs []string) (map[string]*models.Job, error)
- func (s *GORMStore) ListJobsByDatasetID(ctx context.Context, fileID string) ([]*models.Job, error)
- func (s *GORMStore) ListModelDeploymentTemplates(ctx context.Context, modelID, statusFilter, name string) ([]*pb.ModelDeploymentTemplate, error)
- func (s *GORMStore) ListModels(ctx context.Context, search, category string) ([]*pb.Model, error)
- func (s *GORMStore) ListNonTerminalJobs(ctx context.Context) ([]*models.Job, error)
- func (s *GORMStore) ListProvisions(ctx context.Context, options *types.ListOptions) ([]*types.ProvisionResult, error)
- func (s *GORMStore) ListQuotas(ctx context.Context, search string) ([]*pb.Quota, error)
- func (s *GORMStore) ListSecrets(ctx context.Context, search string) ([]*pb.Secret, error)
- func (s *GORMStore) LoadDemoData() error
- func (s *GORMStore) ResolveModelDeploymentTemplate(ctx context.Context, modelID, name, version string) (*pb.ModelDeploymentTemplate, error)
- func (s *GORMStore) RunMigrations() error
- func (s *GORMStore) UpdateModelDeploymentTemplate(ctx context.Context, req *pb.UpdateModelDeploymentTemplateRequest) (*pb.ModelDeploymentTemplate, error)
- func (s *GORMStore) UpdateProvisionStatus(ctx context.Context, provisionId string, pstatus types.ProvisionStatus) error
- func (s *GORMStore) UpsertJob(ctx context.Context, rec *models.Job) error
- func (s *GORMStore) UpsertProvision(ctx context.Context, result *types.ProvisionResult) error
- type Store
Constants ¶
const (
DefaultStoreListLimit = 50
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GORMStore ¶
type GORMStore struct {
// contains filtered or unexported fields
}
GORMStore implements Store for mysql/sqlite with shared logic.
func NewMemoryStore ¶
func NewMemoryStore(injector error_injection.Injector) *GORMStore
NewMemoryStore returns an in-memory SQLite store. Convenience wrapper used by the memory:// URI scheme and by tests; equivalent to NewSQLiteStore(":memory:", ...). Production deployments should use a sqlite: file URL or mysql:// instead.
func NewMySQLStore ¶
func NewMySQLStore(dsn, encryptionKey string, injector error_injection.Injector) (*GORMStore, error)
NewMySQLStore creates mysql-backed gorm store with auto-migrations.
func NewSQLiteStore ¶
func NewSQLiteStore(dsn, encryptionKey string, injector error_injection.Injector) (*GORMStore, error)
NewSQLiteStore creates sqlite-backed gorm store with auto-migrations. Pass ":memory:" or any "...mode=memory..." DSN to get an in-memory database; such DSNs are pinned to a single connection so all queries see the same in-process database.
func (*GORMStore) CreateAPIKey ¶
func (*GORMStore) CreateDeployment ¶
func (s *GORMStore) CreateDeployment(ctx context.Context, req *pb.CreateDeploymentRequest) (*pb.Deployment, error)
func (*GORMStore) CreateModel ¶
func (*GORMStore) CreateModelDeploymentTemplate ¶
func (s *GORMStore) CreateModelDeploymentTemplate(ctx context.Context, req *pb.CreateModelDeploymentTemplateRequest) (*pb.ModelDeploymentTemplate, error)
func (*GORMStore) CreateSecret ¶
func (*GORMStore) DeleteAPIKey ¶
func (*GORMStore) DeleteDeployment ¶
func (*GORMStore) DeleteModelDeploymentTemplate ¶
func (*GORMStore) DeleteProvision ¶
func (*GORMStore) DeleteSecret ¶
func (*GORMStore) ExistsProvision ¶
func (*GORMStore) GetDemoJob ¶
GetDemoJob looks up a single full pb.Job by id. Counterpart of ListDemoJobs.
func (*GORMStore) GetDeployment ¶
func (*GORMStore) GetModelDeploymentTemplate ¶
func (*GORMStore) GetProvision ¶
func (*GORMStore) GetProvisionByIdempotencyKey ¶
func (*GORMStore) ListAPIKeys ¶
func (*GORMStore) ListAllJobs ¶
func (s *GORMStore) ListAllJobs(ctx context.Context, after string, limit int) ([]*models.Job, bool, error)
ListAllJobs lists all jobs with cursor-based pagination, sorted by created_at descending. after is the job ID cursor - returns jobs created before this job.
func (*GORMStore) ListDemoJobs ¶
ListDemoJobs returns the full pb.Job records (including OpenAI Batch state fields) currently stored, used by the JobHandler dev fallback when MDS is unreachable. Unlike the Store.ListJobs interface method which only surfaces the Console-owned overlay subset, this method returns whatever was seeded directly into s.
func (*GORMStore) ListDeployments ¶
func (*GORMStore) ListJobsByBatchIDs ¶
func (*GORMStore) ListJobsByDatasetID ¶
func (*GORMStore) ListModelDeploymentTemplates ¶
func (*GORMStore) ListModels ¶
func (*GORMStore) ListNonTerminalJobs ¶
func (*GORMStore) ListProvisions ¶
func (s *GORMStore) ListProvisions(ctx context.Context, options *types.ListOptions) ([]*types.ProvisionResult, error)
func (*GORMStore) ListQuotas ¶
func (*GORMStore) ListSecrets ¶
func (*GORMStore) LoadDemoData ¶
LoadDemoData populates the store with demo records. Safe to call once on a fresh store; calling on a store that already has data appends and may yield duplicate IDs depending on the demo seed.
func (*GORMStore) ResolveModelDeploymentTemplate ¶
func (*GORMStore) RunMigrations ¶
func (*GORMStore) UpdateModelDeploymentTemplate ¶
func (s *GORMStore) UpdateModelDeploymentTemplate(ctx context.Context, req *pb.UpdateModelDeploymentTemplateRequest) (*pb.ModelDeploymentTemplate, error)
func (*GORMStore) UpdateProvisionStatus ¶
func (*GORMStore) UpsertProvision ¶
type Store ¶
type Store interface {
// Deployments
ListDeployments(ctx context.Context, search string) ([]*pb.Deployment, error)
GetDeployment(ctx context.Context, id string) (*pb.Deployment, error)
CreateDeployment(ctx context.Context, req *pb.CreateDeploymentRequest) (*pb.Deployment, error)
DeleteDeployment(ctx context.Context, id string) error
// Jobs — Planner-owned state-machine snapshot of each job, persisted as models.Job.
UpsertJob(ctx context.Context, rec *models.Job) error
GetJob(ctx context.Context, id string) (*models.Job, error) // (nil, nil) when not found
ListJobs(ctx context.Context, ids []string) (map[string]*models.Job, error)
ListJobsByBatchIDs(ctx context.Context, batchIDs []string) (map[string]*models.Job, error)
ListJobsByDatasetID(ctx context.Context, fileID string) ([]*models.Job, error)
DeleteJob(ctx context.Context, id string) error
ListNonTerminalJobs(ctx context.Context) ([]*models.Job, error)
// ListAllJobs lists all jobs with cursor-based pagination.
// after is the job ID cursor (empty string for first page).
// Returns jobs sorted by created_at descending, hasMore indicates if more results exist.
ListAllJobs(ctx context.Context, after string, limit int) ([]*models.Job, bool, error)
// Models
ListModels(ctx context.Context, search, category string) ([]*pb.Model, error)
GetModel(ctx context.Context, id string) (*pb.Model, error)
CreateModel(ctx context.Context, m *pb.Model) (*pb.Model, error)
// Model Deployment Templates. modelID is the parent — Get/Update/Delete
// validate that the addressed template actually belongs to it, returning
// NotFound otherwise so URLs are canonical.
//
// ResolveModelDeploymentTemplate looks up by (modelID, name, version);
// version="" means "latest active". This is the path used by clients
// that pin templates from outside the UI (e.g. batch SDK callers passing
// model_template / model_template_version).
ListModelDeploymentTemplates(ctx context.Context, modelID, statusFilter, name string) ([]*pb.ModelDeploymentTemplate, error)
GetModelDeploymentTemplate(ctx context.Context, modelID, id string) (*pb.ModelDeploymentTemplate, error)
CreateModelDeploymentTemplate(ctx context.Context, req *pb.CreateModelDeploymentTemplateRequest) (*pb.ModelDeploymentTemplate, error)
UpdateModelDeploymentTemplate(ctx context.Context, req *pb.UpdateModelDeploymentTemplateRequest) (*pb.ModelDeploymentTemplate, error)
DeleteModelDeploymentTemplate(ctx context.Context, modelID, id string) error
ResolveModelDeploymentTemplate(ctx context.Context, modelID, name, version string) (*pb.ModelDeploymentTemplate, error)
// API Keys
ListAPIKeys(ctx context.Context) ([]*pb.APIKey, error)
CreateAPIKey(ctx context.Context, name string) (*pb.APIKey, string, error) // returns key + full secret
DeleteAPIKey(ctx context.Context, id string) error
// Secrets
ListSecrets(ctx context.Context, search string) ([]*pb.Secret, error)
CreateSecret(ctx context.Context, name, value string) (*pb.Secret, error)
DeleteSecret(ctx context.Context, id string) error
// Quotas
ListQuotas(ctx context.Context, search string) ([]*pb.Quota, error)
// Provision
// GetProvision retrieves a stored provision result by provision ID.
// Returns nil and a NotFound error if the key doesn't exist.
GetProvision(ctx context.Context, provisionId string) (*types.ProvisionResult, error)
// GetProvisionByIdempotencyKey retrieves a stored provision result by idempotency key.
// Returns nil and a NotFound error if the key doesn't exist.
GetProvisionByIdempotencyKey(ctx context.Context, idempotencyKey string) (*types.ProvisionResult, error)
// UpsertProvision inserts/updates a provision result with the given idempotency key.
UpsertProvision(ctx context.Context, result *types.ProvisionResult) error
// UpdateProvisionStatus updates the status of a provision result.
UpdateProvisionStatus(ctx context.Context, provisionId string, status types.ProvisionStatus) error
// DeleteProvision marks a stored provision result by provision ID as deleted.
DeleteProvision(ctx context.Context, provisionId string) error
// ExistsProvision checks if a provision exists for the given provision ID.
ExistsProvision(ctx context.Context, provisionId string) (bool, error)
// ListProvisions lists stored provision results.
ListProvisions(ctx context.Context, options *types.ListOptions) ([]*types.ProvisionResult, error)
// Close closes the store.
Close() error
}
Store defines the storage interface for all console entities.
func NewFromURI ¶
func NewFromURI(uri, secretKey string, injector error_injection.Injector) (Store, error)
NewFromURI dispatches to a Store implementation based on the URI scheme. Supported forms:
sqlite:/absolute/path.db → file-backed SQLite sqlite:///absolute/path.db → same, URL form sqlite:file:/path/to/db?cache=shared → raw SQLite driver DSN mysql://user:pass@host:3306/db?param=value → MySQL via go-sql-driver/mysql memory:// → in-process in-memory SQLite (test/throwaway)
The "sqlite:" prefix is stripped and the remainder is forwarded to the SQLite driver verbatim, so any DSN form the driver accepts (file paths, URI-form options) works without bespoke parsing. For in-memory storage use memory:// — production deployments should use sqlite: or mysql://.
secretKey is forwarded to backends that encrypt stored secrets at rest.