poller

package
v0.0.0-...-141b21d Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package poller polls Gerrit for interesting CV changes.

Package poller implements stateful Gerrit polling.

Index

Constants

This section is empty.

Variables

View Source
var File_go_chromium_org_luci_cv_internal_gerrit_poller_storage_proto protoreflect.FileDescriptor
View Source
var File_go_chromium_org_luci_cv_internal_gerrit_poller_task_proto protoreflect.FileDescriptor

Functions

func FilterProjects

func FilterProjects(payloads []proto.Message) []string

FilterProjects returns Projects from the tasks for Gerrit Poller.

Types

type CLUpdater

type CLUpdater interface {
	Schedule(context.Context, *changelist.UpdateCLTask) error
	ScheduleDelayed(context.Context, *changelist.UpdateCLTask, time.Duration) error
}

CLUpdater encapsulates interaction with Gerrit CL Updater by the Poller.

type PollGerritTask

type PollGerritTask struct {
	LuciProject string `protobuf:"bytes,1,opt,name=luci_project,json=luciProject,proto3" json:"luci_project,omitempty"`
	// eta is when this task is supposed to run.
	Eta *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=eta,proto3" json:"eta,omitempty"`
	// contains filtered or unexported fields
}

PollGerritTask performs next poll for a given LUCI Project.

Queue: "poll-gerrit".

func FilterPayloads

func FilterPayloads(payloads []proto.Message) []*PollGerritTask

FilterPayloads returns payloads for Gerrit Poller tasks only.

func (*PollGerritTask) Descriptor deprecated

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

Deprecated: Use PollGerritTask.ProtoReflect.Descriptor instead.

func (*PollGerritTask) GetEta

func (x *PollGerritTask) GetEta() *timestamppb.Timestamp

func (*PollGerritTask) GetLuciProject

func (x *PollGerritTask) GetLuciProject() string

func (*PollGerritTask) ProtoMessage

func (*PollGerritTask) ProtoMessage()

func (*PollGerritTask) ProtoReflect

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

func (*PollGerritTask) Reset

func (x *PollGerritTask) Reset()

func (*PollGerritTask) String

func (x *PollGerritTask) String() string

type Poller

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

Poller polls Gerrit to discover new CLs and modifications of the existing ones.

func New

func New(tqd *tq.Dispatcher, g gerrit.Factory, clUpdater CLUpdater, pm pmNotifier) *Poller

New creates a new Poller, registering it in the given TQ dispatcher.

func (*Poller) Poke

func (p *Poller) Poke(ctx context.Context, luciProject string) error

Poke schedules the next poll via task queue.

Under perfect operation, this is redundant, but not harmful. Given bugs or imperfect operation, this ensures poller continues operating.

Must not be called inside a datastore transaction.

type QueryState

type QueryState struct {

	// Host is Gerrit host.
	Host string `protobuf:"bytes,1,opt,name=host,proto3" json:"host,omitempty"`
	// Enumerated Gerrit projects, e.g. ["infra/infra", "infra/luci/luci-go"].
	OrProjects []string `protobuf:"bytes,2,rep,name=or_projects,json=orProjects,proto3" json:"or_projects,omitempty"`
	// Common Gerrit project prefix, e.g. "chromiumos/".
	CommonProjectPrefix string `protobuf:"bytes,3,opt,name=common_project_prefix,json=commonProjectPrefix,proto3" json:"common_project_prefix,omitempty"`
	// When the last full poll was started.
	LastFullTime *timestamppb.Timestamp `protobuf:"bytes,11,opt,name=last_full_time,json=lastFullTime,proto3" json:"last_full_time,omitempty"`
	// When the last incremental poll was started.
	LastIncrTime *timestamppb.Timestamp `protobuf:"bytes,12,opt,name=last_incr_time,json=lastIncrTime,proto3" json:"last_incr_time,omitempty"`
	// Changes are changes which were last observed by the query execution.
	//
	// These are not CL IDs, but Gerrit change numbers.
	//
	// The full poll resets these.
	// The incremental poll adds newly discovered CLs.
	//
	// Sorted.
	Changes []int64 `protobuf:"varint,13,rep,packed,name=changes,proto3" json:"changes,omitempty"`
	// contains filtered or unexported fields
}

QueryState represents execution of a single Gerrit query over time.

Exactly one of (or_projects, common_project_prefix) must be specified. Not using oneof to avoid wrapping or_projects in a message as oneof doesn't support repeated fields.

func (*QueryState) Descriptor deprecated

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

Deprecated: Use QueryState.ProtoReflect.Descriptor instead.

func (*QueryState) GetChanges

func (x *QueryState) GetChanges() []int64

func (*QueryState) GetCommonProjectPrefix

func (x *QueryState) GetCommonProjectPrefix() string

func (*QueryState) GetHost

func (x *QueryState) GetHost() string

func (*QueryState) GetLastFullTime

func (x *QueryState) GetLastFullTime() *timestamppb.Timestamp

func (*QueryState) GetLastIncrTime

func (x *QueryState) GetLastIncrTime() *timestamppb.Timestamp

func (*QueryState) GetOrProjects

func (x *QueryState) GetOrProjects() []string

func (*QueryState) ProtoMessage

func (*QueryState) ProtoMessage()

func (*QueryState) ProtoReflect

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

func (*QueryState) Reset

func (x *QueryState) Reset()

func (*QueryState) String

func (x *QueryState) String() string

type QueryStates

type QueryStates struct {
	States []*QueryState `protobuf:"bytes,1,rep,name=states,proto3" json:"states,omitempty"`
	// contains filtered or unexported fields
}

QueryStates exists to reference several QueryStates as a single property in a Datastore entity.

func (*QueryStates) Descriptor deprecated

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

Deprecated: Use QueryStates.ProtoReflect.Descriptor instead.

func (*QueryStates) GetStates

func (x *QueryStates) GetStates() []*QueryState

func (*QueryStates) ProtoMessage

func (*QueryStates) ProtoMessage()

func (*QueryStates) ProtoReflect

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

func (*QueryStates) Reset

func (x *QueryStates) Reset()

func (*QueryStates) String

func (x *QueryStates) String() string

type State

type State struct {

	// Project is the name of the LUCI Project for which poller is working.
	LuciProject string `gae:"$id"`
	// UpdateTime is the timestamp when this state was last updated.
	UpdateTime time.Time `gae:",noindex"`
	// EVersion is the latest version number of the state.
	//
	// It increments by 1 every time state is updated either due to new project config
	// being updated OR after each successful poll.
	EVersion int64 `gae:",noindex"`
	// ConfigHash defines which Config version was last worked on.
	ConfigHash string `gae:",noindex"`
	// QueryStates tracks states of individual queries.
	//
	// Most LUCI projects will run just 1 query per Gerrit host.
	// But, if a LUCI project is watching many Gerrit projects (a.k.a. Git repos),
	// then the Gerrit projects may be split between several queries.
	//
	// TODO(tandrii): rename the datastore property name.
	QueryStates *QueryStates `gae:"SubPollers"`
	// contains filtered or unexported fields
}

State persists poller's State in datastore.

State is exported for exposure via Admin API for debugging/observation. It must not be used elsewhere.

Jump to

Keyboard shortcuts

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