instance

package
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: AGPL-3.0 Imports: 50 Imported by: 0

Documentation

Overview

Package instance is the Instance admin area (add-on spec 3.3, 3.13, 5.10): accounts across workspaces, workspaces (with a 7-day restore hold), the authentication policy, instance settings and version & updates. Everything here needs an instance admin and every change is audited.

Index

Constants

View Source
const RestoreHold = 7 * 24 * time.Hour

RestoreHold is how long a deleted workspace can be restored before the purge job deletes it for good.

View Source
const UpgradeCommand = "cd /opt/reputecast && docker compose pull && docker compose up -d"

UpgradeCommand is how a docker compose install upgrades.

Variables

This section is empty.

Functions

func Register

func Register(h huma.API, s *Service)

Register adds the Instance admin operations. Every one needs an instance admin (a person, never an API key).

Types

type InstanceAdminInput

type InstanceAdminInput struct {
	Admin bool `json:"admin"`
}

InstanceAdminInput grants or removes instance admin.

type InstanceDeactivateInput

type InstanceDeactivateInput struct {
	Reason string `json:"reason" minLength:"3" maxLength:"500"`
	// RevokeKeys revokes the API keys and agents the person created.
	RevokeKeys bool `json:"revokeKeys,omitempty"`
}

InstanceDeactivateInput deactivates an account.

type InstanceDeactivateResult

type InstanceDeactivateResult struct {
	Sessions    int64 `json:"sessions"`
	Keys        int64 `json:"keys"`
	Memberships int64 `json:"memberships"`
}

InstanceDeactivateResult says what the deactivation ended.

type InstanceDomainRejection

type InstanceDomainRejection struct {
	Email string    `json:"email"`
	At    time.Time `json:"at"`
}

InstanceDomainRejection is the latest sign-in rejected for its domain.

type InstanceGraceMember

type InstanceGraceMember struct {
	Name  string    `json:"name"`
	Email string    `json:"email"`
	Until time.Time `json:"until"`
}

InstanceGraceMember is someone in a two-factor grace period.

type InstanceLogoInput

type InstanceLogoInput struct {
	Data string `json:"data" minLength:"10" maxLength:"1400000"`
}

InstanceLogoInput uploads a logo: an SVG document or a PNG, as a data URL or base64.

type InstanceMethods

type InstanceMethods struct {
	Password bool `json:"password"`
	Passkeys bool `json:"passkeys"`
	SSO      bool `json:"sso"`
}

InstanceMethods are the instance-wide sign-in method switches.

type InstancePasswordResetInfo

type InstancePasswordResetInfo struct {
	Email string `json:"email"`
	// System: a System-stream provider can send the email now.
	System bool `json:"system"`
	// Provider is the System-stream provider ("Postmark") and its status.
	Provider       string `json:"provider,omitempty"`
	ProviderStatus string `json:"providerStatus,omitempty"`
	Command        string `json:"command"`
	// SSOOnly: the person has no password; their IdP manages sign-in.
	SSOOnly           bool   `json:"ssoOnly"`
	SSOProvider       string `json:"ssoProvider,omitempty"`
	MinutesValid      int    `json:"minutesValid"`
	LastSentAt        string `json:"lastSentAt,omitempty"`
	DeactivatedNotice string `json:"deactivatedNotice,omitempty"`
}

InstancePasswordResetInfo is what the "Send a password reset" dialog shows.

type InstancePasswordResetSent

type InstancePasswordResetSent struct {
	Via       string    `json:"via"`
	ExpiresAt time.Time `json:"expiresAt"`
}

InstancePasswordResetSent says the reset email went out.

type InstancePolicy

