prebuilds
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Index¶
- Constants
- type EnterpriseClaimer
- type MetricsCollector
- func (mc *MetricsCollector) BackgroundFetch(ctx context.Context, updateInterval, updateTimeout time.Duration)
- func (mc *MetricsCollector) Collect(metricsCh chan<- prometheus.Metric)
- func (*MetricsCollector) Describe(descCh chan<- *prometheus.Desc)
- func (mc *MetricsCollector) UpdateState(ctx context.Context, timeout time.Duration) error
- type StoreReconciler
- func (c *StoreReconciler) CalculateActions(ctx context.Context, snapshot prebuilds.PresetSnapshot) ([]*prebuilds.ReconciliationActions, error)
- func (c *StoreReconciler) ForceMetricsUpdate(ctx context.Context) error
- func (c *StoreReconciler) ReconcileAll(ctx context.Context) error
- func (c *StoreReconciler) ReconcilePreset(ctx context.Context, ps prebuilds.PresetSnapshot) error
- func (c *StoreReconciler) Run(ctx context.Context)
- func (c *StoreReconciler) SnapshotState(ctx context.Context, store database.Store) (*prebuilds.GlobalSnapshot, error)
- func (c *StoreReconciler) Stop(ctx context.Context, cause error)
- func (c *StoreReconciler) TrackResourceReplacement(ctx context.Context, workspaceID, buildID uuid.UUID, ...)
- func (c *StoreReconciler) WithReconciliationLock(ctx context.Context, logger slog.Logger, ...) error
Constants¶
const (MetricCreatedCount = namespace + "created_total"MetricFailedCount = namespace + "failed_total"MetricClaimedCount = namespace + "claimed_total"MetricResourceReplacementsCount = namespace + "resource_replacements_total"MetricDesiredGauge = namespace + "desired"MetricRunningGauge = namespace + "running"MetricEligibleGauge = namespace + "eligible"MetricPresetHardLimitedGauge = namespace + "preset_hard_limited"MetricLastUpdatedGauge = namespace + "metrics_last_updated")
Variables¶
This section is empty.
Functions¶
This section is empty.
Types¶
typeEnterpriseClaimer¶
type EnterpriseClaimer struct {// contains filtered or unexported fields}
funcNewEnterpriseClaimer¶
func NewEnterpriseClaimer(storedatabase.Store) *EnterpriseClaimer
func (EnterpriseClaimer)Initiator¶
func (EnterpriseClaimer) Initiator()uuid.UUID
typeMetricsCollector¶
type MetricsCollector struct {// contains filtered or unexported fields}
funcNewMetricsCollector¶
func NewMetricsCollector(dbdatabase.Store, loggerslog.Logger, snapshotterprebuilds.StateSnapshotter) *MetricsCollector
func (*MetricsCollector)BackgroundFetch¶
func (mc *MetricsCollector) BackgroundFetch(ctxcontext.Context, updateInterval, updateTimeouttime.Duration)
BackgroundFetch updates the metrics state every given interval.
func (*MetricsCollector)Collect¶
func (mc *MetricsCollector) Collect(metricsCh chan<-prometheus.Metric)
Collect uses the cached state to set configured metrics.The state is cached because this function can be called multiple times per second and retrieving the current stateis an expensive operation.
func (*MetricsCollector)Describe¶
func (*MetricsCollector) Describe(descCh chan<- *prometheus.Desc)
func (*MetricsCollector)UpdateState¶
UpdateState builds the current metrics state.
typeStoreReconciler¶
type StoreReconciler struct {// contains filtered or unexported fields}
funcNewStoreReconciler¶
func NewStoreReconciler(storedatabase.Store,pspubsub.Pubsub,cfgcodersdk.PrebuildsConfig,loggerslog.Logger,clockquartz.Clock,registererprometheus.Registerer,notifEnqnotifications.Enqueuer,) *StoreReconciler
func (*StoreReconciler)CalculateActions¶
func (c *StoreReconciler) CalculateActions(ctxcontext.Context, snapshotprebuilds.PresetSnapshot) ([]*prebuilds.ReconciliationActions,error)
func (*StoreReconciler)ForceMetricsUpdate¶
func (c *StoreReconciler) ForceMetricsUpdate(ctxcontext.Context)error
ForceMetricsUpdate forces the metrics collector, if defined, to update its state (we cache the metrics state toreduce load on the database).
func (*StoreReconciler)ReconcileAll¶
func (c *StoreReconciler) ReconcileAll(ctxcontext.Context)error
ReconcileAll will attempt to resolve the desired vs actual state of all templates which have presets with prebuilds configured.
NOTE:
This function will kick of n provisioner jobs, based on the calculated state modifications.
These provisioning jobs are fire-and-forget. We DO NOT wait for the prebuilt workspaces to complete theirprovisioning. As a consequence, it's possible that another reconciliation run will occur, which will mean thatmultiple preset versions could be reconciling at once. This may mean some temporary over-provisioning, but thereconciliation loop will bring these resources back into their desired numbers in an EVENTUALLY-consistent way.
For example: we could decide to provision 1 new instance in this reconciliation.While that workspace is being provisioned, another template version is created which means this same preset willbe reconciled again, leading to another workspace being provisioned. Two workspace builds will be occurringsimultaneously for the same preset, but once both jobs have completed the reconciliation loop will notice theextraneous instance and delete it.
func (*StoreReconciler)ReconcilePreset¶
func (c *StoreReconciler) ReconcilePreset(ctxcontext.Context, psprebuilds.PresetSnapshot)error
func (*StoreReconciler)Run¶
func (c *StoreReconciler) Run(ctxcontext.Context)
func (*StoreReconciler)SnapshotState¶
func (c *StoreReconciler) SnapshotState(ctxcontext.Context, storedatabase.Store) (*prebuilds.GlobalSnapshot,error)
SnapshotState captures the current state of all prebuilds across templates.
func (*StoreReconciler)TrackResourceReplacement¶
func (c *StoreReconciler) TrackResourceReplacement(ctxcontext.Context, workspaceID, buildIDuuid.UUID, replacements []*sdkproto.ResourceReplacement)