spanneradapters

package
v0.0.0-...-76d23df Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: Apache-2.0 Imports: 27 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFailedToStoreEnum indicates the storage layer failed to store chromium enum.
	ErrFailedToStoreEnum = errors.New("failed to store chromium enum")
	// ErrFailedToStoreEnumValue indicates the storage layer failed to store chromium enum value.
	ErrFailedToStoreEnumValue = errors.New("failed to store chromium enum value")
	// ErrFailedToStoreEnumValueWebFeatureMapping indicates the storage layer failed to store
	// the mapping between enum value and web feature.
	ErrFailedToStoreEnumValueWebFeatureMapping = errors.New(
		"failed to store web feature to chromium enum value mapping")
	// ErrFailedToGetFeatureKeys indicates an internal error when trying to get all the feature keys.
	ErrFailedToGetFeatureKeys = errors.New("failed to get feature keys")
)
View Source
var (
	// ErrCapstoneLookupFailed indicates an internal error trying to find the capstone.
	ErrCapstoneLookupFailed = errors.New("failed to look up capstone")

	// ErrCapstoneSaveFailed indicates an internal error trying to save the capstone.
	ErrCapstoneSaveFailed = errors.New("failed to save capstone")

	// ErrMetricsSaveFailed indicates an internal error trying to save the metrics.
	ErrMetricsSaveFailed = errors.New("failed to save metrics")

	// ErrInvalidRate indicates an internal error when parsing the rate.
	ErrInvalidRate = errors.New("invalid rate")
)
View Source
var ErrConflictMigratingFeatureKey = errors.New("conflict migrating feature key")

ErrConflictMigratingFeatureKey is returned when a feature key migration would result in a conflict. This occurs when both the old feature key and the new feature key are present in the input data, indicating that the upstream data source is in an inconsistent state.

Functions

func NewWPTRun

func NewWPTRun(testRun shared.TestRun) gcpspanner.WPTRun

NewWPTRun creates a gcpspanner WPTRun from the incoming TestRun from wpt.fyi.

func NullJSONToTypedSlice

func NullJSONToTypedSlice[T any](jsonVal spanner.NullJSON) (*[]T, error)

NullJSONToTypedSlice safely converts a spanner.NullJSON object, which the Spanner client decodes into a generic `interface{}`, into a strongly-typed slice of type `T`.

A direct type assertion is not feasible because the underlying type is typically `[]interface{}`, where each element is a `map[string]interface{}`. The most robust and idiomatic way to perform this conversion is to re-marshal the generic structure back into a JSON byte slice and then unmarshal it into the desired target struct slice. This process also implicitly validates that the data from the database conforms to the API's data contract. It returns `backendtypes.ErrEmptyJSONValue` if the input is valid but results in an empty slice.

func VendorPositionsToNullJSON

func VendorPositionsToNullJSON(positions []webfeaturesmappingtypes.StandardsPosition) (spanner.NullJSON, error)

VendorPositionsToNullJSON converts a slice of StandardsPosition into a spanner.NullJSON object. This is used by both the real data consumer and the fake data generator to ensure consistency.

Types

type BCDConsumer

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

BCDConsumer is the adapter that takes data from the BCD workflow and prepares it to be stored in the spanner database.

func NewBCDWorkflowConsumer

func NewBCDWorkflowConsumer(client BCDWorkflowSpannerClient) *BCDConsumer

NewBCDWorkflowConsumer constructs an adapter for the bcd consumer service.

func (*BCDConsumer) InsertBrowserReleases

func (b *BCDConsumer) InsertBrowserReleases(ctx context.Context, releases []bcdconsumertypes.BrowserRelease) error

type BCDWorkflowSpannerClient

type BCDWorkflowSpannerClient interface {
	InsertBrowserRelease(ctx context.Context, release gcpspanner.BrowserRelease) error
}

BCDWorkflowSpannerClient expects a subset of the functionality from lib/gcpspanner that only apply to inserting BCD data.

type Backend

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

Backend converts queries to spanner to usable entities for the backend service.

func NewBackend

func NewBackend(client BackendSpannerClient) *Backend

NewBackend constructs an adapter for the backend service.

func (*Backend) CreateSavedSearchSubscription

func (s *Backend) CreateSavedSearchSubscription(ctx context.Context,
	userID string, req backend.Subscription) (*backend.SubscriptionResponse, error)

func (*Backend) CreateUserSavedSearch

