Documentation
¶
Overview ¶
Package app is the usecase layer between the transports and the internals. Each action is its own struct holding exactly the dependencies it needs; there is no shared object, so actions cannot couple to each other. Input and output are transport-neutral: flag parsing, query parameters, rejection of deprecated fields and rendering stay in cmd and core/server, which import this package and nothing below it.
Index ¶
- Variables
- type AsyncJob
- type BackupJob
- type BackupSummary
- type Check
- type CreateBackupRequest
- type DeleteBackupRequest
- type DeleteJob
- type GetBackup
- type GetBackupTask
- type GetBackupTaskRequest
- type GetRestore
- type ListBackups
- type MigrateJob
- type MigrateRequest
- type RestoreJob
- type RestoreRequest
- type RestoreSecondaryJob
- type RestoreSecondaryRequest
Constants ¶
This section is empty.
Variables ¶
var ErrBackupNotFound = errors.New("backup not found")
ErrBackupNotFound reports a selector with no artifact behind it. Callers that merge the artifact with the job half (the v1 get_backup contract) use it to tell "no backup persisted yet" apart from a storage failure.
var ErrStorageNotReady = errors.New("storage not ready")
ErrStorageNotReady means storage admission failed before a job was registered. Transports may ask the caller to retry the same create request.
Functions ¶
This section is empty.
Types ¶
type AsyncJob ¶ added in v0.6.1
type AsyncJob[Status any] interface { // Run releases the job into the background and answers nothing: once // released there is nobody on the call path left to act on an error, so // the outcome lives in the job store and in Wait. // // The context must NOT be the request's. A request context is canceled // when the request ends, and cancellation walks every context derived // from it, so a job released with one is canceled the moment the caller // goes away — the opposite of what running async exists for. Hand Run a // process-scoped context: the server's base context or // context.Background(). Run(ctx context.Context) // Wait blocks until Run's job settles and answers its status. It is the // request-side half: taking the request's context here is fine, because // abandoning a Wait only stops the waiting, never the job. Waiting on a // job that was never started blocks until the context is done. Wait(ctx context.Context) (Status, error) }
The layer speaks two contracts. AsyncJob is the registered run: an id and a state in the job store, released into the background to outlive the request that started it. The synchronous contract is tasklet.Tasklet — Execute calls composing into trees, a task holding child tasklets — and a job's body is usually the root of one such tree. The tasklet half already has its name in core/tasklet; this file deliberately mints no second word for the same shape.
type BackupJob ¶ added in v0.6.1
type BackupJob struct {
// contains filtered or unexported fields
}
BackupJob is one registered create-backup run — the create counterpart of DeleteJob. A job is what a create call makes: the backup artifact is what a successful job leaves behind in storage, a different resource with its own usecase (GetBackup) — the split the v2 API draws between jobs/backup/create, which returns the job, and backups/describe, which reads the artifact.
Registering a job and running it are separate steps: admission happens in NewBackupJob, synchronously, so a duplicate name, an unreachable storage or an artifact directory that is already taken is the caller's immediate answer. Running is Run, which releases the job into the background; Wait blocks on the settlement.
func NewBackupJob ¶ added in v0.6.1
func NewBackupJob(ctx context.Context, params *cfg.Config, store *jobstate.Store, req CreateBackupRequest) (*BackupJob, error)
NewBackupJob creates both storage clients from the config and registers the job: source list preflight, artifact dir preflight, then the job state store. The clients are created per call; sharing them across calls is a lifecycle decision this layer deliberately does not make.
func (*BackupJob) Run ¶ added in v0.6.1
Run releases the job into the background and answers nothing: once the job is released there is nobody on the call path who could act on an error, so the outcome lives only in the job store, where Wait and the task APIs read it. The context must be process-scoped, not the request's — see AsyncJob.Run.
type BackupSummary ¶
BackupSummary is the artifact summary as list presents it. It is not backuppb.BackupSummary on purpose: that type is the v1 wire shape, and wire shapes belong to the transports, which render this view into whatever their contract says.
type Check ¶
type Check struct {
// contains filtered or unexported fields
}
Check verifies that a backup run would work: Milvus answers, both storages are reachable, and an object can be copied from the Milvus storage to the backup storage.
func NewCheck ¶
NewCheck builds the usecase from config, creating the Milvus gRPC client and both storage clients itself so the transports never import internal/storage or internal/client/milvus. The clients are created per call; sharing them across calls is a lifecycle decision this layer deliberately does not make.
func (*Check) Execute ¶
Execute runs the checks in order and writes the result report to output. It stops at the first failed check: a later check against a broken dependency would only add noise. The report is plain text by design — how a transport presents it (stdout, HTTP body) is the transport's call.
type CreateBackupRequest ¶ added in v0.6.1
type CreateBackupRequest struct {
// TaskID is the id the job registers under in the job state store.
TaskID string
// Option carries the parsed backup parameters: the artifact name the job
// registers under, strategy, format, collection filter, GC pause and the
// like. Option.BackupName is also the key the job is visible under to
// the task APIs, so it must be the one name the transport validated.
Option backup.Option
}
CreateBackupRequest describes one backup job. It is the transport-neutral whole of what the action accepts: both transports derive the task id from their request-id conventions and parse their own input format into Option before calling.
type DeleteBackupRequest ¶ added in v0.6.1
DeleteBackupRequest describes one delete job. TaskID is the id the job registers under in the job store; BackupName is the artifact it removes.
type DeleteJob ¶ added in v0.6.1
type DeleteJob struct {
// contains filtered or unexported fields
}
DeleteJob is one registered delete-backup run — the delete counterpart of BackupJob. Registering (NewDeleteJob) is synchronous and proves the artifact's meta is readable: a delete that cannot prove what it is deleting is refused, so a wrong root path or a corrupted backup is the caller's immediate answer instead of wiping whatever prefix happens to sit under the path.
func NewDeleteJob ¶ added in v0.6.1
func NewDeleteJob(ctx context.Context, params *cfg.Config, store *jobstate.Store, req DeleteBackupRequest) (*DeleteJob, error)
NewDeleteJob creates the backup storage client from the config and registers the job. The client is created per call; sharing one across calls is a lifecycle decision this layer deliberately does not make.
type GetBackup ¶
type GetBackup struct {
// contains filtered or unexported fields
}
GetBackup reads one backup artifact: the persisted meta in the backup storage. The job that produced it is a different resource with its own usecase, GetBackupTask — the two are read separately so transports with a split API (v2) map one endpoint to one usecase, and a transport with a merged contract (v1) does the merging itself.
func NewGetBackup ¶
NewGetBackup builds the usecase from config, creating the backup storage client itself so the transports never import internal/storage. The client is created per call; sharing one across calls is a lifecycle decision this layer deliberately does not make.
type GetBackupTask ¶
type GetBackupTask struct {
// contains filtered or unexported fields
}
GetBackupTask reads the state of one backup job. The job half of a backup lives only in the job state store, so like its sister GetRestore this usecase never touches storage, there is nothing to construct and construction cannot fail.
func NewGetBackupTask ¶
func NewGetBackupTask(store *jobstate.Store) *GetBackupTask
NewGetBackupTask builds the usecase on the given job state store; the server wiring passes the process-local one. That manager's state dies with the process — an artifact whose creating process has restarted has no job half anymore and is read through GetBackup alone.
func (*GetBackupTask) Execute ¶
func (uc *GetBackupTask) Execute(ctx context.Context, req GetBackupTaskRequest) (jobstate.BackupStatus, error)
Execute returns the job state store's snapshot of the selected job. An unknown selector is jobstate.ErrTaskNotFound, not a silent success. The store's snapshot type travels unchanged, as in GetRestore: an app-defined struct would only rename it.
type GetBackupTaskRequest ¶
GetBackupTaskRequest selects the job to read. Name and ID are alternative selectors; the ID wins when both are set, because only the ID can pin down one of several jobs that shared the name.
type GetRestore ¶
type GetRestore struct {
// contains filtered or unexported fields
}
GetRestore reads the state of one restore job. Restore jobs keep all their state in the job state store, so this is the thinnest usecase in the layer: unlike its sister GetBackup it never touches storage, which also means there is nothing to construct and construction cannot fail.
func NewGetRestore ¶
func NewGetRestore(store *jobstate.Store) *GetRestore
NewGetRestore builds the usecase on the given job state store; the server wiring passes the process-local one. That manager's state dies with the process — the existing get_restore contract: after a restart every task ID answers not-found.
func (*GetRestore) Execute ¶
func (uc *GetRestore) Execute(ctx context.Context, id string) (jobstate.RestoreStatus, error)
Execute returns the job state store's snapshot of the restore job with the given ID. An unknown ID is an error, not a silent success. A restore has no artifact half to merge — the backup a job produces is read through GetBackup — so unlike GetBackup the job state store's own snapshot travels unchanged; an app-defined struct would only rename it.
type ListBackups ¶
type ListBackups struct {
// contains filtered or unexported fields
}
ListBackups lists the backup artifacts kept in the backup storage.
func NewListBackups ¶
NewListBackups builds the usecase from config, creating the backup storage client itself so the transports never import internal/storage. The client is created per call; sharing one across calls is a lifecycle decision this layer deliberately does not make.
func (*ListBackups) Execute ¶
func (uc *ListBackups) Execute(ctx context.Context) ([]BackupSummary, error)
Execute returns one summary per readable backup. A backup whose meta cannot be read is skipped, so one corrupted backup does not hide the rest.
type MigrateJob ¶ added in v0.6.1
type MigrateJob struct {
// contains filtered or unexported fields
}
MigrateJob is one registered migrate run — the migrate counterpart of DeleteJob. Registering (NewMigrateJob) is synchronous and proves the backup's meta is readable: a migrate that cannot prove what it is uploading is the caller's immediate answer, and there is no task object that can be run unregistered.
func NewMigrateJob ¶ added in v0.6.1
func NewMigrateJob(ctx context.Context, params *cfg.Config, store *jobstate.Store, req MigrateRequest) (*MigrateJob, error)
NewMigrateJob creates the cloud and backup storage clients from the config and registers the job. The clients are created per call; sharing one across calls is a lifecycle decision this layer deliberately does not make.
func (*MigrateJob) Run ¶ added in v0.6.1
func (j *MigrateJob) Run(ctx context.Context)
Run releases the job into the background and answers nothing: once the job is released there is nobody on the call path who could act on an error, so the outcome lives only in the job store, where Wait reads it.
func (*MigrateJob) Wait ¶ added in v0.6.1
func (j *MigrateJob) Wait(ctx context.Context) (jobstate.MigrateStatus, error)
Wait blocks until a Run settles and answers with the final status. It is only meaningful after Run; waiting on a job that was never started blocks until the context is done.
type MigrateRequest ¶ added in v0.6.1
MigrateRequest describes one migrate job. TaskID is the id the job registers under in the job store; BackupName is the artifact it uploads; ClusterID is the Zilliz Cloud cluster the backup migrates to.
type RestoreJob ¶ added in v0.6.1
type RestoreJob struct {
// contains filtered or unexported fields
}
RestoreJob is one registered restore job, ready to execute. A job is what a restore call makes: the restored collections are what a successful job leaves behind in the target Milvus.
Registering a job and running it are separate steps: registration happens in NewRestoreJob, synchronously, so a missing backup or an unreadable meta is the caller's immediate answer. Running is Run, which releases the job into the background; Wait blocks on the settlement.
func NewRestoreJob ¶ added in v0.6.1
func NewRestoreJob(ctx context.Context, params *cfg.Config, store *jobstate.Store, req RestoreRequest) (*RestoreJob, error)
NewRestoreJob creates both storage clients from the config and registers the job: validation against the backup storage first — the backup must exist and its meta must be readable, because a not-found backup is the caller's mistake and has to be answered before the job is registered — then the job state store. NewBackupStorage also creates the backup bucket when it is missing: a restore may target a bucket nothing has written yet. The clients are created per call; sharing them across calls is a lifecycle decision this layer deliberately does not make.
func (*RestoreJob) Run ¶ added in v0.6.1
func (j *RestoreJob) Run(ctx context.Context)
Run releases the job into the background and answers nothing: once the job is released there is nobody on the call path who could act on an error, so the outcome lives only in the job store, where Wait and the task APIs read it. The context must be process-scoped, not the request's — see AsyncJob.Run.
func (*RestoreJob) Wait ¶ added in v0.6.1
func (j *RestoreJob) Wait(ctx context.Context) (jobstate.RestoreStatus, error)
Wait blocks until a Run settles and answers with the job's snapshot in the job store — the terminal state, error message and per-collection halves are on it. It is only meaningful after Run; waiting on a job that was never started blocks until the context is done.
type RestoreRequest ¶ added in v0.6.1
type RestoreRequest struct {
// TaskID identifies the restore job in the job state store. The transport
// defaults it when its contract carries no id.
TaskID string
// BackupName names the backup artifact to restore.
BackupName string
Plan *restore.Plan
Option *restore.Option
}
RestoreRequest selects and shapes one restore. Plan and Option are the restore task's own vocabulary on purpose: each transport translates its grammar into them — the CLI from flags, v1 from its pb fields — and the two grammars do not map onto each other, so there is nothing transport-neutral to put here instead.
type RestoreSecondaryJob ¶ added in v0.6.1
type RestoreSecondaryJob struct {
// contains filtered or unexported fields
}
RestoreSecondaryJob is one registered secondary-restore job, ready to execute. A secondary restore replays the source cluster's DDL verbatim under the target cluster's id. Registration happens in NewRestoreSecondaryJob, synchronously; running is Run, exactly as on RestoreJob.
func NewRestoreSecondaryJob ¶ added in v0.6.1
func NewRestoreSecondaryJob(ctx context.Context, params *cfg.Config, store *jobstate.Store, req RestoreSecondaryRequest) (*RestoreSecondaryJob, error)
NewRestoreSecondaryJob creates both storage clients from the config and registers one secondary-restore job: validation against the backup storage first, then the job state store. The clients are created per call; sharing them across calls is a lifecycle decision this layer deliberately does not make.
func (*RestoreSecondaryJob) Run ¶ added in v0.6.1
func (j *RestoreSecondaryJob) Run(ctx context.Context)
Run releases the job into the background; see RestoreJob.Run.
func (*RestoreSecondaryJob) Wait ¶ added in v0.6.1
func (j *RestoreSecondaryJob) Wait(ctx context.Context) (jobstate.RestoreStatus, error)
Wait blocks until a Run settles; see RestoreJob.Wait.
type RestoreSecondaryRequest ¶ added in v0.6.1
type RestoreSecondaryRequest struct {
// TaskID identifies the restore job in the job state store. The transport
// defaults it when its contract carries no id.
TaskID string
// BackupName names the backup artifact to restore.
BackupName string
// SourceClusterID is the cluster the backup's DDL was taken from.
SourceClusterID string
// TargetClusterID is the cluster the DDL is replayed under.
TargetClusterID string
}
RestoreSecondaryRequest selects one secondary restore.