type InstancePolicy struct {
	Methods InstanceMethods         `json:"methods"`
	Social  []sso.SSOSocialProvider `json:"social"`
	SSO     []sso.SSOProviderItem   `json:"sso"`
	// Password policy.
	PasswordMinLength int  `json:"passwordMinLength"`
	PasswordReuse     int  `json:"passwordReuse" doc:"Block the last N passwords; 0 allows re-use"`
	BreachedCheck     bool `json:"breachedCheck"`
	// Two-factor enforcement: everyone, sensitive (holders of a ⚑ permission) or off.
	TwoFactor string `json:"twoFactor" enum:"everyone,sensitive,off"`
	GraceDays int    `json:"graceDays"`
	// Sessions and lockout.
	SessionLifetimeHours int `json:"sessionLifetimeHours"`
	SessionIdleMinutes   int `json:"sessionIdleMinutes"`
	LockoutAttempts      int `json:"lockoutAttempts"`
	LockoutMinutes       int `json:"lockoutMinutes"`
	// JITDomains is the email domain allowlist for automatic accounts.
	JITDomains []string `json:"jitDomains"`
	// State the page explains.
	InGrace       []InstanceGraceMember    `json:"inGrace"`
	LockedNow     int                      `json:"lockedNow"`
	LastRejection *InstanceDomainRejection `json:"lastRejection,omitempty"`
	UpdatedAt     time.Time                `json:"updatedAt"`
}

InstancePolicy is Instance admin › Authentication.

type InstancePolicyInput

type InstancePolicyInput struct {
	Methods              InstanceMethods       `json:"methods"`
	Social               InstanceSocialToggles `json:"social"`
	PasswordMinLength    int                   `json:"passwordMinLength" minimum:"8" maximum:"128"`
	PasswordReuse        int                   `json:"passwordReuse" enum:"0,5,10"`
	BreachedCheck        bool                  `json:"breachedCheck"`
	TwoFactor            string                `json:"twoFactor" enum:"everyone,sensitive,off"`
	GraceDays            int                   `json:"graceDays" minimum:"0" maximum:"90"`
	SessionLifetimeHours int                   `json:"sessionLifetimeHours" minimum:"1" maximum:"2160"`
	SessionIdleMinutes   int                   `json:"sessionIdleMinutes" minimum:"5" maximum:"4320"`
	LockoutAttempts      int                   `json:"lockoutAttempts" minimum:"3" maximum:"100"`
	LockoutMinutes       int                   `json:"lockoutMinutes" minimum:"1" maximum:"1440"`
	JITDomains           []string              `json:"jitDomains" maxItems:"50"`
}

InstancePolicyInput is PUT /admin/policy (the "Save policies" button).

type InstanceRelease

type InstanceRelease struct {
	Tag         string    `json:"tag"`
	Name        string    `json:"name,omitempty"`
	PublishedAt time.Time `json:"publishedAt"`
	URL         string    `json:"url"`
	// Notes are the changelog's bullet points; Note its closing remark.
	Notes []string `json:"notes"`
	Note  string   `json:"note,omitempty"`
	// Demo marks the sample release of the demo data.
	Demo bool `json:"demo"`
}

InstanceRelease is the latest ReputeCast release.

type InstanceSettings

type InstanceSettings struct {
	Name            string `json:"name"`
	PublicURL       string `json:"publicUrl"`
	DefaultTimezone string `json:"defaultTimezone"`
	// DefaultLanguage and DefaultRegionFormat are used for the sign-in page,
	// members who haven't chosen, and invitations.
	DefaultLanguage     string `json:"defaultLanguage,omitempty" example:"en"`
	DefaultRegionFormat string `json:"defaultRegionFormat,omitempty" example:"standard"`
	// LogoSVG is the instance logo (PNG uploads are wrapped in an SVG);
	// empty means the ReputeCast mark.
	LogoSVG string `json:"logoSvg,omitempty"`
	// URLCheck is the last public URL check.
	URLCheck *accounts.URLCheck `json:"urlCheck,omitempty"`
	// ConfigPublicURL is the URL the server was started with
	// (http.public_url). A saved PublicURL replaces it for every link and
	// webhook; the command line and the HTTPS-only cookie setting still read
	// it.
	ConfigPublicURL string `json:"configPublicUrl,omitempty"`
	// PublicURLLocked: the server pins the public URL (http.public_url_locked).
	// PublicURL is then the configured address and a save can't change it.
	PublicURLLocked bool `json:"publicUrlLocked"`
	// Webhooks is set on a save that moved the public URL.
	Webhooks *PublicURLWebhooks `json:"webhooks,omitempty"`
}

