Help us shape the future of Go! Take the 2026 Go Developer Survey

daemon

package
v0.1.94 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AWSCredentialsBody added in v0.1.65

type AWSCredentialsBody struct {
	AccessKeyID     string `json:"accessKeyId"`
	SecretAccessKey string `json:"secretAccessKey"`

	// SessionToken is required for STS/SSO-derived credentials (an instance
	// role resolved on the client, an assumed role, an SSO session) — they do
	// not authenticate without it.
	SessionToken string `json:"sessionToken,omitempty"`

	// Source is the chain rung that produced the triple (e.g.
	// "EnvConfigCredentials"), for the daemon's log line only.
	Source string `json:"source,omitempty"`
}

AWSCredentialsBody carries CLIENT-resolved static AWS credentials for a one-shot S3 fetch. Precedent for secrets in a request body: PUT /api/offsite/config has always carried secretAccessKey the same way, over the same loopback-by-default channel.

NEVER log this struct, its enclosing request, or a resolved aws.Credentials value. The daemon uses the triple only to build an in-memory S3 client; nothing persists it.

type BackupRequest

type BackupRequest struct {
	Comment string `json:"comment,omitempty"`
}

type BackupResponse

type BackupResponse struct {
	BackupID   int       `json:"backupId"`
	BackupPath string    `json:"backupPath"`
	Size       int64     `json:"size"`
	Timestamp  time.Time `json:"timestamp"`
	Message    string    `json:"message"`
}

type CreateRDBMSRequest

type CreateRDBMSRequest struct {
	Name           string `json:"name"`
	Version        string `json:"version"`
	Image          string `json:"image"`
	Port           int    `json:"port"`
	CPUCores       int    `json:"cpuCores"`
	RAMMB          int    `json:"ramMb"`
	ParameterGroup string `json:"parameterGroup"`
}

Request/Response types for RDBMS operations

type CronPlanRequest

type CronPlanRequest struct {
	InstanceName      string `json:"instanceName"`
	UTCHour           *int   `json:"utcHour"`
	CleanupLocalDays  *int   `json:"cleanupLocalDays"`
	CleanupRemoteDays *int   `json:"cleanupRemoteDays"`
}

type CronTaskTracker

type CronTaskTracker struct {
	// contains filtered or unexported fields
}

CronTaskTracker manages sequential execution of cron tasks

func NewCronTaskTracker

func NewCronTaskTracker(opDeps *operations.Dependencies, executor *operations.Executor, backupDir string) *CronTaskTracker

NewCronTaskTracker creates a new cron task tracker

func (*CronTaskTracker) GetStatus

func (t *CronTaskTracker) GetStatus() (currentTask string, queueLength int, queuedTasks []string)

GetStatus returns the current status for debugging

func (*CronTaskTracker) RunTask

func (t *CronTaskTracker) RunTask(ctx context.Context, instanceName string) bool

RunTask runs a cron task sequentially - starts immediately if nothing running, queues if busy Returns true if the task was started or queued, false if it's a duplicate

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

ErrorResponse represents an API error response

type HealthHistory

type HealthHistory struct {
	Records   []*HealthRecord `json:"records"`
	Timestamp string          `json:"timestamp"`
}

HealthHistory represents the health history response

type HealthRecord

type HealthRecord struct {
	ID               int64    `json:"id"`
	Timestamp        string   `json:"timestamp"`
	TimestampUnix    int64    `json:"timestampUnix"`
	InProgress       bool     `json:"inProgress"`
	HealthyAll       bool     `json:"healthyAll"`
	HealthyHost      bool     `json:"healthyHost"`
	HealthyInstances []string `json:"healthyInstances"`
	BrokenInstances  []string `json:"brokenInstances"`
	FailDetails      string   `json:"failDetails"`
}

HealthRecord represents a single health check record for API response

type HealthScheduler

type HealthScheduler struct {
	// contains filtered or unexported fields
}

HealthScheduler manages the health check scheduling with process mutex

func NewHealthScheduler

func NewHealthScheduler(healthChecker *services.HealthChecker, intervalSec int) *HealthScheduler

func (*HealthScheduler) IsRunning

func (hs *HealthScheduler) IsRunning() bool

IsRunning returns whether a health check is currently running

func (*HealthScheduler) Pause

func (hs *HealthScheduler) Pause()