func (s *Backend) CreateUserSavedSearch(ctx context.Context, userID string,
	savedSearch backend.SavedSearch) (*backend.SavedSearchResponse, error)

func (*Backend) DeleteNotificationChannel

func (s *Backend) DeleteNotificationChannel(ctx context.Context, userID, channelID string) error

func (*Backend) DeleteSavedSearchSubscription

func (s *Backend) DeleteSavedSearchSubscription(ctx context.Context, userID, subscriptionID string) error

func (*Backend) DeleteUserSavedSearch

func (s *Backend) DeleteUserSavedSearch(ctx context.Context, userID, savedSearchID string) error

func (*Backend) FeaturesSearch

func (s *Backend) FeaturesSearch(
	ctx context.Context,
	pageToken *string,
	pageSize int,
	searchNode *searchtypes.SearchNode,
	sortOrder *backend.ListFeaturesParamsSort,
	wptMetricView backend.WPTMetricView,
	browsers []backend.BrowserPathParam,
) (*backend.FeaturePage, error)

func (*Backend) GetFeature

func (s *Backend) GetFeature(
	ctx context.Context,
	featureID string,
	wptMetricView backend.WPTMetricView,
	browsers []backend.BrowserPathParam,
) (*backendtypes.GetFeatureResult, error)

func (*Backend) GetIDFromFeatureKey

func (s *Backend) GetIDFromFeatureKey(
	ctx context.Context,
	featureID string,
) (*string, error)

func (*Backend) GetNotificationChannel

func (s *Backend) GetNotificationChannel(ctx context.Context,
	userID, channelID string) (*backend.NotificationChannelResponse, error)

func (*Backend) GetSavedSearch

func (s *Backend) GetSavedSearch(ctx context.Context, savedSearchID string, userID *string) (
	*backend.SavedSearchResponse, error)

func (*Backend) GetSavedSearchSubscription

func (s *Backend) GetSavedSearchSubscription(ctx context.Context,
	userID, subscriptionID string) (*backend.SubscriptionResponse, error)

func (*Backend) ListBaselineStatusCounts

func (s *Backend) ListBaselineStatusCounts(
	ctx context.Context,
	startAt time.Time,
	endAt time.Time,
	pageSize int,
	pageToken *string,
) (*backend.BaselineStatusMetricsPage, error)

func (*Backend) ListBrowserFeatureCountMetric

func (s *Backend) ListBrowserFeatureCountMetric(
	ctx context.Context,
	targetBrowser string,
	targetMobileBrowser *string,
	startAt time.Time,
	endAt time.Time,
	pageSize int,
	pageToken *string,
) (*backend.BrowserReleaseFeatureMetricsPage, error)

func (*Backend) ListChromeDailyUsageStats

func (s *Backend) ListChromeDailyUsageStats(
	ctx context.Context,
	featureID string,
	startAt, endAt time.Time,
	pageSize int,
	pageToken *string,
) ([]backend.ChromeUsageStat, *string, error)

func (*Backend) ListMetricsForFeatureIDBrowserAndChannel

func (s *Backend) ListMetricsForFeatureIDBrowserAndChannel(
	ctx context.Context,
	featureID string,
	browser string,
	channel string,
	metricView backend.MetricViewPathParam,
	startAt, endAt time.Time,
	pageSize int,
	pageToken *string,
) ([]backend.WPTRunMetric, *string, error)

func (*Backend) ListMetricsOverTimeWithAggregatedTotals

func (s *Backend) ListMetricsOverTimeWithAggregatedTotals(
	ctx context.Context,
	featureIDs []string,
	browser string,
	channel string,
	metricView backend.MetricViewPathParam,
	startAt, endAt time.Time,
	pageSize int,
	pageToken *string,
) ([]backend.WPTRunMetric, *string, error)

func (*Backend) ListMissingOneImplCounts

func (s *Backend) ListMissingOneImplCounts(
	ctx context.Context,
	targetBrowser string,
	targetMobileBrowser *string,
	otherBrowsers []string,
	startAt, endAt time.Time,
	pageSize int,
	pageToken *string,
) (*backend.BrowserReleaseFeatureMetricsPage, error)

func (*Backend) ListMissingOneImplementationFeatures

func (s *Backend) ListMissingOneImplementationFeatures(
	ctx context.Context,
	targetBrowser string,
	targetMobileBrowser *string,
	otherBrowsers []string,
	targetDate time.Time,
	pageSize int,
	pageToken *string,
) (*backend.MissingOneImplFeaturesPage, error)