InstanceSettings is Instance admin › Instance & updates › Instance.

type InstanceSettingsInput

type InstanceSettingsInput struct {
	Name            string `json:"name" minLength:"1" maxLength:"80"`
	PublicURL       string `json:"publicUrl" maxLength:"300"`
	DefaultTimezone string `json:"defaultTimezone" maxLength:"64"`
	// DefaultLanguage and DefaultRegionFormat stay as they are when omitted.
	DefaultLanguage     string `json:"defaultLanguage,omitempty" enum:"en,de,es,fr,vi"`
	DefaultRegionFormat string `json:"defaultRegionFormat,omitempty" enum:"standard,en-US,vi-VN,de-DE,en-GB,es-ES,fr-FR,pt-BR"`
}

InstanceSettingsInput saves the instance basics.

type InstanceSignInEvent

type InstanceSignInEvent struct {
	ID string    `json:"id"`
	At time.Time `json:"at"`
	// Event names the method: "Password + TOTP", "Google Workspace SSO",
	// "Password · 3 failed".
	Event   string `json:"event"`
	Account string `json:"account"`
	// Result: allowed, denied, or recovered (failed attempts, then allowed).
	Result string `json:"result" enum:"allowed,denied,recovered"`
	// Detail explains a rejection ("domain not allowed").
	Detail string `json:"detail,omitempty"`
}

InstanceSignInEvent is one row of Users › Recent sign-in events.

type InstanceSignInList

type InstanceSignInList struct {
	Items []InstanceSignInEvent `json:"items"`
}

InstanceSignInList is GET /admin/sign-ins.

type InstanceSignOutResult

type InstanceSignOutResult struct {
	Revoked int64 `json:"revoked"`
}

InstanceSignOutResult says how many sessions ended.

type InstanceSocialToggles

type InstanceSocialToggles struct {
	Google    bool `json:"google"`
	Microsoft bool `json:"microsoft"`
	GitHub    bool `json:"github"`
}

InstanceSocialToggles turn each social provider on or off.

type InstanceTwoFactorResetInput

type InstanceTwoFactorResetInput struct {
	Reason string `json:"reason" minLength:"3" maxLength:"500"`
	// Password re-confirms the admin (required when they have one).
	Password string `json:"password,omitempty" maxLength:"1024"`
}

InstanceTwoFactorResetInput resets a person's authenticator.

type InstanceURLCheckInput

type InstanceURLCheckInput struct {
	URL string `json:"url,omitempty" maxLength:"300"`
}

InstanceURLCheckInput checks a URL (the saved one when empty).

type InstanceUpdateCheckInput

type InstanceUpdateCheckInput struct {
	Enabled bool `json:"enabled"`
}

InstanceUpdateCheckInput turns the release check on or off.

type InstanceUser

