jobs

package
v0.0.0-...-bf59245 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2017 License: Apache-2.0 Imports: 15 Imported by: 0

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:

BackupJobDetails
RestoreJobDetails
SchemaChangeJobDetails
JobPayload

Index

Constants

View Source
const (
	JobTypeBackup       string = "BACKUP"
	JobTypeRestore      string = "RESTORE"
	JobTypeSchemaChange string = "SCHEMA CHANGE"
)

Job types are named for the SQL query that creates them.

Variables

View Source
var (
	ErrInvalidLengthJobs = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowJobs   = fmt.Errorf("proto: integer overflow")
)

Functions

This section is empty.

Types

type BackupJobDetails

type BackupJobDetails struct {
}

func (*BackupJobDetails) Descriptor

func (*BackupJobDetails) Descriptor() ([]byte, []int)

func (*BackupJobDetails) Marshal

func (m *BackupJobDetails) Marshal() (dAtA []byte, err error)

func (*BackupJobDetails) MarshalTo

func (m *BackupJobDetails) MarshalTo(dAtA []byte) (int, error)

func (*BackupJobDetails) ProtoMessage

func (*BackupJobDetails) ProtoMessage()

func (*BackupJobDetails) Reset

func (m *BackupJobDetails) Reset()

func (*BackupJobDetails) Size

func (m *BackupJobDetails) Size() (n int)

func (*BackupJobDetails) String

func (m *BackupJobDetails) String() string

func (*BackupJobDetails) Unmarshal

func (m *BackupJobDetails) Unmarshal(dAtA []byte) error

type JobDetails

type JobDetails interface{}

JobDetails is a marker interface for job details proto structs.

type JobLogger

type JobLogger struct {
	Job JobRecord
	// contains filtered or unexported fields
}

JobLogger manages logging the progress of long-running system processes, like backups and restores, to the system.jobs table.

The Job field can be directly modified before Created is called. Updates to the Job field after the job has been created will not be written to the database, however, even when calling e.g. Started or Succeeded.

func GetJobLogger

func GetJobLogger(
	ctx context.Context, db *client.DB, ex sqlutil.InternalExecutor, jobID int64,
) (*JobLogger, error)

GetJobLogger creates a new JobLogger initialized from a previously created job id.

func NewJobLogger

func NewJobLogger(db *client.DB, ex sqlutil.InternalExecutor, job JobRecord) *JobLogger

NewJobLogger creates a new JobLogger.

func (*JobLogger) Created

func (jl *JobLogger) Created(ctx context.Context) error

Created records the creation of a new job in the system.jobs table and remembers the assigned ID of the job in the JobLogger. The job information is read from the Job field at the time Created is called.

func (*JobLogger) Failed

func (jl *JobLogger) Failed(ctx context.Context, err error)

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 (*JobLogger) JobID

func (jl *JobLogger) JobID() *int64

JobID returns the ID of the job that this JobLogger is currently tracking. This will be nil if Created has not yet been called.

func (*JobLogger) Payload

func (jl *JobLogger) Payload() JobPayload

Payload returns the most recently sent JobPayload for this JobLogger. Will return an empty JobPayload until Created() is called on a new JobLogger.

func (*JobLogger) Progressed

func (jl *JobLogger) 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 (*JobLogger) Started

func (jl *JobLogger) Started(ctx context.Context) error

Started marks the tracked job as started.

func (*JobLogger) Succeeded

func (jl *JobLogger) Succeeded(ctx context.Context) error

Succeeded marks the tracked job as having succeeded and sets its fraction completed to 1.0.

func (*JobLogger) WithTxn

func (jl *JobLogger) WithTxn(txn *client.Txn) *JobLogger

WithTxn sets the transaction that this JobLogger will use for its next operation. If the transaction is nil, the JobLogger will create a one-off transaction instead. If you use WithTxn, this JobLogger will no longer be threadsafe.

type JobPayload

type JobPayload 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"`
	// Types that are valid to be assigned to Details:
	//	*JobPayload_Backup
	//	*JobPayload_Restore
	//	*JobPayload_SchemaChange
	Details isJobPayload_Details `protobuf_oneof:"details"`
}

func UnmarshalJobPayload

func UnmarshalJobPayload(datum parser.Datum) (*JobPayload, error)

UnmarshalJobPayload unmarshals and returns the JobPayload encoded in the input datum, which should be a DBytes.

func (*JobPayload) Descriptor

func (*JobPayload) Descriptor() ([]byte, []int)

func (*JobPayload) GetBackup

func (m *JobPayload) GetBackup() *BackupJobDetails

func (*JobPayload) GetDetails

func (m *JobPayload) GetDetails() isJobPayload_Details

func (*JobPayload) GetRestore

func (m *JobPayload) GetRestore() *RestoreJobDetails

func (*JobPayload) GetSchemaChange

func (m *JobPayload) GetSchemaChange() *SchemaChangeJobDetails

func (*JobPayload) Marshal

func (m *JobPayload) Marshal() (dAtA []byte, err error)

func (*JobPayload) MarshalTo

func (m *JobPayload) MarshalTo(dAtA []byte) (int, error)