func (*Backend) ListNotificationChannels

func (s *Backend) ListNotificationChannels(ctx context.Context,
	userID string, pageSize int, pageToken *string) (*backend.NotificationChannelPage, error)

func (*Backend) ListSavedSearchSubscriptions

func (s *Backend) ListSavedSearchSubscriptions(ctx context.Context,
	userID string, pageSize int, pageToken *string) (*backend.SubscriptionPage, error)

func (*Backend) ListUserSavedSearches

func (s *Backend) ListUserSavedSearches(
	ctx context.Context,
	userID string,
	pageSize int,
	pageToken *string,
) (*backend.UserSavedSearchPage, error)

func (*Backend) PutUserSavedSearchBookmark

func (s *Backend) PutUserSavedSearchBookmark(
	ctx context.Context,
	userID string,
	savedSearchID string,
) error

func (*Backend) RemoveUserSavedSearchBookmark

func (s *Backend) RemoveUserSavedSearchBookmark(
	ctx context.Context,
	userID string,
	savedSearchID string,
) error

func (*Backend) SyncUserProfileInfo

func (s *Backend) SyncUserProfileInfo(ctx context.Context, userProfile backendtypes.UserProfile) error

func (*Backend) UpdateSavedSearchSubscription

func (s *Backend) UpdateSavedSearchSubscription(ctx context.Context,
	userID, subscriptionID string, req backend.UpdateSubscriptionRequest) (*backend.SubscriptionResponse, error)

func (*Backend) UpdateUserSavedSearch

func (s *Backend) UpdateUserSavedSearch(
	ctx context.Context,
	savedSearchID string,
	userID string,
	updateRequest *backend.SavedSearchUpdateRequest,
) (*backend.SavedSearchResponse, error)

type BackendAdapterForEventProducerDiffer

type BackendAdapterForEventProducerDiffer interface {
	GetFeature(
		ctx context.Context,
		featureID string,
		wptMetricView backend.WPTMetricView,
		browsers []backend.BrowserPathParam,
	) (*backendtypes.GetFeatureResult, error)
	FeaturesSearch(
		ctx context.Context,
		pageToken *string,
		pageSize int,
		searchNode *searchtypes.SearchNode,
		sortOrder *backend.ListFeaturesParamsSort,
		wptMetricView backend.WPTMetricView,
		browsers []backend.BrowserPathParam,
	) (*backend.FeaturePage, error)
}

type BackendSpannerClient

