Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add migrate operation interface #387

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions cmd/signozschemamigrator/schema_migrator/op.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package schemamigrator

// Operation is the interface that all operations must implement.
// An Operation that is not mutation, idempotent and lightweight is expected
// to complete almost immediately given there are no blocking items in the
// distributed_ddl_queue.
// Such operations are completed synchronously and allow the release upgrade
// to proceed.
// All other operations are run asynchronously in the background and do not
// block the release upgrade.
type Operation interface {
// ToSQL returns the SQL for the alter operation
ToSQL() string
// IsMutation returns true if the operation is a mutation
IsMutation() bool
// IsIdempotent returns true if the operation is idempotent
// This is used to determine if the operation can be retried in case of a
// failure.
IsIdempotent() bool
// IsLightweight returns true if the operation is lightweight
// The lightweight operations are the ones that either modify the metadata or
// drop the delete from disk as opposed to the ones that re-write the whole
// data parts.
IsLightweight() bool

// OnCluster returns a new operation with the cluster name set
// This is used when the operation is run on a specific cluster
OnCluster(string) Operation

// WithReplication returns a new operation with the replication set
WithReplication() Operation

// ShouldWaitForDistributionQueue returns true if the operation should wait for the distribution queue to be empty
ShouldWaitForDistributionQueue() (bool, string, string)
}