Pause pauses health checks (new ones won't start)

func (*HealthScheduler) Start

func (hs *HealthScheduler) Start(ctx context.Context)

func (*HealthScheduler) Unpause

func (hs *HealthScheduler) Unpause()

Unpause resumes health checks

func (*HealthScheduler) WaitForCompletion

func (hs *HealthScheduler) WaitForCompletion(timeout time.Duration) bool

WaitForCompletion waits for any running health check to complete

type HealthStatus

type HealthStatus struct {
	Overall      string        `json:"overall"` // "healthy", "degraded", "unhealthy"
	LastCheck    *HealthRecord `json:"lastCheck"`
	CheckRunning bool          `json:"checkRunning"`
	Timestamp    string        `json:"timestamp"`
}

HealthStatus represents the detailed health status response

type KVPair

type KVPair struct {
	Key       string `json:"key"`
	Value     string `json:"value"`
	UpdatedAt string `json:"updatedAt"`
}

KVPair represents a key-value pair for API responses

type KVSetRequest

type KVSetRequest struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

KVSetRequest represents the request body for setting a key-value pair

type PullImageRequest

type PullImageRequest struct {
	Version string `json:"version"`
	Image   string `json:"image"`
	// IfMissing pulls only when the image is not already present locally.
	IfMissing bool `json:"ifMissing"`
}

Request types for image operations

type ReconfigureRequest

type ReconfigureRequest struct {
	ParameterGroup string `json:"parameterGroup,omitempty"`
	CPUCores       *int   `json:"cpuCores,omitempty"`
	RAMMB          *int   `json:"ramMb,omitempty"`
	Port           *int   `json:"port,omitempty"`
}

ReconfigureRequest is the body of PUT /api/rdbms/{name}/config. Every field is optional and an absent one keeps the instance's current value; at least one must be present.

type RestoreRequest

type RestoreRequest struct {
	BackupID     int    `json:"backupId,omitempty"`
	FilePath     string `json:"filePath,omitempty"`
	DatabaseName string `json:"databaseName"`
	RestoreAs    string `json:"restoreAs,omitempty"`
}

RestoreRequest represents the request body for restore

type RestoreResponse

type RestoreResponse struct {
	TargetDatabase string `json:"targetDatabase"`
	SourceBackup   string `json:"sourceBackup"`
	Message        string `json:"message"`
}

RestoreResponse represents the response from restore

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(port int, dataDir, backupDir string, healthCheckIntervalSec int, allowRemote bool) (*Server, error)

func (*Server) MintToken

func (s *Server) MintToken() (string, error)

MintToken creates a new CLI auth token and returns its plaintext. The daemon does not mint tokens on its own (see NewServer); this is the programmatic equivalent of `oddk auth mint`, used by tests to obtain a usable token.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the server.

ORDER MATTERS, and it is not the obvious one. Scheduled operations inherit the background context cancelled by s.cancel, so cancelling first would abort the very operation this is supposed to protect — a half-aborted pg_restore or container-create is precisely the debris the uninterruptible-operations design exists to prevent. So: stop accepting work, wait for what is running, and only then cancel.

If ctx expires first, the in-flight operation is abandoned and the caller gets ctx.Err(); the next daemon start reconciles whatever it left behind.

func (*Server) Start

func (s *Server) Start() error

type SnapshotArchiveSource added in v0.1.93

type SnapshotArchiveSource struct {
	// FilePath is a path on the DAEMON's filesystem (the original form).
	FilePath string `json:"filePath,omitempty"`

	// SnapshotID names a row in this host's snapshot catalogue; the daemon
	// downloads it from S3 first (via offsite settings) if the local copy is
	// gone.
	SnapshotID int `json:"snapshotId,omitempty"`

	// S3URI names an s3://bucket/key archive, possibly from another
	// deployment. Region, Endpoint and Credentials apply only to this mode.
	S3URI       string              `json:"s3Uri,omitempty"`
	Region      string              `json:"region,omitempty"`
	Endpoint    string              `json:"endpoint,omitempty"`
	Credentials *AWSCredentialsBody `json:"credentials,omitempty"`

	// MasterKeyPath is the SOURCE host's master.key, needed only when the
	// snapshot came from a different deployment. Empty means this host's key.
	MasterKeyPath string `json:"masterKeyPath,omitempty"`
}

SnapshotArchiveSource selects the archive a snapshot restore reads, shared by restore-instance and restore-database. Exactly one of FilePath, SnapshotID or S3URI must be set.

type SnapshotCronRequest added in v0.1.59

type SnapshotCronRequest struct {
	UTCHour           int `json:"utcHour"`
	IntervalHours     int `json:"intervalHours"`
	CleanupLocalDays  int `json:"cleanupLocalDays"`
	CleanupRemoteDays int `json:"cleanupRemoteDays"`

	// Format is "physical" or "logical". Empty follows the merge rule below:
	// an existing plan keeps its format, a new plan defaults to physical.
	Format string `json:"format,omitempty"`
}

SnapshotCronRequest is the body of POST /api/cron/snapshot.

type SnapshotRestoreDatabaseRequest added in v0.1.93

type SnapshotRestoreDatabaseRequest struct {
	Instance string `json:"instance"`
	// FromInstance is the snapshot entry to read; empty means Instance.
	FromInstance string `json:"fromInstance,omitempty"`
	Database     string `json:"database"`
	RestoreAs    string `json:"restoreAs,omitempty"`
	SnapshotArchiveSource
}

SnapshotRestoreDatabaseRequest is the body of POST /api/snapshot/restore-database.

type SnapshotRestoreInstanceRequest added in v0.1.59

type SnapshotRestoreInstanceRequest struct {
	Instance string `json:"instance"`
	SnapshotArchiveSource
}

SnapshotRestoreInstanceRequest is the body of POST /api/snapshot/restore-instance.

type SwitchRequest

type SwitchRequest struct {
	Image   string `json:"image"`
	Version string `json:"version"`
}

type UpdateRequest

type UpdateRequest struct {
	Image string `json:"image"`
}

UpdateRequest is the body for POST /api/rdbms/{name}/update. Image is optional (defaults to the instance's current image).

type UpdateStateRequest

type UpdateStateRequest struct {
	State string `json:"state"`
}

type UpgradeRequest

type UpgradeRequest struct {
	TargetVersion string `json:"targetVersion"`
	Image         string `json:"image"`
}

Jump to

Keyboard shortcuts

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