type BackendSpannerClient interface {
	ListMetricsForFeatureIDBrowserAndChannel(
		ctx context.Context,
		featureID string,
		browser string,
		channel string,
		metric gcpspanner.WPTMetricView,
		startAt time.Time,
		endAt time.Time,
		pageSize int,
		pageToken *string,
	) ([]gcpspanner.WPTRunFeatureMetricWithTime, *string, error)
	ListMetricsOverTimeWithAggregatedTotals(
		ctx context.Context,
		featureIDs []string,
		browser string,
		channel string,
		metric gcpspanner.WPTMetricView,
		startAt, endAt time.Time,
		pageSize int,
		pageToken *string,
	) ([]gcpspanner.WPTRunAggregationMetricWithTime, *string, error)
	ListChromeDailyUsageStatsForFeatureID(
		ctx context.Context,
		featureID string,
		startAt, endAt time.Time,
		pageSize int,
		pageToken *string,
	) ([]gcpspanner.ChromeDailyUsageStatWithDate, *string, error)
	FeaturesSearch(
		ctx context.Context,
		pageToken *string,
		pageSize int,
		searchNode *searchtypes.SearchNode,
		sortOrder gcpspanner.Sortable,
		wptMetricView gcpspanner.WPTMetricView,
		browsers []string,
	) (*gcpspanner.FeatureResultPage, error)
	GetFeature(
		ctx context.Context,
		filter gcpspanner.Filterable,
		wptMetricView gcpspanner.WPTMetricView,
		browsers []string,
	) (*gcpspanner.FeatureResult, error)
	GetMovedWebFeatureDetailsByOriginalFeatureKey(
		ctx context.Context,
		featureKey string,
	) (*gcpspanner.MovedWebFeature, error)
	GetSplitWebFeatureByOriginalFeatureKey(
		ctx context.Context,
		featureKey string,
	) (*gcpspanner.SplitWebFeature, error)
	GetIDFromFeatureKey(
		ctx context.Context,
		filter *gcpspanner.FeatureIDFilter,
	) (*string, error)
	ListBrowserFeatureCountMetric(
		ctx context.Context,
		targetBrowser string,
		targetMobileBrowser *string,
		startAt time.Time,
		endAt time.Time,
		pageSize int,
		pageToken *string,
	) (*gcpspanner.BrowserFeatureCountResultPage, error)
	ListMissingOneImplCounts(
		ctx context.Context,
		targetBrowser string,
		targetMobileBrowser *string,
		otherBrowsers []string,
		startAt time.Time,
		endAt time.Time,
		pageSize int,
		pageToken *string,
	) (*gcpspanner.MissingOneImplCountPage, error)
	ListMissingOneImplementationFeatures(
		ctx context.Context,
		targetBrowser string,
		targetMobileBrowser *string,
		otherBrowsers []string,
		targetDate time.Time,
		pageSize int,
		pageToken *string,
	) (*gcpspanner.MissingOneImplFeatureListPage, error)
	ListBaselineStatusCounts(
		ctx context.Context,
		dateType gcpspanner.BaselineDateType,
		startAt time.Time,
		endAt time.Time,
		pageSize int,
		pageToken *string,
	) (*gcpspanner.BaselineStatusCountResultPage, error)
	CreateNewUserSavedSearch(
		ctx context.Context,
		newSearch gcpspanner.CreateUserSavedSearchRequest) (*string, error)
	GetUserSavedSearch(
		ctx context.Context,
		savedSearchID string,
		authenticatedUserID *string) (*gcpspanner.UserSavedSearch, error)
	DeleteUserSavedSearch(ctx context.Context, req gcpspanner.DeleteUserSavedSearchRequest) error
	ListUserSavedSearches(
		ctx context.Context,
		userID string,
		pageSize int,
		pageToken *string) (*gcpspanner.UserSavedSearchesPage, error)
	UpdateUserSavedSearch(ctx context.Context, req gcpspanner.UpdateSavedSearchRequest) error
	AddUserSearchBookmark(ctx context.Context, req gcpspanner.UserSavedSearchBookmark) error
	DeleteUserSearchBookmark(ctx context.Context, req gcpspanner.UserSavedSearchBookmark) error
	SyncUserProfileInfo(ctx context.Context, userProfile gcpspanner.UserProfile) error
	CreateSavedSearchSubscription(
		ctx context.Context, req gcpspanner.CreateSavedSearchSubscriptionRequest) (*string, error)
	GetSavedSearchSubscription(ctx context.Context, subscriptionID string, userID string) (
		*gcpspanner.SavedSearchSubscription, error)
	UpdateSavedSearchSubscription(ctx context.Context, req gcpspanner.UpdateSavedSearchSubscriptionRequest) error
	DeleteSavedSearchSubscription(ctx context.Context, subscriptionID string, userID string) error
	ListSavedSearchSubscriptions(ctx context.Context, req gcpspanner.ListSavedSearchSubscriptionsRequest) (
		[]gcpspanner.SavedSearchSubscription, *string, error)
	GetNotificationChannel(
		ctx context.Context, channelID string, userID string) (*gcpspanner.NotificationChannel, error)
	ListNotificationChannels(ctx context.Context, req gcpspanner.ListNotificationChannelsRequest) (
		[]gcpspanner.NotificationChannel, *string, error)
	DeleteNotificationChannel(ctx context.Context, channelID string, userID string) error
}

type BatchEventProducer

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

func (*BatchEventProducer) ListAllSavedSearches

func (b *BatchEventProducer) ListAllSavedSearches(ctx context.Context) ([]workertypes.SearchJob, error)

type BatchEventProducerSpannerClient

type BatchEventProducerSpannerClient interface {
	ListAllSavedSearches(
		ctx context.Context) ([]gcpspanner.SavedSearchBriefDetails, error)
}

type BrowserList

type BrowserList []backend.BrowserPathParam

func (BrowserList) ToStringList

func (b BrowserList) ToStringList() []string

type ChromiumHistogramEnumConsumer

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

ChromiumHistogramEnumConsumer handles the conversion of histogram between the workflow/API input format and the format used by the GCP Spanner client.

func NewChromiumHistogramEnumConsumer

func NewChromiumHistogramEnumConsumer(client ChromiumHistogramEnumsClient) *ChromiumHistogramEnumConsumer

NewChromiumHistogramEnumConsumer constructs an adapter for the chromium histogram enum consumer service.

func (*ChromiumHistogramEnumConsumer) GetAllMovedWebFeatures

