Documentation ¶
Overview ¶
Package jobs is a generated protocol buffer package.
It is generated from these files:
cockroach/pkg/sql/jobs/jobs.proto
It has these top-level messages:
Lease BackupDetails RestoreDetails ImportDetails ResumeSpanList SchemaChangeDetails Payload
Index ¶
- Constants
- Variables
- func AddResumeHook(fn resumeHookFn)
- func WrapPayloadDetails(details Details) interface{ ... }
- type BackupDetails
- func (*BackupDetails) Descriptor() ([]byte, []int)
- func (m *BackupDetails) Marshal() (dAtA []byte, err error)
- func (m *BackupDetails) MarshalTo(dAtA []byte) (int, error)
- func (*BackupDetails) ProtoMessage()
- func (m *BackupDetails) Reset()
- func (m *BackupDetails) Size() (n int)
- func (m *BackupDetails) String() string
- func (m *BackupDetails) Unmarshal(dAtA []byte) error
- type Details
- type ImportDetails
- func (*ImportDetails) Descriptor() ([]byte, []int)
- func (m *ImportDetails) Marshal() (dAtA []byte, err error)
- func (m *ImportDetails) MarshalTo(dAtA []byte) (int, error)
- func (*ImportDetails) ProtoMessage()
- func (m *ImportDetails) Reset()
- func (m *ImportDetails) Size() (n int)
- func (m *ImportDetails) String() string
- func (m *ImportDetails) Unmarshal(dAtA []byte) error
- type ImportDetails_Table
- func (*ImportDetails_Table) Descriptor() ([]byte, []int)
- func (m *ImportDetails_Table) Marshal() (dAtA []byte, err error)
- func (m *ImportDetails_Table) MarshalTo(dAtA []byte) (int, error)
- func (*ImportDetails_Table) ProtoMessage()
- func (m *ImportDetails_Table) Reset()
- func (m *ImportDetails_Table) Size() (n int)
- func (m *ImportDetails_Table) String() string
- func (m *ImportDetails_Table) Unmarshal(dAtA []byte) error
- type InvalidStatusError
- type Job
- func (j *Job) Canceled(ctx context.Context) error
- func (j *Job) ClusterID() uuid.UUID
- func (j *Job) Created(ctx context.Context, cancelFn func()) error
- func (j *Job) DB() *client.DB
- func (j *Job) Failed(ctx context.Context, err error)
- func (j *Job) FinishedWith(ctx context.Context, err error) error
- func (j *Job) Gossip() *gossip.Gossip
- func (j *Job) ID() *int64
- func (j *Job) NodeID() roachpb.NodeID
- func (j *Job) Paused(ctx context.Context) error
- func (j *Job) Payload() Payload
- func (j *Job) Progressed(ctx context.Context, fractionCompleted float32, progressedFn ProgressedFn) error
- func (j *Job) Resumed(ctx context.Context) error
- func (j *Job) SetDetails(ctx context.Context, details interface{}) error
- func (j *Job) Started(ctx context.Context) error
- func (j *Job) Succeeded(ctx context.Context) error
- func (j *Job) WithTxn(txn *client.Txn) *Job
- type Lease
- func (*Lease) Descriptor() ([]byte, []int)
- func (this *Lease) Equal(that interface{}) bool
- func (m *Lease) Marshal() (dAtA []byte, err error)
- func (m *Lease) MarshalTo(dAtA []byte) (int, error)
- func (*Lease) ProtoMessage()
- func (m *Lease) Reset()
- func (m *Lease) Size() (n int)
- func (m *Lease) String() string
- func (m *Lease) Unmarshal(dAtA []byte) error
- type Payload
- func (*Payload) Descriptor() ([]byte, []int)
- func (m *Payload) GetBackup() *BackupDetails
- func (m *Payload) GetDetails() isPayload_Details
- func (m *Payload) GetImport() *ImportDetails
- func (m *Payload) GetRestore() *RestoreDetails
- func (m *Payload) GetSchemaChange() *SchemaChangeDetails
- func (m *Payload) Marshal() (dAtA []byte, err error)
- func (m *Payload) MarshalTo(dAtA []byte) (int, error)
- func (*Payload) ProtoMessage()
- func (m *Payload) Reset()
- func (m *Payload) Size() (n int)
- func (m *Payload) String() string
- func (p *Payload) Type() Type
- func (m *Payload) Unmarshal(dAtA []byte) error
- func (p *Payload) UnwrapDetails() (Details, error)
- func (*Payload) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, ...)
- type Payload_Backup
- type Payload_Import
- type Payload_Restore
- type Payload_SchemaChange
- type ProgressedFn
- type Record
- type Registry
- func (r *Registry) LoadJob(ctx context.Context, jobID int64) (*Job, error)
- func (r *Registry) LoadJobWithTxn(ctx context.Context, jobID int64, txn *client.Txn) (*Job, error)
- func (r *Registry) NewJob(record Record) *Job
- func (r *Registry) Start(ctx context.Context, stopper *stop.Stopper, nl nodeLiveness, ...) error
- type RestoreDetails
- func (*RestoreDetails) Descriptor() ([]byte, []int)
- func (m *RestoreDetails) Marshal() (dAtA []byte, err error)
- func (m *RestoreDetails) MarshalTo(dAtA []byte) (int, error)
- func (*RestoreDetails) ProtoMessage()
- func (m *RestoreDetails) Reset()
- func (m *RestoreDetails) Size() (n int)
- func (m *RestoreDetails) String() string
- func (m *RestoreDetails) Unmarshal(dAtA []byte) error
- type RestoreDetails_TableRewrite
- func (*RestoreDetails_TableRewrite) Descriptor() ([]byte, []int)
- func (m *RestoreDetails_TableRewrite) Marshal() (dAtA []byte, err error)
- func (m *RestoreDetails_TableRewrite) MarshalTo(dAtA []byte) (int, error)
- func (*RestoreDetails_TableRewrite) ProtoMessage()
- func (m *RestoreDetails_TableRewrite) Reset()
- func (m *RestoreDetails_TableRewrite) Size() (n int)
- func (m *RestoreDetails_TableRewrite) String() string
- func (m *RestoreDetails_TableRewrite) Unmarshal(dAtA []byte) error
- type ResumeSpanList
- func (*ResumeSpanList) Descriptor() ([]byte, []int)
- func (m *ResumeSpanList) Marshal() (dAtA []byte, err error)
- func (m *ResumeSpanList) MarshalTo(dAtA []byte) (int, error)
- func (*ResumeSpanList) ProtoMessage()
- func (m *ResumeSpanList) Reset()
- func (m *ResumeSpanList) Size() (n int)
- func (m *ResumeSpanList) String() string
- func (m *ResumeSpanList) Unmarshal(dAtA []byte) error
- type SchemaChangeDetails
- func (*SchemaChangeDetails) Descriptor() ([]byte, []int)
- func (m *SchemaChangeDetails) Marshal() (dAtA []byte, err error)
- func (m *SchemaChangeDetails) MarshalTo(dAtA []byte) (int, error)
- func (*SchemaChangeDetails) ProtoMessage()
- func (m *SchemaChangeDetails) Reset()
- func (m *SchemaChangeDetails) Size() (n int)
- func (m *SchemaChangeDetails) String() string
- func (m *SchemaChangeDetails) Unmarshal(dAtA []byte) error
- type Status
- type Type
Constants ¶
const DefaultCancelInterval = base.DefaultHeartbeatInterval
DefaultCancelInterval is a reasonable interval at which to poll this node for liveness failures and cancel running jobs.
Variables ¶
var ( ErrInvalidLengthJobs = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowJobs = fmt.Errorf("proto: integer overflow") )
var DefaultAdoptInterval = 30 * time.Second
DefaultAdoptInterval is a reasonable interval at which to poll system.jobs for jobs with expired leases.
DefaultAdoptInterval is mutable for testing. NB: Updates to this value after Registry.Start has been called will not have any effect.
var Type_name = map[int32]string{
0: "UNSPECIFIED",
1: "BACKUP",
2: "RESTORE",
3: "SCHEMA_CHANGE",
4: "IMPORT",
}
var Type_value = map[string]int32{
"UNSPECIFIED": 0,
"BACKUP": 1,
"RESTORE": 2,
"SCHEMA_CHANGE": 3,
"IMPORT": 4,
}
var WithoutCancel func()
WithoutCancel indicates that the job should not have its leasing and cancelation managed by Registry. This is only a temporary measure; eventually all jobs will use the Registry's leasing and cancelation.
Functions ¶
func WrapPayloadDetails ¶
func WrapPayloadDetails(details Details) interface { isPayload_Details }
WrapPayloadDetails wraps a Details object in the protobuf wrapper struct necessary to make it usable as the Details field of a Payload.
Providing an unknown details type indicates programmer error and so causes a panic.
Types ¶
type BackupDetails ¶
type BackupDetails struct { StartTime cockroach_util_hlc.Timestamp `protobuf:"bytes,1,opt,name=start_time,json=startTime" json:"start_time"` EndTime cockroach_util_hlc.Timestamp `protobuf:"bytes,2,opt,name=end_time,json=endTime" json:"end_time"` URI string `protobuf:"bytes,3,opt,name=uri,proto3" json:"uri,omitempty"` }
func (*BackupDetails) Descriptor ¶
func (*BackupDetails) Descriptor() ([]byte, []int)
func (*BackupDetails) Marshal ¶
func (m *BackupDetails) Marshal() (dAtA []byte, err error)
func (*BackupDetails) ProtoMessage ¶
func (*BackupDetails) ProtoMessage()
func (*BackupDetails) Reset ¶
func (m *BackupDetails) Reset()
func (*BackupDetails) Size ¶
func (m *BackupDetails) Size() (n int)
func (*BackupDetails) String ¶
func (m *BackupDetails) String() string
func (*BackupDetails) Unmarshal ¶
func (m *BackupDetails) Unmarshal(dAtA []byte) error
type Details ¶
type Details interface{}
Details is a marker interface for job details proto structs.
type ImportDetails ¶
type ImportDetails struct {
Tables []ImportDetails_Table `protobuf:"bytes,1,rep,name=tables" json:"tables"`
}
func (*ImportDetails) Descriptor ¶
func (*ImportDetails) Descriptor() ([]byte, []int)
func (*ImportDetails) Marshal ¶
func (m *ImportDetails) Marshal() (dAtA []byte, err error)
func (*ImportDetails) ProtoMessage ¶
func (*ImportDetails) ProtoMessage()
func (*ImportDetails) Reset ¶
func (m *ImportDetails) Reset()
func (*ImportDetails) Size ¶
func (m *ImportDetails) Size() (n int)
func (*ImportDetails) String ¶
func (m *ImportDetails) String() string
func (*ImportDetails) Unmarshal ¶
func (m *ImportDetails) Unmarshal(dAtA []byte) error
type ImportDetails_Table ¶
type ImportDetails_Table struct { Desc *cockroach_sql_sqlbase1.TableDescriptor `protobuf:"bytes,1,opt,name=desc" json:"desc,omitempty"` URIs []string `protobuf:"bytes,2,rep,name=uris" json:"uris,omitempty"` Options *cockroach_roachpb1.CSVOptions `protobuf:"bytes,3,opt,name=options" json:"options,omitempty"` BackupPath string `protobuf:"bytes,4,opt,name=backup_path,json=backupPath,proto3" json:"backup_path,omitempty"` }
func (*ImportDetails_Table) Descriptor ¶
func (*ImportDetails_Table) Descriptor() ([]byte, []int)
func (*ImportDetails_Table) Marshal ¶
func (m *ImportDetails_Table) Marshal() (dAtA []byte, err error)
func (*ImportDetails_Table) MarshalTo ¶
func (m *ImportDetails_Table) MarshalTo(dAtA []byte) (int, error)
func (*ImportDetails_Table) ProtoMessage ¶
func (*ImportDetails_Table) ProtoMessage()
func (*ImportDetails_Table) Reset ¶
func (m *ImportDetails_Table) Reset()
func (*ImportDetails_Table) Size ¶
func (m *ImportDetails_Table) Size() (n int)
func (*ImportDetails_Table) String ¶
func (m *ImportDetails_Table) String() string
func (*ImportDetails_Table) Unmarshal ¶
func (m *ImportDetails_Table) Unmarshal(dAtA []byte) error
type InvalidStatusError ¶
type InvalidStatusError struct {
// contains filtered or unexported fields
}
InvalidStatusError is the error returned when the desired operation is invalid given the job's current status.
func (*InvalidStatusError) Error ¶
func (e *InvalidStatusError) Error() string
type Job ¶
type Job struct { Record Record // contains filtered or unexported fields }
Job manages logging the progress of long-running system processes, like backups and restores, to the system.jobs table.
The Record field can be directly modified before Created is called. Updates to the Record field after the job has been created will not be written to the database, however, even when calling e.g. Started or Succeeded.
func (*Job) Canceled ¶
Canceled sets the status of the tracked job to canceled. It does not directly cancel the job; like job.Paused, it expects the job to call job.Progressed soon, observe a "job is canceled" error, and abort further work.
func (*Job) Created ¶
Created records the creation of a new job in the system.jobs table and remembers the assigned ID of the job in the Job. The job information is read from the Record field at the time Created is called. If cancelFn is not nil, the Registry will automatically acquire a lease for this job and invoke cancelFn if the lease expires.
func (*Job) Failed ¶
Failed marks the tracked job as having failed with the given error. Any errors encountered while updating the jobs table are logged but not returned, under the assumption that the the caller is already handling a more important error and doesn't care about this one.
func (*Job) FinishedWith ¶
FinishedWith is a shortcut for automatically calling Succeeded or Failed based on the presence of err. Any non-nil error is taken to mean that the job has failed. The error returned, if any, is serious enough that it should not be logged and ignored.
TODO(benesch): Fix this wonky API. Once schema change leases are managed by this package, replace Succeeded, Failed, and FinishedWith with an API like
func (r *Registry) RunJob(setupFn func() Details, workFn func() error) (result, error)
where RunJob handles writing to system.jobs automatically.
func (*Job) ID ¶
ID returns the ID of the job that this Job is currently tracking. This will be nil if Created has not yet been called.
func (*Job) Paused ¶
Paused sets the status of the tracked job to paused. It does not directly pause the job; instead, it expects the job to call job.Progressed soon, observe a "job is paused" error, and abort further work.
func (*Job) Payload ¶
Payload returns the most recently sent Payload for this Job. Will return an empty Payload until Created() is called on a new Job.
func (*Job) Progressed ¶
func (j *Job) Progressed( ctx context.Context, fractionCompleted float32, progressedFn ProgressedFn, ) error
Progressed updates the progress of the tracked job to fractionCompleted. A fractionCompleted that is less than the currently-recorded fractionCompleted will be silently ignored. If progressedFn is non-nil, it will be invoked with a pointer to the job's details to allow for modifications to the details before the job is saved. If no such modifications are required, pass Noop instead of nil for readability.
func (*Job) Resumed ¶
Resumed sets the status of the tracked job to running iff the job is currently paused. It does not directly resume the job; rather, it expires the job's lease so that a Registry adoption loop detects it and resumes it.
func (*Job) SetDetails ¶
SetDetails sets the details field of the currently running tracked job.
type Lease ¶
type Lease struct { // The ID of the node that holds the lease. NodeID github_com_cockroachdb_cockroach_pkg_roachpb.NodeID `` /* 141-byte string literal not displayed */ // The epoch of the lease holder's node liveness entry. Epoch int64 `protobuf:"varint,2,opt,name=epoch,proto3" json:"epoch,omitempty"` }
func (*Lease) Descriptor ¶
func (*Lease) ProtoMessage ¶
func (*Lease) ProtoMessage()
type Payload ¶
type Payload struct { Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"` // For consistency with the SQL timestamp type, which has microsecond // precision, we avoid the timestamp.Timestamp WKT, which has nanosecond // precision, and use microsecond integers directly. StartedMicros int64 `protobuf:"varint,3,opt,name=started_micros,json=startedMicros,proto3" json:"started_micros,omitempty"` FinishedMicros int64 `protobuf:"varint,4,opt,name=finished_micros,json=finishedMicros,proto3" json:"finished_micros,omitempty"` ModifiedMicros int64 `protobuf:"varint,5,opt,name=modified_micros,json=modifiedMicros,proto3" json:"modified_micros,omitempty"` DescriptorIDs []github_com_cockroachdb_cockroach_pkg_sql_sqlbase.ID `` /* 162-byte string literal not displayed */ FractionCompleted float32 `protobuf:"fixed32,7,opt,name=fraction_completed,json=fractionCompleted,proto3" json:"fraction_completed,omitempty"` Error string `protobuf:"bytes,8,opt,name=error,proto3" json:"error,omitempty"` // ID 9 is intentionally reserved for lease information. Lease *Lease `protobuf:"bytes,9,opt,name=lease" json:"lease,omitempty"` // Types that are valid to be assigned to Details: // *Payload_Backup // *Payload_Restore // *Payload_SchemaChange // *Payload_Import Details isPayload_Details `protobuf_oneof:"details"` }
func UnmarshalPayload ¶
UnmarshalPayload unmarshals and returns the Payload encoded in the input datum, which should be a parser.DBytes.
func (*Payload) Descriptor ¶
func (*Payload) GetBackup ¶
func (m *Payload) GetBackup() *BackupDetails
func (*Payload) GetDetails ¶
func (m *Payload) GetDetails() isPayload_Details
func (*Payload) GetImport ¶
func (m *Payload) GetImport() *ImportDetails
func (*Payload) GetRestore ¶
func (m *Payload) GetRestore() *RestoreDetails
func (*Payload) GetSchemaChange ¶
func (m *Payload) GetSchemaChange() *SchemaChangeDetails
func (*Payload) ProtoMessage ¶
func (*Payload) ProtoMessage()
func (*Payload) UnwrapDetails ¶
UnwrapDetails returns the details object stored within the payload's Details field, discarding the protobuf wrapper struct.
Unlike in WrapPayloadDetails, an unknown details type may simply indicate that the Payload originated on a node aware of more details types, and so the error is returned to the caller.
type Payload_Backup ¶
type Payload_Backup struct {
Backup *BackupDetails `protobuf:"bytes,10,opt,name=backup,oneof"`
}
func (*Payload_Backup) Size ¶
func (m *Payload_Backup) Size() (n int)
type Payload_Import ¶
type Payload_Import struct {
Import *ImportDetails `protobuf:"bytes,13,opt,name=import,oneof"`
}
func (*Payload_Import) Size ¶
func (m *Payload_Import) Size() (n int)
type Payload_Restore ¶
type Payload_Restore struct {
Restore *RestoreDetails `protobuf:"bytes,11,opt,name=restore,oneof"`
}
func (*Payload_Restore) Size ¶
func (m *Payload_Restore) Size() (n int)
type Payload_SchemaChange ¶
type Payload_SchemaChange struct {
SchemaChange *SchemaChangeDetails `protobuf:"bytes,12,opt,name=schemaChange,oneof"`
}
func (*Payload_SchemaChange) MarshalTo ¶
func (m *Payload_SchemaChange) MarshalTo(dAtA []byte) (int, error)
func (*Payload_SchemaChange) Size ¶
func (m *Payload_SchemaChange) Size() (n int)
type ProgressedFn ¶
ProgressedFn is a callback that allows arbitrary modifications to a job's details when updating its progress.
var Noop ProgressedFn
Noop is a nil ProgressedFn.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry creates Jobs and manages their leases and cancelation.
func MakeRegistry ¶
func MakeRegistry( clock *hlc.Clock, db *client.DB, ex sqlutil.InternalExecutor, gossip *gossip.Gossip, nodeID *base.NodeIDContainer, clusterID func() uuid.UUID, ) *Registry
MakeRegistry creates a new Registry.
func (*Registry) LoadJob ¶
LoadJob loads an existing job with the given jobID from the system.jobs table.
func (*Registry) LoadJobWithTxn ¶
LoadJobWithTxn does the same as above, but using the transaction passed in the txn argument. Passing a nil transaction is equivalent to calling LoadJob in that a transaction will be automatically created.
type RestoreDetails ¶
type RestoreDetails struct { LowWaterMark []byte `protobuf:"bytes,1,opt,name=low_water_mark,json=lowWaterMark,proto3" json:"low_water_mark,omitempty"` TableRewrites map[github_com_cockroachdb_cockroach_pkg_sql_sqlbase.ID]*RestoreDetails_TableRewrite `` /* 235-byte string literal not displayed */ URIs []string `protobuf:"bytes,3,rep,name=uris" json:"uris,omitempty"` }
func (*RestoreDetails) Descriptor ¶
func (*RestoreDetails) Descriptor() ([]byte, []int)
func (*RestoreDetails) Marshal ¶
func (m *RestoreDetails) Marshal() (dAtA []byte, err error)
func (*RestoreDetails) ProtoMessage ¶
func (*RestoreDetails) ProtoMessage()
func (*RestoreDetails) Reset ¶
func (m *RestoreDetails) Reset()
func (*RestoreDetails) Size ¶
func (m *RestoreDetails) Size() (n int)
func (*RestoreDetails) String ¶
func (m *RestoreDetails) String() string
func (*RestoreDetails) Unmarshal ¶
func (m *RestoreDetails) Unmarshal(dAtA []byte) error
type RestoreDetails_TableRewrite ¶
type RestoreDetails_TableRewrite struct { TableID github_com_cockroachdb_cockroach_pkg_sql_sqlbase.ID `` /* 144-byte string literal not displayed */ ParentID github_com_cockroachdb_cockroach_pkg_sql_sqlbase.ID `` /* 147-byte string literal not displayed */ }
func (*RestoreDetails_TableRewrite) Descriptor ¶
func (*RestoreDetails_TableRewrite) Descriptor() ([]byte, []int)
func (*RestoreDetails_TableRewrite) Marshal ¶
func (m *RestoreDetails_TableRewrite) Marshal() (dAtA []byte, err error)
func (*RestoreDetails_TableRewrite) MarshalTo ¶
func (m *RestoreDetails_TableRewrite) MarshalTo(dAtA []byte) (int, error)
func (*RestoreDetails_TableRewrite) ProtoMessage ¶
func (*RestoreDetails_TableRewrite) ProtoMessage()
func (*RestoreDetails_TableRewrite) Reset ¶
func (m *RestoreDetails_TableRewrite) Reset()
func (*RestoreDetails_TableRewrite) Size ¶
func (m *RestoreDetails_TableRewrite) Size() (n int)
func (*RestoreDetails_TableRewrite) String ¶
func (m *RestoreDetails_TableRewrite) String() string
func (*RestoreDetails_TableRewrite) Unmarshal ¶
func (m *RestoreDetails_TableRewrite) Unmarshal(dAtA []byte) error
type ResumeSpanList ¶
type ResumeSpanList struct {
ResumeSpans []cockroach_roachpb1.Span `protobuf:"bytes,1,rep,name=resume_spans,json=resumeSpans" json:"resume_spans"`
}
func (*ResumeSpanList) Descriptor ¶
func (*ResumeSpanList) Descriptor() ([]byte, []int)
func (*ResumeSpanList) Marshal ¶
func (m *ResumeSpanList) Marshal() (dAtA []byte, err error)
func (*ResumeSpanList) ProtoMessage ¶
func (*ResumeSpanList) ProtoMessage()
func (*ResumeSpanList) Reset ¶
func (m *ResumeSpanList) Reset()
func (*ResumeSpanList) Size ¶
func (m *ResumeSpanList) Size() (n int)
func (*ResumeSpanList) String ¶
func (m *ResumeSpanList) String() string
func (*ResumeSpanList) Unmarshal ¶
func (m *ResumeSpanList) Unmarshal(dAtA []byte) error
type SchemaChangeDetails ¶
type SchemaChangeDetails struct { ReadAsOf cockroach_util_hlc.Timestamp `protobuf:"bytes,1,opt,name=read_as_of,json=readAsOf" json:"read_as_of"` // A schema change can involve running multiple processors backfilling // or deleting data. They occasionally checkpoint Spans so that the // processing can resume in the event of a node failure. The spans are // non-overlapping contiguous areas of the KV space that still need to // be processed. The index represents the index of a mutation in a // mutation list containing mutations for the same mutationID. ResumeSpanList []ResumeSpanList `protobuf:"bytes,2,rep,name=resume_span_list,json=resumeSpanList" json:"resume_span_list"` }
func (*SchemaChangeDetails) Descriptor ¶
func (*SchemaChangeDetails) Descriptor() ([]byte, []int)
func (*SchemaChangeDetails) Marshal ¶
func (m *SchemaChangeDetails) Marshal() (dAtA []byte, err error)
func (*SchemaChangeDetails) MarshalTo ¶
func (m *SchemaChangeDetails) MarshalTo(dAtA []byte) (int, error)
func (*SchemaChangeDetails) ProtoMessage ¶
func (*SchemaChangeDetails) ProtoMessage()
func (*SchemaChangeDetails) Reset ¶
func (m *SchemaChangeDetails) Reset()
func (*SchemaChangeDetails) Size ¶
func (m *SchemaChangeDetails) Size() (n int)
func (*SchemaChangeDetails) String ¶
func (m *SchemaChangeDetails) String() string
func (*SchemaChangeDetails) Unmarshal ¶
func (m *SchemaChangeDetails) Unmarshal(dAtA []byte) error
type Status ¶
type Status string
Status represents the status of a job in the system.jobs table.
const ( // StatusPending is for jobs that have been created but on which work has // not yet started. StatusPending Status = "pending" // StatusRunning is for jobs that are currently in progress. StatusRunning Status = "running" // StatusPaused is for jobs that are not currently performing work, but have // saved their state and can be resumed by the user later. StatusPaused Status = "paused" // StatusFailed is for jobs that failed. StatusFailed Status = "failed" // StatusSucceeded is for jobs that have successfully completed. StatusSucceeded Status = "succeeded" // StatusCanceled is for jobs that were explicitly canceled by the user and // cannot be resumed. StatusCanceled Status = "canceled" )
func RunAndWaitForTerminalState ¶
func RunAndWaitForTerminalState( ctx context.Context, sqlDB *gosql.DB, execFn func(context.Context) error, ) (int64, Status, error)
RunAndWaitForTerminalState runs a closure and potentially tracks its progress using the system.jobs table.
If the closure returns before a jobs entry is created, the closure's error is passed back with no job information. Otherwise, the first jobs entry created after the closure starts is polled until it enters a terminal state and that job's id, status, and error are returned.
TODO(dan): Return a *Job instead of just the id and status.
TODO(dan): This assumes that the next entry to the jobs table was made by this closure, but this assumption is quite racy. See if we can do something better.