type InstanceUser struct {
	ID            string                  `json:"id"`
	Email         string                  `json:"email"`
	Name          string                  `json:"name"`
	AvatarColor   string                  `json:"avatarColor"`
	AvatarURL     string                  `json:"avatarUrl,omitempty"`
	InstanceAdmin bool                    `json:"instanceAdmin"`
	BreakGlass    bool                    `json:"breakGlass"`
	Workspaces    []InstanceUserWorkspace `json:"workspaces"`
	// Methods: their own credentials first ("Password · passkey"); people
	// without a password list their SSO or social sign-in first
	// ("Google SSO · passkey"). AllMethods has every one.
	Methods    []access.MemberSignInMethod `json:"methods"`
	AllMethods []access.MemberSignInMethod `json:"allMethods"`
	// TwoFactor is the same status as on the team list (On · TOTP, Via
	// IdP, Required · off with the grace period, Off).
	TwoFactor    access.MemberTwoFA `json:"twoFactor"`
	LastSignInAt *time.Time         `json:"lastSignInAt,omitempty"`
	Status       string             `json:"status" enum:"active,deactivated"`
	// DeactivatedAt is set for deactivated accounts.
	DeactivatedAt *time.Time `json:"deactivatedAt,omitempty"`
	LockedUntil   *time.Time `json:"lockedUntil,omitempty"`
	Sessions      int        `json:"sessions"`
	APIKeys       int        `json:"apiKeys" doc:"Active API keys and agents the person created"`
	// SoleOwnerOf names the workspaces where they are the only Owner.
	SoleOwnerOf []string `json:"soleOwnerOf"`
	HasPassword bool     `json:"hasPassword"`
	// SSOProvider is the SSO they sign in with, for "managed by" texts.
	SSOProvider string `json:"ssoProvider,omitempty"`
	Self        bool   `json:"self"`
	// AgencyLevel is their place on the agency's staff while agency mode
	// is on (instance admins are agency managers); empty otherwise.
	AgencyLevel string `json:"agencyLevel,omitempty" enum:"agency_manager,account_manager"`
}

InstanceUser is one row of Instance admin › Users.

type InstanceUserList

type InstanceUserList struct {
	Items []InstanceUser `json:"items"`
	// Total is every account, before filters.
	Total      int                    `json:"total"`
	AdminNames []string               `json:"adminNames"`
	Workspaces []InstanceWorkspaceRef `json:"workspaces"`
}

InstanceUserList is GET /admin/users.

type InstanceUserPath

type InstanceUserPath struct {
	UserID string `path:"userId" format:"uuid"`
}

type InstanceUserReason

type InstanceUserReason struct {
	Reason string `json:"reason,omitempty" maxLength:"500"`
}

InstanceUserReason carries the reason an action is logged with.

type InstanceUserWorkspace

type InstanceUserWorkspace struct {
	Slug   string `json:"slug"`
	Name   string `json:"name"`
	Role   string `json:"role"`
	Status string `json:"status" enum:"active,deactivated"`
}

InstanceUserWorkspace is a workspace a person belongs to, with their role.

type InstanceVersion

type InstanceVersion struct {
	Installed string `json:"installed" example:"v1.4.2"`
	Commit    string `json:"commit,omitempty"`
	// BuiltAt is when the running binary was built (the release date of a
	// release build).
	BuiltAt *time.Time `json:"builtAt,omitempty"`
	// Release: the installed version is a tagged release (vX.Y.Z).
	Release bool `json:"release"`
	// CheckEnabled is the instance switch; CheckAllowed is false when the
	// server configuration (updates.check) turns the check off entirely.
	CheckEnabled    bool             `json:"checkEnabled"`
	CheckAllowed    bool             `json:"checkAllowed"`
	CheckedAt       *time.Time       `json:"checkedAt,omitempty"`
	CheckError      string           `json:"checkError,omitempty"`
	Latest          *InstanceRelease `json:"latest,omitempty"`
	UpdateAvailable bool             `json:"updateAvailable"`
	UpgradeCommand  string           `json:"upgradeCommand"`
	ReleasesURL     string           `json:"releasesUrl"`
	// ManagedBy names who upgrades this instance when the server's operator
	// does (updates.managed_by); UpgradeCommand doesn't apply then.
	ManagedBy string `json:"managedBy,omitempty"`
}

InstanceVersion is Instance admin › Instance & updates › Version & updates.

type InstanceWorkspace