func (*ChromiumHistogramEnumConsumer) SaveHistogramEnums

type ChromiumHistogramEnumsClient

type ChromiumHistogramEnumsClient interface {
	UpsertChromiumHistogramEnum(context.Context, gcpspanner.ChromiumHistogramEnum) (*string, error)
	SyncChromiumHistogramEnumValues(context.Context, []gcpspanner.ChromiumHistogramEnumValue) error
	GetIDFromChromiumHistogramEnumValueKey(
		ctx context.Context, chromiumHistogramEnumID string, bucketID int64) (*string, error)
	SyncWebFeatureChromiumHistogramEnumValues(context.Context, []gcpspanner.WebFeatureChromiumHistogramEnumValue) error
	GetIDFromFeatureKey(context.Context, *gcpspanner.FeatureIDFilter) (*string, error)
	FetchAllFeatureKeys(context.Context) ([]string, error)
	GetAllMovedWebFeatures(ctx context.Context) ([]gcpspanner.MovedWebFeature, error)
}

ChromiumHistogramEnumsClient expects a subset of the functionality from lib/gcpspanner that only apply to Chromium Histograms.

type DeveloperSignalsClient

type DeveloperSignalsClient interface {
	GetAllMovedWebFeatures(ctx context.Context) ([]gcpspanner.MovedWebFeature, error)
	SyncLatestFeatureDeveloperSignals(ctx context.Context, data []gcpspanner.FeatureDeveloperSignal) error
}

DeveloperSignalsClient expects a subset of the functionality from lib/gcpspanner that only apply to Developer Signals.

type DeveloperSignalsConsumer

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

DeveloperSignalsConsumer handles the conversion of the developer signals between the downloaded format in the workflow and the format used by the GCP Spanner client.

func NewDeveloperSignalsConsumer

func NewDeveloperSignalsConsumer(client DeveloperSignalsClient) *DeveloperSignalsConsumer

NewDeveloperSignalsConsumer constructs an adapter for the developer signals service.

func (*DeveloperSignalsConsumer) GetAllMovedWebFeatures

func (*DeveloperSignalsConsumer) SyncLatestFeatureDeveloperSignals

func (c *DeveloperSignalsConsumer) SyncLatestFeatureDeveloperSignals(
	ctx context.Context, data *developersignaltypes.FeatureDeveloperSignals) error

SyncLatestFeatureDeveloperSignals handles the conversion of developer signals between the workflow/API input format and the format used by the GCP Spanner client.

type EmailWorkerChannelStateManager

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

func (*EmailWorkerChannelStateManager) RecordFailure

func (s *EmailWorkerChannelStateManager) RecordFailure(ctx context.Context, channelID string, err error,
	timestamp time.Time, permanentUserFailure bool, emailEventID string) error

func (*EmailWorkerChannelStateManager) RecordSuccess

func (s *EmailWorkerChannelStateManager) RecordSuccess(ctx context.Context, channelID string,
	timestamp time.Time, eventID string) error

type EmailWorkerSpannerClient

type EmailWorkerSpannerClient interface {
	RecordNotificationChannelSuccess(ctx context.Context, channelID string, timestamp time.Time, eventID string) error
	RecordNotificationChannelFailure(ctx context.Context, channelID string, errorMsg string, timestamp time.Time,
		isPermanent bool, eventID string) error
}

type EventProducer

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

func NewEventProducer

func NewEventProducer(client EventProducerSpannerClient) *EventProducer

func (*EventProducer) AcquireLock

func (e *EventProducer) AcquireLock(ctx context.Context, searchID string, frequency workertypes.JobFrequency,
	workerID string, lockTTL time.Duration) error

func (*EventProducer) GetLatestEvent

func (e *EventProducer) GetLatestEvent(ctx context.Context, frequency workertypes.JobFrequency,
	searchID string) (*workertypes.LatestEventInfo, error)

func (*EventProducer) PublishEvent

func (*EventProducer) ReleaseLock

func (e *EventProducer) ReleaseLock(ctx context.Context, searchID string, frequency workertypes.JobFrequency,
	workerID string) error

type EventProducerDiffer

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

func NewEventProducerDiffer

func NewEventProducerDiffer(adapter BackendAdapterForEventProducerDiffer) *EventProducerDiffer

NewEventProducerDiffer constructs an adapter for the differ in the event producer service.

func (*EventProducerDiffer) FetchFeatures

