Documentation
¶
Index ¶
- type AcquireCertmagicLockParams
- type Build
- type BuildClaimLeaseParams
- type BuildCreateParams
- type BuildLog
- type BuildLogCreateParams
- type BuildMarkBuildingParams
- type BuildMarkSuccessfulParams
- type BuildReleaseLeaseParams
- type BuildStatus
- type CertmagicDatum
- type CertmagicLock
- type DBTX
- type Deployment
- type DeploymentFindRunningAndOlderParams
- type DeploymentStatus
- type DeploymentUpdateBuildParams
- type DeploymentUpdateImageParams
- type DeploymentUpdateVMParams
- type Domain
- type DomainFindActiveByNameParams
- type DomainUpdateDeploymentForProjectParams
- type EnvironmentVariable
- type EnvironmentVariableFindByProjectIDRow
- type GithubInstallation
- type Image
- type ImageCreateParams
- type ImageFindByRepositoryAndTagParams
- type ImageFindOrCreateParams
- type ImageFindOrCreateRow
- type NullBuildStatus
- type NullDeploymentStatus
- type NullServerStatus
- type NullVmStatus
- type Organisation
- type OrganisationMember
- type Project
- type Queries
- func (q *Queries) AcquireCertmagicLock(ctx context.Context, arg AcquireCertmagicLockParams) (int64, error)
- func (q *Queries) AdvisoryLock(ctx context.Context, hashtext string) error
- func (q *Queries) BuildClaimLease(ctx context.Context, arg BuildClaimLeaseParams) (Build, error)
- func (q *Queries) BuildCreate(ctx context.Context, arg BuildCreateParams) (Build, error)
- func (q *Queries) BuildFind(ctx context.Context) ([]Build, error)
- func (q *Queries) BuildFindByVMID(ctx context.Context, vmID uuid.UUID) ([]Build, error)
- func (q *Queries) BuildFindWaitingForBuildImage(ctx context.Context) ([]Build, error)
- func (q *Queries) BuildFirstByID(ctx context.Context, id uuid.UUID) (Build, error)
- func (q *Queries) BuildFirstPending(ctx context.Context) (Build, error)
- func (q *Queries) BuildLogCreate(ctx context.Context, arg BuildLogCreateParams) error
- func (q *Queries) BuildMarkBuilding(ctx context.Context, arg BuildMarkBuildingParams) error
- func (q *Queries) BuildMarkFailed(ctx context.Context, id uuid.UUID) error
- func (q *Queries) BuildMarkSuccessful(ctx context.Context, arg BuildMarkSuccessfulParams) error
- func (q *Queries) BuildReleaseLease(ctx context.Context, arg BuildReleaseLeaseParams) error
- func (q *Queries) CleanupExpiredCertmagicLocks(ctx context.Context) error
- func (q *Queries) DeleteCertmagicData(ctx context.Context, key string) (int64, error)
- func (q *Queries) DeploymentFind(ctx context.Context) ([]Deployment, error)
- func (q *Queries) DeploymentFindByBuildID(ctx context.Context, buildID uuid.UUID) ([]Deployment, error)
- func (q *Queries) DeploymentFindByVMID(ctx context.Context, vmID uuid.UUID) (Deployment, error)
- func (q *Queries) DeploymentFindNewest(ctx context.Context, projectID uuid.UUID) (Deployment, error)
- func (q *Queries) DeploymentFindRunningAndOlder(ctx context.Context, arg DeploymentFindRunningAndOlderParams) ([]Deployment, error)
- func (q *Queries) DeploymentFindRunningByServerID(ctx context.Context, serverID uuid.UUID) ([]Deployment, error)
- func (q *Queries) DeploymentFirstByID(ctx context.Context, id uuid.UUID) (Deployment, error)
- func (q *Queries) DeploymentFirstPending(ctx context.Context) (Deployment, error)
- func (q *Queries) DeploymentMarkRunning(ctx context.Context, id uuid.UUID) error
- func (q *Queries) DeploymentMarkStopped(ctx context.Context, id uuid.UUID) error
- func (q *Queries) DeploymentUpdateBuild(ctx context.Context, arg DeploymentUpdateBuildParams) (Deployment, error)
- func (q *Queries) DeploymentUpdateFailedAt(ctx context.Context, id uuid.UUID) error
- func (q *Queries) DeploymentUpdateImage(ctx context.Context, arg DeploymentUpdateImageParams) (Deployment, error)
- func (q *Queries) DeploymentUpdateVM(ctx context.Context, arg DeploymentUpdateVMParams) (Deployment, error)
- func (q *Queries) DomainFind(ctx context.Context) ([]Domain, error)
- func (q *Queries) DomainFindActiveByName(ctx context.Context, arg DomainFindActiveByNameParams) ([]Domain, error)
- func (q *Queries) DomainFirstByID(ctx context.Context, id uuid.UUID) (Domain, error)
- func (q *Queries) DomainListUnverified(ctx context.Context) ([]Domain, error)
- func (q *Queries) DomainMarkVerified(ctx context.Context, id uuid.UUID) error
- func (q *Queries) DomainSoftDelete(ctx context.Context, id uuid.UUID) error
- func (q *Queries) DomainUpdateDeploymentForProject(ctx context.Context, arg DomainUpdateDeploymentForProjectParams) error
- func (q *Queries) DomainVerified(ctx context.Context, name string) (pgtype.Timestamptz, error)
- func (q *Queries) EnvironmentVariableFindByProjectID(ctx context.Context, projectID uuid.UUID) ([]EnvironmentVariableFindByProjectIDRow, error)
- func (q *Queries) ExistsCertmagicData(ctx context.Context, key string) (bool, error)
- func (q *Queries) GithubInstallationFindByID(ctx context.Context, id uuid.UUID) (GithubInstallation, error)
- func (q *Queries) ImageCreate(ctx context.Context, arg ImageCreateParams) (Image, error)
- func (q *Queries) ImageFind(ctx context.Context) ([]Image, error)
- func (q *Queries) ImageFindByID(ctx context.Context, id uuid.UUID) (Image, error)
- func (q *Queries) ImageFindByRepositoryAndTag(ctx context.Context, arg ImageFindByRepositoryAndTagParams) (Image, error)
- func (q *Queries) ImageFindOrCreate(ctx context.Context, arg ImageFindOrCreateParams) (ImageFindOrCreateRow, error)
- func (q *Queries) ListCertmagicDataNonRecursive(ctx context.Context, dollar_1 pgtype.Text) ([]string, error)
- func (q *Queries) ListCertmagicDataRecursive(ctx context.Context, dollar_1 pgtype.Text) ([]string, error)
- func (q *Queries) LoadCertmagicData(ctx context.Context, key string) (CertmagicDatum, error)
- func (q *Queries) ProjectFirstByID(ctx context.Context, id uuid.UUID) (Project, error)
- func (q *Queries) ReleaseCertmagicLock(ctx context.Context, key string) (int64, error)
- func (q *Queries) ReleaseSessionAdvisoryLock(ctx context.Context, hashtext string) (bool, error)
- func (q *Queries) RouteFindActive(ctx context.Context) ([]RouteFindActiveRow, error)
- func (q *Queries) ServerAllocateIPRange(ctx context.Context) (netip.Prefix, error)
- func (q *Queries) ServerFindActive(ctx context.Context) ([]Server, error)
- func (q *Queries) ServerFindByID(ctx context.Context, id uuid.UUID) (Server, error)
- func (q *Queries) ServerFindDead(ctx context.Context) ([]Server, error)
- func (q *Queries) ServerFindLeastLoaded(ctx context.Context) (ServerFindLeastLoadedRow, error)
- func (q *Queries) ServerHeartbeat(ctx context.Context, id uuid.UUID) error
- func (q *Queries) ServerRegister(ctx context.Context, arg ServerRegisterParams) (Server, error)
- func (q *Queries) ServerSetDrained(ctx context.Context, id uuid.UUID) error
- func (q *Queries) ServerUpdateStatus(ctx context.Context, arg ServerUpdateStatusParams) error
- func (q *Queries) StatCertmagicData(ctx context.Context, key string) (CertmagicDatum, error)
- func (q *Queries) StoreCertmagicData(ctx context.Context, arg StoreCertmagicDataParams) error
- func (q *Queries) TryAdvisoryLock(ctx context.Context, hashtext string) (bool, error)
- func (q *Queries) TrySessionAdvisoryLock(ctx context.Context, hashtext string) (bool, error)
- func (q *Queries) VMCreate(ctx context.Context, arg VMCreateParams) (Vm, error)
- func (q *Queries) VMFind(ctx context.Context) ([]Vm, error)
- func (q *Queries) VMFindByImageID(ctx context.Context, imageID uuid.UUID) ([]Vm, error)
- func (q *Queries) VMFindByServerID(ctx context.Context, serverID uuid.UUID) ([]Vm, error)
- func (q *Queries) VMFirstByID(ctx context.Context, id uuid.UUID) (Vm, error)
- func (q *Queries) VMLogCreate(ctx context.Context, arg VMLogCreateParams) error
- func (q *Queries) VMNextIPAddress(ctx context.Context, arg VMNextIPAddressParams) (netip.Prefix, error)
- func (q *Queries) VMSoftDelete(ctx context.Context, id uuid.UUID) error
- func (q *Queries) VMUpdateStatus(ctx context.Context, arg VMUpdateStatusParams) (Vm, error)
- func (q *Queries) WithTx(tx pgx.Tx) *Queries
- type RouteFindActiveRow
- type Server
- type ServerFindLeastLoadedRow
- type ServerRegisterParams
- type ServerStatus
- type ServerUpdateStatusParams
- type StoreCertmagicDataParams
- type User
- type VMCreateParams
- type VMLogCreateParams
- type VMNextIPAddressParams
- type VMUpdateStatusParams
- type Vm
- type VmLog
- type VmStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AcquireCertmagicLockParams ¶
type AcquireCertmagicLockParams struct {
Key string `json:"key"`
Expires pgtype.Timestamptz `json:"expires"`
}
type Build ¶
type Build struct {
ID uuid.UUID `json:"id"`
Status BuildStatus `json:"status"`
ProjectID uuid.UUID `json:"project_id"`
GithubCommit string `json:"github_commit"`
GithubBranch string `json:"github_branch"`
ImageID uuid.UUID `json:"image_id"`
VmID uuid.UUID `json:"vm_id"`
PendingAt pgtype.Timestamptz `json:"pending_at"`
BuildingAt pgtype.Timestamptz `json:"building_at"`
SuccessfulAt pgtype.Timestamptz `json:"successful_at"`
FailedAt pgtype.Timestamptz `json:"failed_at"`
OrganisationID uuid.UUID `json:"organisation_id"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
ProcessingBy uuid.UUID `json:"processing_by"`
ProcessingStartedAt pgtype.Timestamptz `json:"processing_started_at"`
}
type BuildClaimLeaseParams ¶
type BuildCreateParams ¶
type BuildLogCreateParams ¶
type BuildMarkBuildingParams ¶
type BuildReleaseLeaseParams ¶
type BuildStatus ¶
type BuildStatus string
const ( BuildStatusPending BuildStatus = "pending" BuildStatusBuilding BuildStatus = "building" BuildStatusSuccesful BuildStatus = "succesful" BuildStatusFailed BuildStatus = "failed" )
func (*BuildStatus) Scan ¶
func (e *BuildStatus) Scan(src interface{}) error
type CertmagicDatum ¶
type CertmagicDatum struct {
Key string `json:"key"`
Value string `json:"value"`
Modified pgtype.Timestamptz `json:"modified"`
}
type CertmagicLock ¶
type CertmagicLock struct {
Key string `json:"key"`
Expires pgtype.Timestamptz `json:"expires"`
}
type Deployment ¶
type Deployment struct {
ID uuid.UUID `json:"id"`
Status DeploymentStatus `json:"status"`
GithubCommit string `json:"github_commit"`
ProjectID uuid.UUID `json:"project_id"`
BuildID uuid.UUID `json:"build_id"`
ImageID uuid.UUID `json:"image_id"`
VmID uuid.UUID `json:"vm_id"`
PendingAt pgtype.Timestamptz `json:"pending_at"`
BuildingAt pgtype.Timestamptz `json:"building_at"`
StartingAt pgtype.Timestamptz `json:"starting_at"`
RunningAt pgtype.Timestamptz `json:"running_at"`
StoppingAt pgtype.Timestamptz `json:"stopping_at"`
StoppedAt pgtype.Timestamptz `json:"stopped_at"`
FailedAt pgtype.Timestamptz `json:"failed_at"`
OrganisationID uuid.UUID `json:"organisation_id"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}
type DeploymentStatus ¶
type DeploymentStatus string
const ( DeploymentStatusPending DeploymentStatus = "pending" DeploymentStatusBuilding DeploymentStatus = "building" DeploymentStatusStarting DeploymentStatus = "starting" DeploymentStatusRunning DeploymentStatus = "running" DeploymentStatusStopping DeploymentStatus = "stopping" DeploymentStatusStopped DeploymentStatus = "stopped" DeploymentStatusFailed DeploymentStatus = "failed" )
func (*DeploymentStatus) Scan ¶
func (e *DeploymentStatus) Scan(src interface{}) error
type Domain ¶
type Domain struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
ProjectID uuid.UUID `json:"project_id"`
DeploymentID uuid.UUID `json:"deployment_id"`
VerifiedAt pgtype.Timestamptz `json:"verified_at"`
OrganisationID uuid.UUID `json:"organisation_id"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
TxtVerificationRequired bool `json:"txt_verification_required"`
RedirectTo pgtype.Text `json:"redirect_to"`
RedirectStatusCode pgtype.Int4 `json:"redirect_status_code"`
}
type EnvironmentVariable ¶
type EnvironmentVariable struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Value string `json:"value"`
ProjectID uuid.UUID `json:"project_id"`
OrganisationID uuid.UUID `json:"organisation_id"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}
type GithubInstallation ¶
type GithubInstallation struct {
ID uuid.UUID `json:"id"`
UserID uuid.UUID `json:"user_id"`
GithubAccountID int32 `json:"github_account_id"`
GithubInstallationID int32 `json:"github_installation_id"`
OrganisationID uuid.UUID `json:"organisation_id"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}
type Image ¶
type Image struct {
ID uuid.UUID `json:"id"`
Registry string `json:"registry"`
Repository string `json:"repository"`
Tag string `json:"tag"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}
type ImageCreateParams ¶
type ImageFindOrCreateParams ¶
type ImageFindOrCreateRow ¶
type ImageFindOrCreateRow struct {
ID uuid.UUID `json:"id"`
Registry string `json:"registry"`
Repository string `json:"repository"`
Tag string `json:"tag"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}
type NullBuildStatus ¶
type NullBuildStatus struct {
BuildStatus BuildStatus `json:"build_status"`
Valid bool `json:"valid"` // Valid is true if BuildStatus is not NULL
}
func (*NullBuildStatus) Scan ¶
func (ns *NullBuildStatus) Scan(value interface{}) error
Scan implements the Scanner interface.
type NullDeploymentStatus ¶
type NullDeploymentStatus struct {
DeploymentStatus DeploymentStatus `json:"deployment_status"`
Valid bool `json:"valid"` // Valid is true if DeploymentStatus is not NULL
}
func (*NullDeploymentStatus) Scan ¶
func (ns *NullDeploymentStatus) Scan(value interface{}) error
Scan implements the Scanner interface.
type NullServerStatus ¶
type NullServerStatus struct {
ServerStatus ServerStatus `json:"server_status"`
Valid bool `json:"valid"` // Valid is true if ServerStatus is not NULL
}
func (*NullServerStatus) Scan ¶
func (ns *NullServerStatus) Scan(value interface{}) error
Scan implements the Scanner interface.
type NullVmStatus ¶
type NullVmStatus struct {
VmStatus VmStatus `json:"vm_status"`
Valid bool `json:"valid"` // Valid is true if VmStatus is not NULL
}
func (*NullVmStatus) Scan ¶
func (ns *NullVmStatus) Scan(value interface{}) error
Scan implements the Scanner interface.
type Organisation ¶
type Organisation struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Slug string `json:"slug"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
ProjectLimit int32 `json:"project_limit"`
}
type OrganisationMember ¶
type OrganisationMember struct {
ID uuid.UUID `json:"id"`
UserID uuid.UUID `json:"user_id"`
OrganisationID uuid.UUID `json:"organisation_id"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}
type Project ¶
type Project struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Slug string `json:"slug"`
GithubRepository string `json:"github_repository"`
GithubInstallationID uuid.UUID `json:"github_installation_id"`
OrganisationID uuid.UUID `json:"organisation_id"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
RootDirectory string `json:"root_directory"`
DockerfilePath string `json:"dockerfile_path"`
}
type Queries ¶
type Queries struct {
// contains filtered or unexported fields
}
func (*Queries) AcquireCertmagicLock ¶
func (q *Queries) AcquireCertmagicLock(ctx context.Context, arg AcquireCertmagicLockParams) (int64, error)
Attempts to acquire a lock for a key
func (*Queries) AdvisoryLock ¶
Try to acquire a transaction-scoped advisory lock (non-blocking). Returns true if the lock was acquired, false if another session holds it.
func (*Queries) BuildClaimLease ¶
Atomically claim a build lease for processing on a server. Succeeds if the build is pending/building and either unclaimed, already claimed by this server, or the previous lease is stale.
func (*Queries) BuildCreate ¶
func (*Queries) BuildFindByVMID ¶
func (*Queries) BuildFindWaitingForBuildImage ¶
func (*Queries) BuildFirstByID ¶
func (*Queries) BuildFirstPending ¶
func (*Queries) BuildLogCreate ¶
func (q *Queries) BuildLogCreate(ctx context.Context, arg BuildLogCreateParams) error
func (*Queries) BuildMarkBuilding ¶
func (q *Queries) BuildMarkBuilding(ctx context.Context, arg BuildMarkBuildingParams) error
func (*Queries) BuildMarkFailed ¶
func (*Queries) BuildMarkSuccessful ¶
func (q *Queries) BuildMarkSuccessful(ctx context.Context, arg BuildMarkSuccessfulParams) error
func (*Queries) BuildReleaseLease ¶
func (q *Queries) BuildReleaseLease(ctx context.Context, arg BuildReleaseLeaseParams) error
Release a build processing lease if it's still owned by this server.
func (*Queries) CleanupExpiredCertmagicLocks ¶
Removes expired locks
func (*Queries) DeleteCertmagicData ¶
Deletes a certmagic data entry by key
func (*Queries) DeploymentFind ¶
func (q *Queries) DeploymentFind(ctx context.Context) ([]Deployment, error)
func (*Queries) DeploymentFindByBuildID ¶
func (*Queries) DeploymentFindByVMID ¶
func (*Queries) DeploymentFindNewest ¶
func (*Queries) DeploymentFindRunningAndOlder ¶
func (q *Queries) DeploymentFindRunningAndOlder(ctx context.Context, arg DeploymentFindRunningAndOlderParams) ([]Deployment, error)
Find all running deployments for a project, older than the specified deployment
func (*Queries) DeploymentFindRunningByServerID ¶
func (q *Queries) DeploymentFindRunningByServerID(ctx context.Context, serverID uuid.UUID) ([]Deployment, error)
Find all running deployments whose VM is on a specific server.
func (*Queries) DeploymentFirstByID ¶
func (*Queries) DeploymentFirstPending ¶
func (q *Queries) DeploymentFirstPending(ctx context.Context) (Deployment, error)
func (*Queries) DeploymentMarkRunning ¶
func (*Queries) DeploymentMarkStopped ¶
func (*Queries) DeploymentUpdateBuild ¶
func (q *Queries) DeploymentUpdateBuild(ctx context.Context, arg DeploymentUpdateBuildParams) (Deployment, error)
func (*Queries) DeploymentUpdateFailedAt ¶
func (*Queries) DeploymentUpdateImage ¶
func (q *Queries) DeploymentUpdateImage(ctx context.Context, arg DeploymentUpdateImageParams) (Deployment, error)
func (*Queries) DeploymentUpdateVM ¶
func (q *Queries) DeploymentUpdateVM(ctx context.Context, arg DeploymentUpdateVMParams) (Deployment, error)
func (*Queries) DomainFindActiveByName ¶
func (q *Queries) DomainFindActiveByName(ctx context.Context, arg DomainFindActiveByNameParams) ([]Domain, error)
Find all active (non-deleted) domains with a given name, excluding a specific domain ID
func (*Queries) DomainFirstByID ¶
func (*Queries) DomainListUnverified ¶
func (*Queries) DomainMarkVerified ¶
func (*Queries) DomainSoftDelete ¶
func (*Queries) DomainUpdateDeploymentForProject ¶
func (q *Queries) DomainUpdateDeploymentForProject(ctx context.Context, arg DomainUpdateDeploymentForProjectParams) error
Update all custom domains (non-zeitwork.app) for a project to point to a new deployment
func (*Queries) DomainVerified ¶
Checks if a domain exists and is verified (for on-demand certificate issuance)
func (*Queries) EnvironmentVariableFindByProjectID ¶
func (*Queries) ExistsCertmagicData ¶
Checks if a certmagic data entry exists
func (*Queries) GithubInstallationFindByID ¶
func (*Queries) ImageCreate ¶
func (*Queries) ImageFindByID ¶
func (*Queries) ImageFindByRepositoryAndTag ¶
func (*Queries) ImageFindOrCreate ¶
func (q *Queries) ImageFindOrCreate(ctx context.Context, arg ImageFindOrCreateParams) (ImageFindOrCreateRow, error)
func (*Queries) ListCertmagicDataNonRecursive ¶
func (q *Queries) ListCertmagicDataNonRecursive(ctx context.Context, dollar_1 pgtype.Text) ([]string, error)
Lists certmagic data keys with a given prefix (non-recursive - no additional slashes)
func (*Queries) ListCertmagicDataRecursive ¶
func (q *Queries) ListCertmagicDataRecursive(ctx context.Context, dollar_1 pgtype.Text) ([]string, error)
Lists all certmagic data keys with a given prefix (recursive)
func (*Queries) LoadCertmagicData ¶
Loads a certmagic data entry by key
func (*Queries) ProjectFirstByID ¶
func (*Queries) ReleaseCertmagicLock ¶
Releases a lock for a key
func (*Queries) ReleaseSessionAdvisoryLock ¶
Release a session-scoped advisory lock.
func (*Queries) RouteFindActive ¶
func (q *Queries) RouteFindActive(ctx context.Context) ([]RouteFindActiveRow, error)
Domains -> Deployment -> VM -> Server Returns routes with server info so the edge proxy knows which server hosts each VM. With L2 routing between servers, the edge proxy can reach any VM directly by IP.
func (*Queries) ServerAllocateIPRange ¶
Allocate the next available /20 IP range for a new server. First server gets 10.1.0.0/20, second gets 10.1.16.0/20, etc. Each /20 contains 4096 addresses (2048 VMs with /31 pairs).
func (*Queries) ServerFindActive ¶
Find all servers that are active and have heartbeated recently (within 30s).
func (*Queries) ServerFindByID ¶
func (*Queries) ServerFindDead ¶
Find servers whose heartbeat has expired (no heartbeat for 60s). Used by the failover detector to identify dead servers.
func (*Queries) ServerFindLeastLoaded ¶
func (q *Queries) ServerFindLeastLoaded(ctx context.Context) (ServerFindLeastLoadedRow, error)
Pick the active server with the fewest non-deleted, non-terminal VMs. Used for placement decisions when creating new VMs.
func (*Queries) ServerHeartbeat ¶
Update the heartbeat timestamp for a server.
func (*Queries) ServerRegister ¶
Upsert a server record. On startup, a server registers itself. If it already exists (e.g., after restart), update heartbeat and status.
func (*Queries) ServerSetDrained ¶
Mark a server as drained. All VMs have been migrated off.
func (*Queries) ServerUpdateStatus ¶
func (q *Queries) ServerUpdateStatus(ctx context.Context, arg ServerUpdateStatusParams) error
func (*Queries) StatCertmagicData ¶
Returns metadata about a certmagic data entry
func (*Queries) StoreCertmagicData ¶
func (q *Queries) StoreCertmagicData(ctx context.Context, arg StoreCertmagicDataParams) error
Stores or updates a certmagic data entry
func (*Queries) TryAdvisoryLock ¶
Try to acquire a transaction-scoped advisory lock (non-blocking). Returns true if the lock was acquired, false if another session holds it.
func (*Queries) TrySessionAdvisoryLock ¶
Try to acquire a session-scoped advisory lock (non-blocking). Lock is held until explicitly released or the connection is closed. Used for persistent leader election — run on a dedicated connection.
func (*Queries) VMFindByImageID ¶
func (*Queries) VMFindByServerID ¶
func (*Queries) VMFirstByID ¶
func (*Queries) VMLogCreate ¶
func (q *Queries) VMLogCreate(ctx context.Context, arg VMLogCreateParams) error
func (*Queries) VMNextIPAddress ¶
func (q *Queries) VMNextIPAddress(ctx context.Context, arg VMNextIPAddressParams) (netip.Prefix, error)
Allocate the next /31 subnet within a server's IP range. Each VM needs its own /31 subnet, so we increment by 2 to skip to the next block. The first VM in a range gets base+1 (e.g., 10.1.0.1/31), host side is base+0.
func (*Queries) VMSoftDelete ¶
func (*Queries) VMUpdateStatus ¶
type RouteFindActiveRow ¶
type RouteFindActiveRow struct {
DomainName string `json:"domain_name"`
VmPort pgtype.Int4 `json:"vm_port"`
VmID uuid.UUID `json:"vm_id"`
VmIp netip.Prefix `json:"vm_ip"`
ServerID uuid.UUID `json:"server_id"`
RedirectTo pgtype.Text `json:"redirect_to"`
RedirectStatusCode pgtype.Int4 `json:"redirect_status_code"`
}
type Server ¶
type Server struct {
ID uuid.UUID `json:"id"`
Hostname string `json:"hostname"`
InternalIp string `json:"internal_ip"`
IpRange netip.Prefix `json:"ip_range"`
Status ServerStatus `json:"status"`
LastHeartbeatAt pgtype.Timestamptz `json:"last_heartbeat_at"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}
type ServerFindLeastLoadedRow ¶
type ServerFindLeastLoadedRow struct {
ID uuid.UUID `json:"id"`
Hostname string `json:"hostname"`
InternalIp string `json:"internal_ip"`
IpRange netip.Prefix `json:"ip_range"`
Status ServerStatus `json:"status"`
LastHeartbeatAt pgtype.Timestamptz `json:"last_heartbeat_at"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
VmCount int64 `json:"vm_count"`
}
type ServerRegisterParams ¶
type ServerStatus ¶
type ServerStatus string
const ( ServerStatusActive ServerStatus = "active" ServerStatusDraining ServerStatus = "draining" ServerStatusDrained ServerStatus = "drained" ServerStatusDead ServerStatus = "dead" )
func (*ServerStatus) Scan ¶
func (e *ServerStatus) Scan(src interface{}) error
type ServerUpdateStatusParams ¶
type ServerUpdateStatusParams struct {
ID uuid.UUID `json:"id"`
Status ServerStatus `json:"status"`
}
type StoreCertmagicDataParams ¶
type StoreCertmagicDataParams struct {
Key string `json:"key"`
Value string `json:"value"`
Modified pgtype.Timestamptz `json:"modified"`
}
type User ¶
type User struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
Username string `json:"username"`
ProfilePictureUrl pgtype.Text `json:"profile_picture_url"`
GithubAccountID pgtype.Int4 `json:"github_account_id"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
VerifiedAt pgtype.Timestamptz `json:"verified_at"`
}
type VMCreateParams ¶
type VMCreateParams struct {
ID uuid.UUID `json:"id"`
Vcpus int32 `json:"vcpus"`
Memory int32 `json:"memory"`
Status VmStatus `json:"status"`
ImageID uuid.UUID `json:"image_id"`
ServerID uuid.UUID `json:"server_id"`
Port pgtype.Int4 `json:"port"`
IpAddress netip.Prefix `json:"ip_address"`
EnvVariables pgtype.Text `json:"env_variables"`
Metadata []byte `json:"metadata"`
}
type VMLogCreateParams ¶
type VMNextIPAddressParams ¶
type VMUpdateStatusParams ¶
type Vm ¶
type Vm struct {
ID uuid.UUID `json:"id"`
Vcpus int32 `json:"vcpus"`
Memory int32 `json:"memory"`
Status VmStatus `json:"status"`
ImageID uuid.UUID `json:"image_id"`
Port pgtype.Int4 `json:"port"`
IpAddress netip.Prefix `json:"ip_address"`
Metadata []byte `json:"metadata"`
CreatedAt pgtype.Timestamptz `json:"created_at"`
UpdatedAt pgtype.Timestamptz `json:"updated_at"`
DeletedAt pgtype.Timestamptz `json:"deleted_at"`
PendingAt pgtype.Timestamptz `json:"pending_at"`
StartingAt pgtype.Timestamptz `json:"starting_at"`
RunningAt pgtype.Timestamptz `json:"running_at"`
StoppingAt pgtype.Timestamptz `json:"stopping_at"`
StoppedAt pgtype.Timestamptz `json:"stopped_at"`
FailedAt pgtype.Timestamptz `json:"failed_at"`
EnvVariables pgtype.Text `json:"env_variables"`
ServerID uuid.UUID `json:"server_id"`
}