type InstanceWorkspace struct {
	ID          string    `json:"id"`
	Slug        string    `json:"slug"`
	Name        string    `json:"name"`
	Owner       string    `json:"owner,omitempty"`
	Members     int       `json:"members"`
	Invited     int       `json:"invited"`
	Subscribers int64     `json:"subscribers"`
	Providers   []string  `json:"providers"`
	CreatedAt   time.Time `json:"createdAt"`
	// DeletedAt and PurgeAt are set during the restore hold.
	DeletedAt *time.Time `json:"deletedAt,omitempty"`
	PurgeAt   *time.Time `json:"purgeAt,omitempty"`
	// Member: the admin belongs to it, so its settings open.
	Member bool `json:"member"`
}

InstanceWorkspace is one row of Instance admin › Workspaces.

type InstanceWorkspaceDeleteInput

type InstanceWorkspaceDeleteInput struct {
	Confirm string `json:"confirm" maxLength:"80"`
}

InstanceWorkspaceDeleteInput confirms a deletion by typing the name.

type InstanceWorkspaceDeleted

type InstanceWorkspaceDeleted struct {
	PurgeAt   time.Time `json:"purgeAt"`
	Cancelled int64     `json:"cancelled" doc:"Scheduled sends that were stopped"`
}

InstanceWorkspaceDeleted says until when the workspace can be restored.

type InstanceWorkspaceInput

type InstanceWorkspaceInput struct {
	Name string `json:"name" minLength:"1" maxLength:"80"`
	// OwnerID defaults to the admin creating it.
	OwnerID  string `json:"ownerId,omitempty" format:"uuid"`
	Timezone string `json:"timezone,omitempty" maxLength:"64"`
}

InstanceWorkspaceInput creates a workspace.

type InstanceWorkspaceList

type InstanceWorkspaceList struct {
	Items []InstanceWorkspace `json:"items"`
	// Live is the number of workspaces not deleted.
	Live int `json:"live"`
}

InstanceWorkspaceList is GET /admin/workspaces.

type InstanceWorkspacePath

type InstanceWorkspacePath struct {
	WorkspaceID string `path:"workspaceId" format:"uuid"`
}

type InstanceWorkspaceRef

type InstanceWorkspaceRef struct {
	Slug string `json:"slug"`
	Name string `json:"name"`
}

InstanceWorkspaceRef names a workspace for the filter.

type PublicURLManualHook

type PublicURLManualHook struct {
	Workspace string `json:"workspace"`
	Provider  string `json:"provider"`
	URL       string `json:"url" doc:"The provider's webhook address on the new public URL"`
}

PublicURLManualHook is a provider whose webhook has to be changed by hand.

type PublicURLWebhooks

type PublicURLWebhooks struct {
	Reregistering int                   `json:"reregistering" doc:"Providers whose webhook ReputeCast moves to the new URL, in the background"`
	Manual        []PublicURLManualHook `json:"manual" doc:"Providers whose webhook is set up in the provider itself"`
}

PublicURLWebhooks is what a new public URL did to provider webhooks.

type ReleaseCheckArgs

type ReleaseCheckArgs struct{}

ReleaseCheckArgs is the daily release check.

func (ReleaseCheckArgs) InsertOpts

func (ReleaseCheckArgs) InsertOpts() river.InsertOpts

InsertOpts keeps one check at a time on the maintenance queue.

func (ReleaseCheckArgs) Kind

func (ReleaseCheckArgs) Kind() string

Kind implements river.JobArgs.

type ReleaseCheckWorker

type ReleaseCheckWorker struct {
	river.WorkerDefaults[ReleaseCheckArgs]
	S *Service
}

ReleaseCheckWorker runs the check when both the server configuration and the instance switch allow it; otherwise it makes no request at all.

func (*ReleaseCheckWorker) Work

Work implements river.Worker.

type Service