func (e *EventProducerDiffer) FetchFeatures(ctx context.Context, query string) ([]backend.Feature, error)

func (*EventProducerDiffer) GetFeature

func (e *EventProducerDiffer) GetFeature(
	ctx context.Context,
	featureID string) (*backendtypes.GetFeatureResult, error)

type EventProducerDifferSpannerClient

type EventProducerDifferSpannerClient interface {
	BackendSpannerClient
}

type EventProducerSpannerClient

type EventProducerSpannerClient interface {
	TryAcquireSavedSearchStateWorkerLock(
		ctx context.Context,
		savedSearchID string,
		snapshotType gcpspanner.SavedSearchSnapshotType,
		workerID string,
		ttl time.Duration) (bool, error)
	PublishSavedSearchNotificationEvent(ctx context.Context,
		event gcpspanner.SavedSearchNotificationCreateRequest, newStatePath, workerID string,
		opts ...gcpspanner.CreateOption) (*string, error)
	GetLatestSavedSearchNotificationEvent(
		ctx context.Context,
		savedSearchID string,
		snapshotType gcpspanner.SavedSearchSnapshotType,
	) (*gcpspanner.SavedSearchNotificationEvent, error)
	ReleaseSavedSearchStateWorkerLock(
		ctx context.Context,
		savedSearchID string,
		snapshotType gcpspanner.SavedSearchSnapshotType,
		workerID string) error
}

type Migrator

type Migrator[SetValueType, DataType any] struct {
	// AllFeaturesSet is a map representing the set of all feature keys present in the source data.
	// The key is the feature identifier (string). The value's type is generic and not used by the migrator logic.
	AllFeaturesSet map[string]SetValueType
	// MovedFeatures is a map where the key is the old (moved) feature key and the value
	// contains information about the new feature key.
	MovedFeatures map[string]webdxfeaturetypes.FeatureMovedData
	// DataToMigrate is the actual data structure that needs to be modified based on the feature key migrations.
	DataToMigrate DataType
	// contains filtered or unexported fields
}

Migrator is a generic helper designed to handle the migration of data associated with renamed feature keys. It iterates through a provided dataset, identifies features that have been moved (renamed), and applies a user-defined update function to migrate the data to the new feature key.

SetValueType is the type of the value in the set of all features. It is not used directly but is required for the generic map type. DataType is the type of the data structure that holds the information to be migrated.

func NewMigrator

func NewMigrator[SetValueType, DataType any](
	movedFeatures map[string]webdxfeaturetypes.FeatureMovedData,
	allFeaturesSet map[string]SetValueType,
	data DataType,
	options ...MigratorOption[SetValueType, DataType],
) *Migrator[SetValueType, DataType]

NewMigrator creates and returns a new Migrator instance. It takes the moved features map, the set of all features from the source data, the data to be migrated, and optional configuration functions.

func (*Migrator[SetValueType, DataType]) Migrate

func (m *Migrator[SetValueType, DataType]) Migrate(
	ctx context.Context, update func(oldKey, newKey string, data DataType)) error

Migrate executes the feature key migration process. It iterates over all feature keys in the input data. If a feature key has been moved, it checks for conflicts. A conflict arises if the target (new) feature key already exists in the input data. If a conflict is found, it returns ErrConflictMigratingFeatureKey. If there is no conflict, it logs a warning and calls the provided `update` function with the old key, new key, and the data structure to be migrated.

type MigratorOption

type MigratorOption[SetValueType, DataType any] func(*Migrator[SetValueType, DataType])

MigratorOption defines a function signature for configuring a Migrator instance.

func WithLoggerForMigrator

func WithLoggerForMigrator[SetValueType, DataType any](logger *slog.Logger) MigratorOption[SetValueType, DataType]

WithLoggerForMigrator returns a MigratorOption to set a custom logger for the Migrator. This allows capturing migration warnings and errors in a structured way.

type PushDeliverySpannerClient

type PushDeliverySpannerClient interface {
	FindAllActivePushSubscriptions(
		ctx context.Context,
		savedSearchID string,
		frequency gcpspanner.SavedSearchSnapshotType,
	) ([]gcpspanner.SubscriberDestination, error)
}

type PushDeliverySubscriberFinder

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

func (*PushDeliverySubscriberFinder) FindSubscribers

type UMAMetricConsumer

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

UMAMetricConsumer handles the conversion of histogram between the workflow/API input format and the format used by the GCP Spanner client.

func NewUMAMetricConsumer

