Documentation
¶
Index ¶
- Constants
- func CreateActionKey(ctx context.Context, t time.Time, disambiguation uint32) (*datastore.Key, error)
- func InstallServices(k KarteFrontend, srv grpc.ServiceRegistrar)
- func PutActionEntities(ctx context.Context, entities ...*ActionEntity) error
- func PutObservationEntities(ctx context.Context, entities ...*ObservationEntity) error
- type ActionEntitiesQuery
- type ActionEntity
- type ActionQueryAncillaryData
- type KarteFrontend
- type ObservationEntitiesQuery
- type ObservationEntity
Constants ¶
const ActionKind = "ActionKind"
ActionKind is the kind of an action
const ObservationKind = "ObservationKind"
ObservationKind is the kind of an observation.
Variables ¶
This section is empty.
Functions ¶
func CreateActionKey ¶
func CreateActionKey(ctx context.Context, t time.Time, disambiguation uint32) (*datastore.Key, error)
CreateActionKey creates a datastore.Key for an action.
func InstallServices ¶
func InstallServices(k KarteFrontend, srv grpc.ServiceRegistrar)
InstallServices takes a Karte frontend and exposes it to a LUCI prpc.Server.
func PutActionEntities ¶
func PutActionEntities(ctx context.Context, entities ...*ActionEntity) error
PutActionEntities writes action entities to datastore.
func PutObservationEntities ¶
func PutObservationEntities(ctx context.Context, entities ...*ObservationEntity) error
PutObservationEntities writes multiple observation entities to datastore.
Types ¶
type ActionEntitiesQuery ¶
type ActionEntitiesQuery struct { // Token is the pagination token used by datastore. Token string // Query is a wrapped datastore query. Query *datastore.Query }
ActionEntitiesQuery is a wrapped query of action entities bearing a page token.
func (*ActionEntitiesQuery) Next ¶
func (q *ActionEntitiesQuery) Next(ctx context.Context, batchSize int32) ([]*ActionEntity, ActionQueryAncillaryData, error)
Next takes a batch size and returns the next batch of action entities from a query.
type ActionEntity ¶
type ActionEntity struct { ID string `gae:"$id"` Kind string `gae:"kind"` SwarmingTaskID string `gae:"swarming_task_id"` BuildbucketID string `gae:"buildbucket_id"` AssetTag string `gae:"asset_tag"` StartTime time.Time `gae:"start_time"` StopTime time.Time `gae:"stop_time"` CreateTime time.Time `gae:"receive_time"` Status int32 `gae:"status"` FailReason string `gae:"fail_reason,noindex"` SealTime time.Time `gae:"seal_time"` // After the seal time has passed, no further modifications may be made. Hostname string `gae:"hostname"` Model string `gae:"model"` Board string `gae:"board"` RecoveredBy string `gae:"recovered_by"` Restarts int32 `gae:"restarts"` PlanName string `gae:"plan_name"` AllowFail int32 `gae:"allow_fail"` ActionType int32 `gae:"action_type"` // Count the number of times that an action entity was modified by a request. ModificationCount int32 `gae:"modification_count"` // Deprecated fields! ErrorReason string `gae:"error_reason,noindex"` // succeeded by "fail_reason'. // contains filtered or unexported fields }
ActionEntity is the datastore entity for actions.
Remember to check the setActionEntityFields function.
func GetActionEntityByID ¶
func GetActionEntityByID(ctx context.Context, id string) (*ActionEntity, error)
GetActionEntityByID gets an action entity by its ID. If we confirm the absence of an entity successfully, no error is returned.
func (*ActionEntity) ConvertToAction ¶
func (e *ActionEntity) ConvertToAction() *kartepb.Action
ConvertToAction converts a datastore action entity to an action proto.
func (*ActionEntity) ConvertToValueSaver ¶
func (e *ActionEntity) ConvertToValueSaver() cloudBQ.ValueSaver
ConvertToValueSaver converts a datastore action entity to a ValueSaver.
func (*ActionEntity) Normalize ¶
func (e *ActionEntity) Normalize()
Normalize normalizes an action entity for writing.
func (ActionEntity) Validate ¶
func (e ActionEntity) Validate() error
Validate validates an action entity for writing.
type ActionQueryAncillaryData ¶
type ActionQueryAncillaryData struct { BiggestID string SmallestID string BiggestVersion string SmallestVersion string }
ActionQueryAncillaryData returns ancillary data computed as part of advancing through an action entities query.
Currently, we return the biggest (earliest) and smallest (latest) version seen.
type KarteFrontend ¶
type KarteFrontend interface { kartepb.KarteServer kartepb.KarteCronServer GetProjectID() string }
KarteFrontend is a combination of the Karte RPCs and the cron RPCs. In the future, any other services exposes by Karte should also be added here.
func NewKarteFrontend ¶
func NewKarteFrontend(projectID string) KarteFrontend
NewKarteFrontend produces a new Karte frontend.
type ObservationEntitiesQuery ¶
type ObservationEntitiesQuery struct { // Token is the pagination token used by datastore. Token string // Query is a wrapped datastore query. Query *datastore.Query }
ObservationEntitiesQuery is a wrapped query of action entities bearing a page token.
func (*ObservationEntitiesQuery) Next ¶
func (q *ObservationEntitiesQuery) Next(ctx context.Context, batchSize int32) ([]*ObservationEntity, error)
Next takes a batch size and returns the next batch of observation entities from a query.
type ObservationEntity ¶
type ObservationEntity struct { ID string `gae:"$id"` ActionID string `gae:"action_id"` MetricKind string `gae:"metric_kind"` ValueString string `gae:"value_string"` ValueNumber float64 `gae:"value_number"` // contains filtered or unexported fields }
ObservationEntity is the datastore entity for observations. Only one of value_string or value_number can have a non-default value. If this constraint is not satisfied, then the record is ill-formed.
func (*ObservationEntity) ConvertToObservation ¶
func (e *ObservationEntity) ConvertToObservation() *kartepb.Observation
ConvertToObservation converts a datastore observation entity to an observation proto. ConvertToObservation does NOT perform validation on the observation entity it is given; this function assumes that its receiver is shallowly valid.
func (*ObservationEntity) ConvertToValueSaver ¶
func (e *ObservationEntity) ConvertToValueSaver() cloudBQ.ValueSaver
ConvertToValueSaver converts an observation entity into a record that can be saved to bigquery.
func (*ObservationEntity) GetType ¶
func (e *ObservationEntity) GetType() string
GetType returns whether an observation record is a number or a string.
func (*ObservationEntity) Validate ¶
func (e *ObservationEntity) Validate() error
Validate performs shallow validation on an observation entity. It enforces the constraint that only one of ValueString or ValueNumber can have a non-zero value.