type Service struct {
	Pool     *pgxpool.Pool
	Q        *store.Queries
	Audit    *audit.Logger
	Box      *secrets.Box
	Cfg      *config.Config
	Log      *slog.Logger
	Accounts *accounts.Service
	SSO      *sso.Service
	// Mail returns the system mailer (set by a start hook after wiring).
	Mail func() mailer.Sender
	// Jobs returns the River client (it exists only after wiring).
	Jobs func() *jobs.Client
	// OnPolicyChange drops the cached authentication policy (App.InvalidatePolicy).
	OnPolicyChange func()
	// OnPublicURL applies a new saved public URL (before and after; empty
	// means http.public_url) and moves provider webhooks to it.
	OnPublicURL func(ctx context.Context, before, after string) (*PublicURLWebhooks, error)
	// HTTP fetches releases and checks the public URL. Nil uses a client
	// with a 10 s timeout.
	HTTP *http.Client
	// ReleasesURL overrides the GitHub API endpoint of the latest release.
	ReleasesURL string
	Now         func() time.Time
}

Service holds the instance admin domain's dependencies.

func (*Service) CheckNow

func (s *Service) CheckNow(ctx context.Context) (InstanceVersion, error)

CheckNow fetches the latest release immediately (when the check is on).

func (*Service) CheckURL

CheckURL checks the public URL's DNS, TLS and reachability and keeps the result for the saved URL.

func (*Service) CreateWorkspace

func (s *Service) CreateWorkspace(ctx context.Context, in InstanceWorkspaceInput) (InstanceWorkspace, error)

CreateWorkspace makes a workspace with its built-in roles and an Owner.

func (*Service) Deactivate

Deactivate signs a person out everywhere and blocks sign-in; history, memberships and content stay. The last instance admin and the only Owner of a workspace can't be deactivated.

func (*Service) DeleteWorkspace

DeleteWorkspace deletes a workspace after a typed confirmation: sends stop now, members lose access, and a River job deletes it for good after the 7-day restore hold.

func (*Service) DiscardJob

func (s *Service) DiscardJob(ctx context.Context, id int64) (SystemJobResult, error)

DiscardJob stops a failed job: a retrying job is cancelled (it stays in the list of given-up jobs for 7 days), a given-up one is deleted. Audited.

func (*Service) FailedJobs

func (s *Service) FailedJobs(ctx context.Context, state, cursor string) (SystemJobList, error)

FailedJobs lists the failed jobs, newest first: state is retrying, given_up or empty for both.

func (*Service) PasswordResetInfo

func (s *Service) PasswordResetInfo(ctx context.Context, id uuid.UUID) (InstancePasswordResetInfo, error)

PasswordResetInfo returns the dialog's state for a person.

func (*Service) Policy

func (s *Service) Policy(ctx context.Context) (InstancePolicy, error)

Policy returns the authentication policy and what it affects right now.

func (*Service) Reactivate

func (s *Service) Reactivate(ctx context.Context, id uuid.UUID) error

Reactivate lets a deactivated person sign in again; the memberships that were deactivated with the account come back.

func (s *Service) RemoveLogo(ctx context.Context) (InstanceSettings, error)

RemoveLogo goes back to the ReputeCast mark.

func (*Service) ResetTwoFactor

func (s *Service) ResetTwoFactor(ctx context.Context, id uuid.UUID, in InstanceTwoFactorResetInput) error

ResetTwoFactor removes a person's authenticator and recovery codes (passkeys stay), restarts the grace period, signs them out and notifies them. The reason is required and logged; the admin confirms with their own password.

func (*Service) RestoreWorkspace

func (s *Service) RestoreWorkspace(ctx context.Context, id uuid.UUID) (InstanceWorkspace, error)

RestoreWorkspace brings a deleted workspace back during its hold, under its old address when that is still free.

func (*Service) RetryJob

func (s *Service) RetryJob(ctx context.Context, id int64) (SystemJobResult, error)

RetryJob runs a failed job again now. Audited.