func (*JobPayload) ProtoMessage

func (*JobPayload) ProtoMessage()

func (*JobPayload) Reset

func (m *JobPayload) Reset()

func (*JobPayload) Size

func (m *JobPayload) Size() (n int)

func (*JobPayload) String

func (m *JobPayload) String() string

func (*JobPayload) Typ

func (jp *JobPayload) Typ() string

Typ returns the payload's job type.

func (*JobPayload) Unmarshal

func (m *JobPayload) Unmarshal(dAtA []byte) error

func (*JobPayload) XXX_OneofFuncs

func (*JobPayload) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{})

XXX_OneofFuncs is for the internal use of the proto package.

type JobPayload_Backup

type JobPayload_Backup struct {
	Backup *BackupJobDetails `protobuf:"bytes,10,opt,name=backup,oneof"`
}

func (*JobPayload_Backup) MarshalTo

func (m *JobPayload_Backup) MarshalTo(dAtA []byte) (int, error)

func (*JobPayload_Backup) Size

func (m *JobPayload_Backup) Size() (n int)

type JobPayload_Restore

type JobPayload_Restore struct {
	Restore *RestoreJobDetails `protobuf:"bytes,11,opt,name=restore,oneof"`
}

func (*JobPayload_Restore) MarshalTo

func (m *JobPayload_Restore) MarshalTo(dAtA []byte) (int, error)

func (*JobPayload_Restore) Size

func (m *JobPayload_Restore) Size() (n int)

type JobPayload_SchemaChange

type JobPayload_SchemaChange struct {
	SchemaChange *SchemaChangeJobDetails `protobuf:"bytes,12,opt,name=schemaChange,oneof"`
}

func (*JobPayload_SchemaChange) MarshalTo

func (m *JobPayload_SchemaChange) MarshalTo(dAtA []byte) (int, error)

func (*JobPayload_SchemaChange) Size

func (m *JobPayload_SchemaChange) Size() (n int)

type JobRecord

type JobRecord struct {
	Description   string
	Username      string
	DescriptorIDs sqlbase.IDs
	Details       JobDetails
}

JobRecord stores the job fields that are not automatically managed by JobLogger.

type JobStatus

type JobStatus string

JobStatus represents the status of a job in the system.jobs table.

const (
	// JobStatusPending is for jobs that have been created but on which work has
	// not yet started.
	JobStatusPending JobStatus = "pending"
	// JobStatusRunning is for jobs that are currently in progress.
	JobStatusRunning JobStatus = "running"
	// JobStatusFailed is for jobs that failed.
	JobStatusFailed JobStatus = "failed"
	// JobStatusSucceeded is for jobs that have successfully completed.
	JobStatusSucceeded JobStatus = "succeeded"
)

type ProgressedFn

type ProgressedFn func(ctx context.Context, details interface{})

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 RestoreJobDetails

type RestoreJobDetails struct {
	LowWaterMark []byte `protobuf:"bytes,1,opt,name=low_water_mark,json=lowWaterMark,proto3" json:"low_water_mark,omitempty"`
}

func (*RestoreJobDetails) Descriptor

func (*RestoreJobDetails) Descriptor() ([]byte, []int)

func (*RestoreJobDetails) Marshal

func (m *RestoreJobDetails) Marshal() (dAtA []byte, err error)

func (*RestoreJobDetails) MarshalTo

func (m *RestoreJobDetails) MarshalTo(dAtA []byte) (int, error)

func (*RestoreJobDetails) ProtoMessage

func (*RestoreJobDetails) ProtoMessage()

func (*RestoreJobDetails) Reset

func (m *RestoreJobDetails) Reset()

func (*RestoreJobDetails) Size

func (m *RestoreJobDetails) Size() (n int)

func (*RestoreJobDetails) String

func (m *RestoreJobDetails) String() string

func (*RestoreJobDetails) Unmarshal

func (m *RestoreJobDetails) Unmarshal(dAtA []byte) error

type SchemaChangeJobDetails

type SchemaChangeJobDetails struct {
}

func (*SchemaChangeJobDetails) Descriptor

func (*SchemaChangeJobDetails) Descriptor() ([]byte, []int)

func (*SchemaChangeJobDetails) Marshal

func (m *SchemaChangeJobDetails) Marshal() (dAtA []byte, err error)

func (*SchemaChangeJobDetails) MarshalTo

func (m *SchemaChangeJobDetails) MarshalTo(dAtA []byte) (int, error)

func (*SchemaChangeJobDetails) ProtoMessage

func (*SchemaChangeJobDetails) ProtoMessage()

func (*SchemaChangeJobDetails) Reset

func (m *SchemaChangeJobDetails) Reset()

func (*SchemaChangeJobDetails) Size

func (m *SchemaChangeJobDetails) Size() (n int)

func (*SchemaChangeJobDetails) String

func (m *SchemaChangeJobDetails) String() string

func (*SchemaChangeJobDetails) Unmarshal

func (m *SchemaChangeJobDetails) Unmarshal(dAtA []byte) error

Jump to

Keyboard shortcuts

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