Documentation
¶
Index ¶
- func AddOrgMember(ctx context.Context, db *sqlx.DB, m *models.OrgMember) error
- func Connect(cfg config.DatabaseConfig) (*sqlx.DB, error)
- func CountAPIKeys(ctx context.Context, db *sqlx.DB) (int, error)
- func CountActiveSessionsByActor(ctx context.Context, db *sqlx.DB, actor string) (int, error)
- func CountArtifacts(ctx context.Context, db *sqlx.DB, actor string) (int, error)
- func CountAuditLogs(ctx context.Context, db *sqlx.DB, sessionID *uuid.UUID, actor string) (int, error)
- func CountFiles(ctx context.Context, db *sqlx.DB, sessionID uuid.UUID) (int, error)
- func CountOrgSessions(ctx context.Context, db *sqlx.DB, orgID uuid.UUID) (int, error)
- func CountOrgs(ctx context.Context, db *sqlx.DB) (int, error)
- func CountRuns(ctx context.Context, db *sqlx.DB, sessionID uuid.UUID) (int, error)
- func CountRunsGlobal(ctx context.Context, db *sqlx.DB) (int, error)
- func CountSessions(ctx context.Context, db *sqlx.DB) (int, error)
- func CountSessionsFiltered(ctx context.Context, db *sqlx.DB, actor, labelKey, labelValue string) (int, error)
- func CountSessionsForActor(ctx context.Context, db *sqlx.DB, actor, labelKey, labelValue string) (int, error)
- func CreateAPIKey(ctx context.Context, db *sqlx.DB, k *models.APIKey) error
- func CreateArtifact(ctx context.Context, db *sqlx.DB, a *models.SharedArtifact) error
- func CreateAuditLog(ctx context.Context, db *sqlx.DB, a *models.AuditLog) error
- func CreateOrg(ctx context.Context, db *sqlx.DB, o *models.Organization) error
- func CreateRun(ctx context.Context, db *sqlx.DB, r *models.Run) error
- func CreateSession(ctx context.Context, db *sqlx.DB, s *models.Session) error
- func CreateSnapshot(ctx context.Context, db *sqlx.DB, s *models.Snapshot) error
- func DeleteArtifact(ctx context.Context, db *sqlx.DB, id uuid.UUID) (string, error)
- func DeleteFile(ctx context.Context, db *sqlx.DB, sessionID uuid.UUID, path string) error
- func DeleteOldAuditLogs(ctx context.Context, db *sqlx.DB, before time.Time) (int64, error)
- func DeleteOrg(ctx context.Context, db *sqlx.DB, id uuid.UUID) error
- func DeleteSnapshot(ctx context.Context, db *sqlx.DB, id uuid.UUID) (string, error)
- func FailStalePendingRuns(ctx context.Context, db *sqlx.DB, before time.Time) (int64, error)
- func GetAPIKeyByHash(ctx context.Context, db *sqlx.DB, keyHash string) (*models.APIKey, error)
- func GetActorOrgs(ctx context.Context, db *sqlx.DB, principal string) ([]*models.OrgMember, error)
- func GetArtifact(ctx context.Context, db *sqlx.DB, id uuid.UUID) (*models.SharedArtifact, error)
- func GetFile(ctx context.Context, db *sqlx.DB, sessionID uuid.UUID, path string) (*models.File, error)
- func GetOrg(ctx context.Context, db *sqlx.DB, id uuid.UUID) (*models.Organization, error)
- func GetOrgBySlug(ctx context.Context, db *sqlx.DB, slug string) (*models.Organization, error)
- func GetOrgMember(ctx context.Context, db *sqlx.DB, orgID uuid.UUID, principal string) (*models.OrgMember, error)
- func GetOrgMemberRole(ctx context.Context, db *sqlx.DB, orgID uuid.UUID, principal string) (string, error)
- func GetRun(ctx context.Context, db *sqlx.DB, id uuid.UUID) (*models.Run, error)
- func GetSession(ctx context.Context, db *sqlx.DB, id uuid.UUID) (*models.Session, error)
- func GetSnapshot(ctx context.Context, db *sqlx.DB, id uuid.UUID) (*models.Snapshot, error)
- func ListAPIKeys(ctx context.Context, db *sqlx.DB) ([]*models.APIKey, error)
- func ListActiveSessions(ctx context.Context, db *sqlx.DB) ([]*models.Session, error)
- func ListArtifacts(ctx context.Context, db *sqlx.DB, actor string, limit, offset int) ([]*models.SharedArtifact, error)
- func ListAuditLogs(ctx context.Context, db *sqlx.DB, sessionID *uuid.UUID, actor string, ...) ([]*models.AuditLog, error)
- func ListAuditSince(ctx context.Context, db *sqlx.DB, since time.Time, limit int) ([]models.AuditLog, error)
- func ListFiles(ctx context.Context, db *sqlx.DB, sessionID uuid.UUID) ([]*models.File, error)
- func ListOrgMembers(ctx context.Context, db *sqlx.DB, orgID uuid.UUID) ([]*models.OrgMember, error)
- func ListOrgSessions(ctx context.Context, db *sqlx.DB, orgID uuid.UUID, limit, offset int) ([]*models.Session, error)
- func ListOrgs(ctx context.Context, db *sqlx.DB, limit, offset int) ([]*models.Organization, error)
- func ListRuns(ctx context.Context, db *sqlx.DB, sessionID uuid.UUID, limit, offset int) ([]*models.Run, error)
- func ListSessions(ctx context.Context, db *sqlx.DB, actor, labelKey, labelValue string, ...) ([]*models.Session, error)
- func ListSessionsForActor(ctx context.Context, db *sqlx.DB, actor, labelKey, labelValue string, ...) ([]*models.Session, error)
- func ListSnapshots(ctx context.Context, db *sqlx.DB, sessionID uuid.UUID) ([]*models.Snapshot, error)
- func RemoveOrgMember(ctx context.Context, db *sqlx.DB, orgID uuid.UUID, principal string) error
- func RevokeAPIKey(ctx context.Context, db *sqlx.DB, id uuid.UUID) error
- func RunMigrations(db *sqlx.DB, migrationsPath string) error
- func StopSession(ctx context.Context, db *sqlx.DB, id uuid.UUID) error
- func SumWorkspaceBytes(ctx context.Context, db *sqlx.DB, sessionID uuid.UUID) (int64, error)
- func TotalArtifactBytes(ctx context.Context, db *sqlx.DB, actor string) (int64, error)
- func UpdateAPIKeyLastUsed(ctx context.Context, db *sqlx.DB, id uuid.UUID) error
- func UpdateRun(ctx context.Context, db *sqlx.DB, p UpdateRunParams) error
- func UpdateSessionLabels(ctx context.Context, db *sqlx.DB, id uuid.UUID, labels models.JSONB) error
- func UpdateSessionStatus(ctx context.Context, db *sqlx.DB, id uuid.UUID, status string, ...) error
- func UpsertFile(ctx context.Context, db *sqlx.DB, f *models.File) error
- type UpdateRunParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CountActiveSessionsByActor ¶
CountActiveSessionsByActor returns the number of active (not stopped) sessions for a given actor. Used to enforce per-actor session limits.
func CountArtifacts ¶
func CountAuditLogs ¶
func CountAuditLogs(ctx context.Context, db *sqlx.DB, sessionID *uuid.UUID, actor string) (int, error)
CountAuditLogs mirrors the filter logic of ListAuditLogs for accurate totals.
func CountFiles ¶
func CountOrgSessions ¶
func CountSessionsFiltered ¶
func CountSessionsFiltered(ctx context.Context, db *sqlx.DB, actor, labelKey, labelValue string) (int, error)
CountSessionsFiltered returns the number of active sessions matching the same filters as ListSessions (actor + optional label key/value).
func CountSessionsForActor ¶
func CountSessionsForActor(ctx context.Context, db *sqlx.DB, actor, labelKey, labelValue string) (int, error)
CountSessionsForActor mirrors ListSessionsForActor for pagination totals.
func CreateArtifact ¶
func CreateAuditLog ¶
func CreateSnapshot ¶
func DeleteArtifact ¶
func DeleteFile ¶
func DeleteOldAuditLogs ¶
DeleteOldAuditLogs removes audit log entries whose timestamp is older than the given cutoff. Returns the number of rows deleted. Called by the background cleanup goroutine when AUDIT_LOG_RETENTION_DAYS > 0.
func DeleteSnapshot ¶
func FailStalePendingRuns ¶
FailStalePendingRuns marks as "failed" any runs that are still in the "pending" state and were created before the given cutoff timestamp.
This is called at startup to clean up runs that were mid-flight when the previous server instance was killed (e.g., a crash or SIGKILL during an in-memory queue drain). Without this cleanup, such runs sit in "pending" forever and are never surfaced to callers as failures.
For the Redis Streams backend, the reaper goroutine handles re-delivery; this function is a last-resort safety net for both queue backends.
func GetAPIKeyByHash ¶
func GetActorOrgs ¶
GetActorOrgs returns all org memberships for the given actor.
func GetArtifact ¶
func GetOrgBySlug ¶
func GetOrgMember ¶
func GetOrgMemberRole ¶
func GetOrgMemberRole(ctx context.Context, db *sqlx.DB, orgID uuid.UUID, principal string) (string, error)
GetOrgMemberRole returns the role for the given actor in the given org, or sql.ErrNoRows if they are not a member.
func GetSession ¶
func GetSnapshot ¶
func ListActiveSessions ¶
ListActiveSessions returns sessions that are still running (for cleanup jobs).
func ListArtifacts ¶
func ListAuditLogs ¶
func ListAuditLogs(ctx context.Context, db *sqlx.DB, sessionID *uuid.UUID, actor string, limit, offset int) ([]*models.AuditLog, error)
ListAuditLogs returns audit log entries. When actor is non-empty only that actor's log entries are returned (tenant isolation). When sessionID is set it takes precedence. Master key passes actor="". Initialises the slice to non-nil so JSON always encodes [] instead of null.
func ListAuditSince ¶
func ListAuditSince(ctx context.Context, db *sqlx.DB, since time.Time, limit int) ([]models.AuditLog, error)
ListAuditSince returns up to limit audit entries created after since, ordered by timestamp ASC.
func ListOrgMembers ¶
func ListOrgSessions ¶
func ListOrgSessions(ctx context.Context, db *sqlx.DB, orgID uuid.UUID, limit, offset int) ([]*models.Session, error)
ListOrgSessions returns active sessions belonging to the given org.
func ListSessions ¶
func ListSessions(ctx context.Context, db *sqlx.DB, actor, labelKey, labelValue string, limit, offset int) ([]*models.Session, error)
ListSessions returns active sessions. When actor is non-empty only that actor's sessions are returned (tenant isolation). Master key passes "". labelKey/labelValue optionally filter by a specific label (both must be set). Initialises the slice to non-nil so JSON always encodes [] instead of null.
func ListSessionsForActor ¶
func ListSessionsForActor(ctx context.Context, db *sqlx.DB, actor, labelKey, labelValue string, limit, offset int) ([]*models.Session, error)
ListSessionsForActor returns all active sessions visible to the actor: own sessions UNION sessions in any org the actor belongs to. When actor is empty (master), all sessions are returned.
func ListSnapshots ¶
func RemoveOrgMember ¶
func SumWorkspaceBytes ¶
SumWorkspaceBytes returns the total size in bytes of all files tracked for the given session. Used by the upload handler to enforce MAX_WORKSPACE_MB.
func TotalArtifactBytes ¶
TotalArtifactBytes returns the sum of size_bytes for all artifacts owned by actor. Pass an empty actor to sum across all actors (master use).
func UpdateAPIKeyLastUsed ¶
func UpdateSessionLabels ¶
UpdateSessionLabels replaces the labels map for a session.