func (*Service) SavePolicy

func (s *Service) SavePolicy(ctx context.Context, in InstancePolicyInput) (InstancePolicy, error)

SavePolicy stores the authentication policy. It refuses changes that would leave nobody a way to sign in, and drops the cached policy so the next request uses the new one.

func (*Service) SaveSettings

func (s *Service) SaveSettings(ctx context.Context, in InstanceSettingsInput) (InstanceSettings, error)

SaveSettings stores the name, public URL and default timezone.

func (*Service) SendPasswordReset

func (s *Service) SendPasswordReset(ctx context.Context, id uuid.UUID) (InstancePasswordResetSent, error)

SendPasswordReset emails a one-time reset link (15 minutes) on the System stream.

func (*Service) SetInstanceAdmin

func (s *Service) SetInstanceAdmin(ctx context.Context, id uuid.UUID, in InstanceAdminInput) error

SetInstanceAdmin makes a person an instance admin or removes it; the last one can't be removed.

SetLogo stores the logo shown on the sign-in page and in team emails.

func (*Service) SetUpdateCheck

func (s *Service) SetUpdateCheck(ctx context.Context, in InstanceUpdateCheckInput) (InstanceVersion, error)

SetUpdateCheck turns the daily release check on or off. Turning it on queues a check right away.

func (*Service) Settings

func (s *Service) Settings(ctx context.Context) (InstanceSettings, error)

func (*Service) SignIns

func (s *Service) SignIns(ctx context.Context, limit int) (InstanceSignInList, error)

SignIns returns the latest sign-in attempts, in the reader's language. Failed password attempts followed by a successful sign-in of the same account within an hour are folded into that row ("Password · 3 failed · Then allowed").

func (*Service) SignOut

SignOut ends every session of a person.

func (*Service) System

func (s *Service) System(ctx context.Context) (SystemView, error)

System reads the System tab.

func (*Service) Unlock

func (s *Service) Unlock(ctx context.Context, id uuid.UUID) error

Unlock clears a sign-in lockout.

func (*Service) Users

Users lists every account on the instance.

func (*Service) Version

func (s *Service) Version(ctx context.Context) (InstanceVersion, error)

Version returns the installed version and the latest release.

func (*Service) Workspaces

func (s *Service) Workspaces(ctx context.Context) (InstanceWorkspaceList, error)

Workspaces lists every workspace, deleted ones in their hold last.

type SystemDatabase

type SystemDatabase struct {
	Version        string        `json:"version"`
	Bytes          int64         `json:"bytes"`
	Connections    int64         `json:"connections" doc:"Open connections to this database, from every process"`
	MaxConnections int64         `json:"maxConnections"`
	SchemaVersion  int64         `json:"schemaVersion"`
	SchemaCurrent  bool          `json:"schemaCurrent"`
	Tables         []SystemTable `json:"tables" doc:"The 10 largest tables, partitions added up"`
}

SystemDatabase is the database's size and schema.

type SystemFiles

type SystemFiles struct {
	Dir       string    `json:"dir"`
	Files     int64     `json:"files"`
	Bytes     int64     `json:"bytes"`
	CountedAt time.Time `json:"countedAt"`
	// Partial is true when the count stopped early (a very large folder).
	Partial bool   `json:"partial,omitempty"`
	Missing bool   `json:"missing,omitempty" doc:"The folder doesn't exist yet (nothing uploaded)"`
	Error   string `json:"error,omitempty"`
}

SystemFiles is the uploaded files folder.

type SystemJob

type SystemJob struct {
	ID          int64            `json:"id"`
	Kind        string           `json:"kind"`
	Queue       string           `json:"queue"`
	State       string           `json:"state" enum:"retrying,given_up"`
	Attempt     int              `json:"attempt"`
	MaxAttempts int              `json:"maxAttempts"`
	Error       string           `json:"error,omitempty" doc:"The last attempt's error, cut to 500 characters"`
	FailedAt    *time.Time       `json:"failedAt,omitempty"`
	NextAt      *time.Time       `json:"nextAt,omitempty" doc:"A retrying job's next attempt"`
	Workspace   *SystemWorkspace `json:"workspace,omitempty"`
}

