updater

package
v0.0.0-...-51f9457 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package updater fetches latest CL data from Gerrit.

Index

Constants

View Source
const (
	TaskClass      = "refresh-gerrit-cl"
	TaskClassBatch = "batch-refresh-gerrit-cl"
)

Variables

View Source
var File_go_chromium_org_luci_cv_internal_gerrit_updater_tasks_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type BatchRefreshGerritCL

type BatchRefreshGerritCL struct {
	Tasks []*RefreshGerritCL `protobuf:"bytes,1,rep,name=tasks,proto3" json:"tasks,omitempty"`
	// contains filtered or unexported fields
}

BatchRefreshGerritCL is a batch of RefreshGerritCL tasks.

Queue: "refresh-gerrit-cl".

func (*BatchRefreshGerritCL) Descriptor deprecated

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

Deprecated: Use BatchRefreshGerritCL.ProtoReflect.Descriptor instead.

func (*BatchRefreshGerritCL) GetTasks

func (x *BatchRefreshGerritCL) GetTasks() []*RefreshGerritCL

func (*BatchRefreshGerritCL) ProtoMessage

func (*BatchRefreshGerritCL) ProtoMessage()

func (*BatchRefreshGerritCL) ProtoReflect

func (x *BatchRefreshGerritCL) ProtoReflect() protoreflect.Message

func (*BatchRefreshGerritCL) Reset

func (x *BatchRefreshGerritCL) Reset()

func (*BatchRefreshGerritCL) String

func (x *BatchRefreshGerritCL) String() string

type RefreshGerritCL

type RefreshGerritCL struct {
	LuciProject string `protobuf:"bytes,1,opt,name=luci_project,json=luciProject,proto3" json:"luci_project,omitempty"`
	Host        string `protobuf:"bytes,2,opt,name=host,proto3" json:"host,omitempty"`
	Change      int64  `protobuf:"varint,3,opt,name=change,proto3" json:"change,omitempty"`
	// Optional fields.
	UpdatedHint *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=updated_hint,json=updatedHint,proto3" json:"updated_hint,omitempty"`
	ClidHint    int64                  `protobuf:"varint,5,opt,name=clid_hint,json=clidHint,proto3" json:"clid_hint,omitempty"`
	// contains filtered or unexported fields
}

RefreshGerritCL fetches latest Gerrit data and saves it to a CL snapshot.

Queue: "refresh-gerrit-cl".

func (*RefreshGerritCL) Descriptor deprecated

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

Deprecated: Use RefreshGerritCL.ProtoReflect.Descriptor instead.

func (*RefreshGerritCL) GetChange

func (x *RefreshGerritCL) GetChange() int64

func (*RefreshGerritCL) GetClidHint

func (x *RefreshGerritCL) GetClidHint() int64

func (*RefreshGerritCL) GetHost

func (x *RefreshGerritCL) GetHost() string

func (*RefreshGerritCL) GetLuciProject

func (x *RefreshGerritCL) GetLuciProject() string

func (*RefreshGerritCL) GetUpdatedHint

func (x *RefreshGerritCL) GetUpdatedHint() *timestamppb.Timestamp

func (*RefreshGerritCL) ProtoMessage

func (*RefreshGerritCL) ProtoMessage()

func (*RefreshGerritCL) ProtoReflect

func (x *RefreshGerritCL) ProtoReflect() protoreflect.Message

func (*RefreshGerritCL) Reset

func (x *RefreshGerritCL) Reset()

func (*RefreshGerritCL) String

func (x *RefreshGerritCL) String() string

type Updater

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

Updater fetches Gerrit Change details and stores them as CV CLs in Datastore.

func New

New creates a new Updater.

func (*Updater) Refresh

func (u *Updater) Refresh(ctx context.Context, r *RefreshGerritCL) (err error)

Refresh fetches the latest info from Gerrit.

If datastore already contains snapshot with Gerrit-reported update time equal to or after updatedHint, then no updating or querying will be performed.

Prefer Schedule() instead of Refresh() in production.

func (*Updater) RefreshBatch

func (u *Updater) RefreshBatch(ctx context.Context, batch *BatchRefreshGerritCL) error

RefreshBatch schedules a refresh task per CL in a batch.

func (*Updater) Schedule

func (u *Updater) Schedule(ctx context.Context, p *RefreshGerritCL) error

Schedule enqueues a TQ task to refresh a Gerrit CL as soon as possible.

It should be used instead of directly using tq.AddTask, for consistent deduplication and ease of debugging.

func (*Updater) ScheduleBatch

func (u *Updater) ScheduleBatch(ctx context.Context, luciProject string, cls []*changelist.CL) error

ScheduleBatch schedules refresh of several Gerrit CLs.

If called in a transaction, enqueues exactly one TQ task transactionally. This allows to write 1 Datastore entity during a transaction instead of N entities if Schedule() was used for each CL.

Otherwise, enqueues 1 TQ task per CL non-transactionally.

func (*Updater) ScheduleDelayed

func (u *Updater) ScheduleDelayed(ctx context.Context, p *RefreshGerritCL, delay time.Duration) error

Schedule enqueues a TQ task to refresh a Gerrit CL after a given delay.

It should be used instead of directly using tq.AddTask, for consistent deduplication and ease of debugging.

Directories

Path Synopsis
Package updatertest provides test helpers for Gerrit CL Updater.
Package updatertest provides test helpers for Gerrit CL Updater.

Jump to

Keyboard shortcuts

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