rdev/internal/port/checkout_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

39 lines
1.5 KiB
Go

// Package port defines interfaces (ports) for external dependencies.
package port
import (
"context"
"github.com/orchard9/rdev/internal/domain"
)
// CheckoutRepository manages checkout persistence.
type CheckoutRepository interface {
// Create stores a new checkout record.
Create(ctx context.Context, checkout *domain.Checkout) error
// Get retrieves a checkout by ID.
Get(ctx context.Context, id domain.CheckoutID) (*domain.Checkout, error)
// GetByProjectBranch retrieves an active checkout for a project+branch.
GetByProjectBranch(ctx context.Context, projectID domain.ProjectID, branch string) (*domain.Checkout, error)
// List returns checkouts matching the given options.
List(ctx context.Context, opts domain.CheckoutListOptions) ([]*domain.Checkout, error)
// ListByProject returns all checkouts for a project.
ListByProject(ctx context.Context, projectID domain.ProjectID) ([]*domain.Checkout, error)
// UpdateStatus updates the status of a checkout.
UpdateStatus(ctx context.Context, id domain.CheckoutID, status domain.CheckoutStatus) error
// SetCheckedIn marks a checkout as checked in with timestamp.
SetCheckedIn(ctx context.Context, id domain.CheckoutID, reviewTaskID string) error
// SetReviewTask sets the review task ID for a checkout.
SetReviewTask(ctx context.Context, id domain.CheckoutID, taskID string) error
// CleanupExpired marks expired checkouts and returns their Gitea token IDs for revocation.
CleanupExpired(ctx context.Context) ([]int64, error)
}