SystemJob is a failed job.

type SystemJobList

type SystemJobList struct {
	Items      []SystemJob `json:"items"`
	NextCursor string      `json:"nextCursor,omitempty"`
}

SystemJobList is a page of failed jobs.

type SystemJobPath

type SystemJobPath struct {
	JobID int64 `path:"jobId" minimum:"1"`
}

SystemJobPath names a job.

type SystemJobResult

type SystemJobResult struct {
	ID    int64  `json:"id"`
	State string `json:"state" enum:"available,cancelled,deleted"`
}

SystemJobResult is a job after an action.

type SystemJobs

type SystemJobs struct {
	Waiting   int64 `json:"waiting" doc:"Due and waiting for a worker"`
	Scheduled int64 `json:"scheduled" doc:"Due later"`
	Running   int64 `json:"running"`
	Retrying  int64 `json:"retrying" doc:"Failed, waiting for their next attempt"`
	GivenUp   int64 `json:"givenUp" doc:"Out of attempts, kept 7 days"`
	// LagSeconds is how long the oldest due job has waited (0 when none).
	LagSeconds float64 `json:"lagSeconds"`
}

SystemJobs counts the jobs in every queue.

type SystemQueue

type SystemQueue struct {
	Name       string   `json:"name"`
	Waiting    int64    `json:"waiting"`
	Scheduled  int64    `json:"scheduled"`
	Running    int64    `json:"running"`
	LagSeconds *float64 `json:"lagSeconds,omitempty" doc:"How long the oldest due job has waited; absent when none waits"`
}

SystemQueue is one queue.

type SystemTable

type SystemTable struct {
	Name       string `json:"name"`
	Rows       int64  `json:"rows" doc:"Postgres's estimate"`
	Bytes      int64  `json:"bytes" doc:"With its indexes and TOAST"`
	IndexBytes int64  `json:"indexBytes"`
}

SystemTable is one table's size.

type SystemView

type SystemView struct {
	Jobs     SystemJobs     `json:"jobs"`
	Queues   []SystemQueue  `json:"queues"`
	Database SystemDatabase `json:"database"`
	Files    SystemFiles    `json:"files"`
}

SystemView is the System tab.

type SystemWorkspace

type SystemWorkspace struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Slug string `json:"slug"`
}

SystemWorkspace names a job's workspace.

type UserFilter

type UserFilter struct {
	Search    string
	Workspace string
	Status    string
	TwoFactor string // on, off, idp
}

UserFilter narrows the users list.

type WorkspacePurgeArgs

type WorkspacePurgeArgs struct {
	WorkspaceID uuid.UUID `json:"workspace_id"`
}

WorkspacePurgeArgs deletes one workspace for good after its restore hold.

func (WorkspacePurgeArgs) InsertOpts

func (WorkspacePurgeArgs) InsertOpts() river.InsertOpts

InsertOpts runs purges on the maintenance queue, one per workspace.

func (WorkspacePurgeArgs) Kind

func (WorkspacePurgeArgs) Kind() string

Kind implements river.JobArgs.

type WorkspacePurgeWorker

type WorkspacePurgeWorker struct {
	river.WorkerDefaults[WorkspacePurgeArgs]
	Pool  *pgxpool.Pool
	Audit *audit.Logger
	Log   *slog.Logger
}

WorkspacePurgeWorker deletes a workspace whose hold is over. A restored workspace, or one still in its hold, is left alone.

func (*WorkspacePurgeWorker) Timeout

Timeout allows large workspaces time to cascade.

func (*WorkspacePurgeWorker) Work

Work implements river.Worker.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL