rdev/internal/port/session_repository.go
jordan 9226454b85
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
feat: label-based undeploy, GC reconciliation, checkout/sessions, pool status
- Add UndeployAll() using label selectors to clean up monorepo components
  on project deletion (replaces name-based Undeploy in DeleteProject and
  the direct undeploy handler)
- Add ResourceGC background worker that periodically finds K8s resources
  whose project label has no matching DB record, deletes after 1h safety
  window
- Widen deployer client type from *kubernetes.Clientset to
  kubernetes.Interface for testability
- UndeployAll accumulates errors via errors.Join instead of failing fast
- Add checkout/checkin sidecar dev flow: temporary git tokens, branch
  checkout, review on checkin with cleanup workers
- Add interactive sessions: pod binding, command execution, SSE streaming,
  ephemeral preview URLs with session cleanup workers
- Add GET /workers/pool endpoint for aggregate capacity and queue depth
- Add sessions:read and sessions:execute auth scopes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 19:11:28 -07:00

30 lines
1.0 KiB
Go

// Package port defines interfaces (ports) for external dependencies.
package port
import (
"context"
"github.com/orchard9/rdev/internal/domain"
)
// SessionRepository manages session persistence.
type SessionRepository interface {
// Create stores a new session record.
Create(ctx context.Context, session *domain.Session) error
// Get retrieves a session by ID.
Get(ctx context.Context, id domain.SessionID) (*domain.Session, error)
// GetActiveByProject retrieves the active session for a project (at most one).
GetActiveByProject(ctx context.Context, projectID domain.ProjectID) (*domain.Session, error)
// ListByProject returns all sessions for a project, ordered by created_at DESC.
ListByProject(ctx context.Context, projectID domain.ProjectID) ([]*domain.Session, error)
// SetEnded marks a session as ended with a timestamp.
SetEnded(ctx context.Context, id domain.SessionID) error
// CleanupExpired marks expired sessions and returns them for preview teardown.
CleanupExpired(ctx context.Context) ([]*domain.Session, error)
}