func NewUMAMetricConsumer(client UMAMetricsClient) *UMAMetricConsumer

NewUMAMetricConsumer constructs an adapter for the uma metric export service.

func (*UMAMetricConsumer) HasCapstone

func (c *UMAMetricConsumer) HasCapstone(
	ctx context.Context,
	day civil.Date,
	histogramName metricdatatypes.HistogramName) (bool, error)

func (*UMAMetricConsumer) SaveCapstone

func (c *UMAMetricConsumer) SaveCapstone(
	ctx context.Context,
	day civil.Date,
	histogramName metricdatatypes.HistogramName) error

func (*UMAMetricConsumer) SaveMetrics

type UMAMetricsClient

type UMAMetricsClient interface {
	HasDailyChromiumHistogramCapstone(context.Context, gcpspanner.DailyChromiumHistogramEnumCapstone) (*bool, error)
	UpsertDailyChromiumHistogramCapstone(context.Context, gcpspanner.DailyChromiumHistogramEnumCapstone) error
	StoreDailyChromiumHistogramMetrics(context.Context,
		metricdatatypes.HistogramName,
		map[int64]gcpspanner.DailyChromiumHistogramMetric) error
	SyncLatestDailyChromiumHistogramMetrics(context.Context) error
}

UMAMetricsClient expects a subset of the functionality from lib/gcpspanner that only apply to Chromium Histograms.

type WPTConsumer

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

WPTConsumer is the adapter that takes data from the WPT workflow and prepares it to be stored in the spanner database.

func NewWPTWorkflowConsumer

func NewWPTWorkflowConsumer(client WPTWorkflowSpannerClient) *WPTConsumer

NewWPTWorkflowConsumer constructs an adapter for the wpt consumer service.

func (*WPTConsumer) GetAllMovedWebFeatures

func (w *WPTConsumer) GetAllMovedWebFeatures(
	ctx context.Context) (map[string]webdxfeaturetypes.FeatureMovedData, error)

func (*WPTConsumer) InsertWPTRun

func (w *WPTConsumer) InsertWPTRun(ctx context.Context, in shared.TestRun) error

func (*WPTConsumer) UpsertWPTRunFeatureMetrics

func (w *WPTConsumer) UpsertWPTRunFeatureMetrics(
	ctx context.Context,
	runID int64,
	metricsPerFeature map[string]wptconsumertypes.WPTFeatureMetric) error

type WPTWorkflowSpannerClient

type WPTWorkflowSpannerClient interface {
	InsertWPTRun(ctx context.Context, run gcpspanner.WPTRun) error
	UpsertWPTRunFeatureMetrics(ctx context.Context, externalRunID int64,
		in map[string]gcpspanner.WPTRunFeatureMetric) error
	GetAllMovedWebFeatures(ctx context.Context) ([]gcpspanner.MovedWebFeature, error)
}

WPTWorkflowSpannerClient expects a subset of the functionality from lib/gcpspanner that only apply to inserting WPT data.

type WebFeatureGroupConsumer

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

WebFeatureGroupConsumer handles the conversion of group data between the workflow/API input format and the format used by the GCP Spanner client.

func NewWebFeatureGroupsConsumer

func NewWebFeatureGroupsConsumer(client WebFeatureGroupsClient) *WebFeatureGroupConsumer

NewWebFeaturesConsumer constructs an adapter for the web features consumer service.

func (*WebFeatureGroupConsumer) InsertWebFeatureGroups

func (c *WebFeatureGroupConsumer) InsertWebFeatureGroups(
	ctx context.Context,
	featureData map[string]webdxfeaturetypes.FeatureValue,
	groupData map[string]webdxfeaturetypes.GroupData) error

type WebFeatureGroupsClient

type WebFeatureGroupsClient interface {
	UpsertGroup(ctx context.Context, group gcpspanner.Group) (*string, error)
	UpsertFeatureGroupLookups(ctx context.Context,
		featureKeyToGroupsMapping map[string][]string, childGroupKeyToParentGroupKey map[string]string) error
}

WebFeatureGroupsClient expects a subset of the functionality from lib/gcpspanner that only apply to Groups.

type WebFeatureSnapshotConsumer

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

WebFeatureSnapshotConsumer handles the conversion of snapshot data between the workflow/API input format and the format used by the GCP Spanner client.

func NewWebFeatureSnapshotsConsumer

func NewWebFeatureSnapshotsConsumer(client WebFeatureSnapshotsClient) *WebFeatureSnapshotConsumer

NewWebFeatureSnapshotsConsumer constructs an adapter for the web feature snapshots consumer service.

func (*WebFeatureSnapshotConsumer) InsertWebFeatureSnapshots

func (c *WebFeatureSnapshotConsumer) InsertWebFeatureSnapshots(
	ctx context.Context,
	featureKeyToID map[string]string,
	featureData map[string]webdxfeaturetypes.FeatureValue,
	snapshotData map[string]webdxfeaturetypes.SnapshotData) error

type WebFeatureSnapshotsClient

type WebFeatureSnapshotsClient interface {
	UpsertSnapshot(ctx context.Context, snapshot gcpspanner.Snapshot) (*string, error)
	UpsertWebFeatureSnapshot(ctx context.Context, snapshot gcpspanner.WebFeatureSnapshot) error
}

WebFeatureSnapshotsClient expects a subset of the functionality from lib/gcpspanner that only apply to Snapshots.

type WebFeatureSpannerClient

type WebFeatureSpannerClient interface {
	SyncWebFeatures(ctx context.Context, features []gcpspanner.WebFeature,
		options ...gcpspanner.SyncWebFeaturesOption) error
	FetchAllWebFeatureIDsAndKeys(ctx context.Context) ([]gcpspanner.SpannerFeatureIDAndKey, error)
	UpsertFeatureBaselineStatus(ctx context.Context, featureID string, status gcpspanner.FeatureBaselineStatus) error
	SyncBrowserFeatureAvailabilities(
		ctx context.Context,
		availabilities map[string][]gcpspanner.BrowserFeatureAvailability) error
	UpsertFeatureSpec(ctx context.Context, webFeatureID string, input gcpspanner.FeatureSpec) error
	UpsertFeatureDiscouragedDetails(ctx context.Context, featureID string,
		in gcpspanner.FeatureDiscouragedDetails) error
	PrecalculateBrowserFeatureSupportEvents(ctx context.Context, startAt, endAt time.Time) error
	SyncMovedWebFeatures(ctx context.Context, features []gcpspanner.MovedWebFeature) error
	SyncSplitWebFeatures(ctx context.Context, features []gcpspanner.SplitWebFeature) error
}

WebFeatureSpannerClient expects a subset of the functionality from lib/gcpspanner that only apply to WebFeatures.

type WebFeaturesConsumer

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

WebFeaturesConsumer handles the conversion of web feature data between the workflow/API input format and the format used by the GCP Spanner client.

func NewWebFeaturesConsumer

func NewWebFeaturesConsumer(client WebFeatureSpannerClient) *WebFeaturesConsumer

NewWebFeaturesConsumer constructs an adapter for the web features consumer service.

func (*WebFeaturesConsumer) InsertMovedWebFeatures

func (c *WebFeaturesConsumer) InsertMovedWebFeatures(
	ctx context.Context,
	data map[string]webdxfeaturetypes.FeatureMovedData) error

func (*WebFeaturesConsumer) InsertSplitWebFeatures

func (c *WebFeaturesConsumer) InsertSplitWebFeatures(
	ctx context.Context,
	data map[string]webdxfeaturetypes.FeatureSplitData) error

func (*WebFeaturesConsumer) InsertWebFeatures

func (c *WebFeaturesConsumer) InsertWebFeatures(
	ctx context.Context,
	data *webdxfeaturetypes.ProcessedWebFeaturesData,
	startAt, endAt time.Time) (map[string]string, error)

type WebFeaturesMappingClient

type WebFeaturesMappingClient interface {
	SyncWebFeaturesMappingData(ctx context.Context, data []gcpspanner.WebFeaturesMappingData) error
}

WebFeaturesMappingClient is the client for interacting with the web features mapping data in Spanner.

type WebFeaturesMappingConsumer

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

WebFeaturesMappingConsumer is a consumer for web features mapping data.

func NewWebFeaturesMappingConsumer

func NewWebFeaturesMappingConsumer(client WebFeaturesMappingClient) *WebFeaturesMappingConsumer

NewWebFeaturesMappingConsumer creates a new WebFeaturesMappingConsumer.

func (*WebFeaturesMappingConsumer) SyncWebFeaturesMappingData

func (a *WebFeaturesMappingConsumer) SyncWebFeaturesMappingData(
	ctx context.Context,
	mappings webfeaturesmappingtypes.WebFeaturesMappings,
) error

SyncWebFeaturesMappingData syncs the web features mapping data to Spanner.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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