pwa

package
v4.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 11 Imported by: 0

README

GWC | Pwa Library

GoWebComponents (GWC)

High-Level Overview

The pwa library contains progressive web app helpers such as persistence, diagnostics, and client capability integrations.

WASM Release Safety

WasmReleaseManifest carries an optional BuildID that participates in revisions and rollout decisions. ChooseWasmRollout assigns clients to stable or canary artifacts deterministically from client ID plus salt, while rollback forces stable selection with a cache TTL capped to one second. EvaluateVersionSkewRefresh provides the one-shot cache-bypassing reload decision and carries a state snapshot forward only when the caller reports that the two versions can migrate.

Public APIs

github.com/monstercameron/GoWebComponents/pwa (package pwa)
  • Functions: Available, BackgroundSyncCapabilities, BuildCacheStoragePlan, BuildServiceWorkerAssetPlan, Cancel, Inspect, InspectDiagnostics, MarshalManifestJSON, MarshalManifestJSONIndented, MutationQueueDiagnosticsSource, Normalized, ObserveInstallability, OpenCacheStorageManager, ParseWasmReleaseManifestJSON, Prompt, RegisterServiceWorker, RegisterSync, ReloadOnControllerChange, Revision, SkipWaiting, Snapshot, State, Subscribe, SubscribeLifecycle, Sync, Unregister, Update, Valid, Validate
  • Types: BackgroundSyncCapabilities, CacheStorageAssetKind, CacheStorageEntry, CacheStorageManager, CacheStoragePlan, CacheStoragePlanOptions, CacheStorageSnapshot, CacheStorageStrategy, DiagnosticsOptions, DiagnosticsSnapshot, InstallPromptResult, InstallabilityManager, InstallabilityOptions, InstallabilityState, InstallabilitySubscription, Manifest, ManifestDiagnostics, ManifestDisplay, ManifestImage, ManifestOrientation, ManifestShortcut, OfflineQueueDiagnostics, OfflineQueueEntry, RelatedApplication, ServiceWorkerAssetPlan, ServiceWorkerAssetPlanOptions, ServiceWorkerOptions, ServiceWorkerRegistration, ServiceWorkerSnapshot, ServiceWorkerState, ServiceWorkerSubscription, ServiceWorkerVersion, StoragePressureDiagnostics, WasmReleaseArtifact, WasmReleaseFlags, WasmReleaseManifest
  • Variables: none
  • Constants: CacheStorageAssetKindAsset, CacheStorageAssetKindMedia, CacheStorageAssetKindScript, CacheStorageAssetKindShell, CacheStorageAssetKindStyle, CacheStorageAssetKindWasm, CacheStorageStrategyCacheFirst, CacheStorageStrategyNetworkFirst, CacheStorageStrategyStaleWhileRevalidate, ManifestDisplayBrowser, ManifestDisplayFullscreen, ManifestDisplayMinimalUI, ManifestDisplayStandalone, ManifestDisplayWindowControlsOverlay, ManifestOrientationAny, ManifestOrientationLandscape, ManifestOrientationLandscapePrimary, ManifestOrientationLandscapeSecondary, ManifestOrientationNatural, ManifestOrientationPortrait, ManifestOrientationPortraitPrimary, ManifestOrientationPortraitSecondary, ServiceWorkerStateActivated, ServiceWorkerStateActivating, ServiceWorkerStateInstalled, ServiceWorkerStateInstalling, ServiceWorkerStateRedundant

Subfiles And Purpose

  • browser_globals_wasm.go - WebAssembly-specific implementation for browser_globals
  • cache_storage.go - Core implementation for cache_storage
  • cache_storage_native.go - Native (non-WASM) implementation for cache_storage
  • cache_storage_native_test.go - Tests for cache_storage_native behavior
  • cache_storage_test.go - Tests for cache_storage behavior
  • cache_storage_wasm.go - WebAssembly-specific implementation for cache_storage
  • cache_storage_wasm_test.go - Tests for cache_storage_wasm behavior
  • diagnostics.go - Core implementation for diagnostics
  • diagnostics_native.go - Native (non-WASM) implementation for diagnostics
  • diagnostics_native_test.go - Tests for diagnostics_native behavior
  • diagnostics_queue_wasm.go - WebAssembly-specific implementation for diagnostics_queue
  • diagnostics_wasm.go - WebAssembly-specific implementation for diagnostics
  • diagnostics_wasm_test.go - Tests for diagnostics_wasm behavior
  • doc.go - Package-level Go documentation
  • helpers_additional_native_test.go - Tests for helpers_additional_native behavior
  • helpers_additional_test.go - Tests for helpers_additional behavior
  • helpers_additional_wasm_test.go - Tests for helpers_additional_wasm behavior
  • installability.go - Core implementation for installability
  • installability_native.go - Native (non-WASM) implementation for installability
  • installability_native_test.go - Tests for installability_native behavior
  • installability_wasm.go - WebAssembly-specific implementation for installability
  • installability_wasm_test.go - Tests for installability_wasm behavior
  • manifest.go - Core implementation for manifest
  • manifest_test.go - Tests for manifest behavior
  • release_manifest.go - Core implementation for release_manifest
  • release_manifest_test.go - Tests for release_manifest behavior
  • service_worker.go - Core implementation for service_worker
  • service_worker_native.go - Native (non-WASM) implementation for service_worker
  • service_worker_native_test.go - Tests for service_worker_native behavior
  • service_worker_wasm.go - WebAssembly-specific implementation for service_worker
  • service_worker_wasm_test.go - Tests for service_worker_wasm behavior

File Map

pwa/
|-- browser_globals_wasm.go
|-- cache_storage.go
|-- cache_storage_native.go
|-- cache_storage_native_test.go
|-- cache_storage_test.go
|-- cache_storage_wasm.go
|-- cache_storage_wasm_test.go
|-- diagnostics.go
|-- diagnostics_native.go
|-- diagnostics_native_test.go
|-- diagnostics_queue_wasm.go
|-- diagnostics_wasm.go
|-- diagnostics_wasm_test.go
|-- doc.go
|-- helpers_additional_native_test.go
|-- helpers_additional_test.go
|-- helpers_additional_wasm_test.go
|-- installability.go
|-- installability_native.go
|-- installability_native_test.go
|-- installability_wasm.go
|-- installability_wasm_test.go
|-- manifest.go
|-- manifest_test.go
|-- release_manifest.go
|-- release_manifest_test.go
|-- service_worker.go
|-- service_worker_native.go
|-- service_worker_native_test.go
|-- service_worker_wasm.go
\-- service_worker_wasm_test.go

Documentation

Overview

Package pwa provides small, explicit Progressive Web App helpers that stay outside the core rendering runtime. The current shipped surface covers web app manifest generation, explicit service-worker registration and update lifecycle coordination, installability observation, release-manifest to service-worker asset planning, Cache Storage coordination, and structured PWA diagnostics so applications can add installability and offline behavior without hiding ownership inside unrelated runtime code.

Index

Examples

Constants

View Source
const (
	ServiceWorkerTypeClassic string = "classic"
	ServiceWorkerTypeModule  string = "module"
)

Service-worker script type values for ServiceWorkerOptions.Type (the standard ServiceWorkerContainer.register `type` option). String constants — assignable to the field — so a typo is a compile error at the use site instead of a silent registration quirk.

View Source
const (
	UpdateViaCacheImports string = "imports"
	UpdateViaCacheAll     string = "all"
	UpdateViaCacheNone    string = "none"
)

HTTP-cache policy values for ServiceWorkerOptions.UpdateViaCache (the standard `updateViaCache` option): "imports" (default — bypass cache for the top script, use it for imports), "all" (use the cache for both), "none" (bypass for both).

Variables

This section is empty.

Functions

func MarshalManifestJSON

func MarshalManifestJSON(parseManifest Manifest) ([]byte, error)

MarshalManifestJSON serializes a normalized, validated Manifest to JSON bytes.

func MarshalManifestJSONIndented

func MarshalManifestJSONIndented(parseManifest Manifest, parsePrefix, parseIndent string) ([]byte, error)

MarshalManifestJSONIndented serializes a normalized, validated Manifest to indented JSON bytes.

Types

type BackgroundSyncCapabilities

type BackgroundSyncCapabilities struct {
	OneShot  bool
	Periodic bool
}

func (BackgroundSyncCapabilities) Available

func (parseCapabilities BackgroundSyncCapabilities) Available() bool

type CacheStorageAssetKind

type CacheStorageAssetKind string
const (
	CacheStorageAssetKindShell  CacheStorageAssetKind = "shell"
	CacheStorageAssetKindWasm   CacheStorageAssetKind = "wasm"
	CacheStorageAssetKindScript CacheStorageAssetKind = "script"
	CacheStorageAssetKindStyle  CacheStorageAssetKind = "style"
	CacheStorageAssetKindMedia  CacheStorageAssetKind = "media"
	CacheStorageAssetKindAsset  CacheStorageAssetKind = "asset"
)

type CacheStorageEntry

type CacheStorageEntry struct {
	URL      string
	Kind     CacheStorageAssetKind
	Strategy CacheStorageStrategy
}

type CacheStorageManager

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

func OpenCacheStorageManager

func OpenCacheStorageManager() (CacheStorageManager, error)

OpenCacheStorageManager is a non-browser stub that always returns an unavailable error.

func (CacheStorageManager) Inspect

func (parseM CacheStorageManager) Inspect(parseCtx context.Context, parsePlan CacheStoragePlan) (CacheStorageSnapshot, error)

func (CacheStorageManager) Sync

func (parseM CacheStorageManager) Sync(parseCtx context.Context, parsePlan CacheStoragePlan) (CacheStorageSnapshot, error)

type CacheStoragePlan

type CacheStoragePlan struct {
	CacheName        string
	CachePrefix      string
	ManifestRevision string
	Entries          []CacheStorageEntry
}

func BuildCacheStoragePlan

func BuildCacheStoragePlan(parseAssetPlan ServiceWorkerAssetPlan, parseOptions ...CacheStoragePlanOptions) (CacheStoragePlan, error)

BuildCacheStoragePlan builds a CacheStoragePlan from a ServiceWorkerAssetPlan and optional options.

Example

ExampleBuildCacheStoragePlan shows building a service-worker cache plan from an asset plan, the input to a generated service worker for offline support.

package main

import (
	"github.com/monstercameron/GoWebComponents/v4/pwa"
)

func main() {
	parsePlan, parseErr := pwa.BuildCacheStoragePlan(pwa.ServiceWorkerAssetPlan{})
	if parseErr != nil {
		return
	}
	_ = parsePlan
}

type CacheStoragePlanOptions

type CacheStoragePlanOptions struct {
	CachePrefix   string
	ShellURLs     []string
	ScriptURLs    []string
	StyleURLs     []string
	MediaURLs     []string
	AssetURLs     []string
	ShellStrategy CacheStorageStrategy
}

type CacheStorageSnapshot

type CacheStorageSnapshot struct {
	CacheName   string
	CachePrefix string
	EntryCount  int
	Entries     []CacheStorageEntry
	CacheNames  []string
}

type CacheStorageStrategy

type CacheStorageStrategy string
const (
	CacheStorageStrategyCacheFirst           CacheStorageStrategy = "cache-first"
	CacheStorageStrategyNetworkFirst         CacheStorageStrategy = "network-first"
	CacheStorageStrategyStaleWhileRevalidate CacheStorageStrategy = "stale-while-revalidate"
)

type DiagnosticsOptions

type DiagnosticsOptions struct {
	Manifest         *Manifest
	Installability   *InstallabilityManager
	ServiceWorker    *ServiceWorkerRegistration
	CacheStorage     *CacheStorageManager
	CacheStoragePlan *CacheStoragePlan
	OfflineQueue     func() ([]OfflineQueueEntry, error)
}

type DiagnosticsSnapshot

type DiagnosticsSnapshot struct {
	Manifest       ManifestDiagnostics
	Installability InstallabilityState
	ServiceWorker  ServiceWorkerSnapshot
	CacheStorage   CacheStorageSnapshot
	OfflineQueue   OfflineQueueDiagnostics
	Storage        StoragePressureDiagnostics
}

func InspectDiagnostics

func InspectDiagnostics(parseDiagnosticsCtx context.Context, parseDiagnosticsOptions DiagnosticsOptions) (DiagnosticsSnapshot, error)

InspectDiagnostics is a non-browser stub that always returns an unavailable error.

type InstallPromptResult

type InstallPromptResult struct {
	Outcome  string
	Platform string
}

type InstallabilityManager

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

func ObserveInstallability

func ObserveInstallability(parseInstallOptions InstallabilityOptions) (InstallabilityManager, error)

ObserveInstallability is a non-browser stub that always returns an unavailable error.

func (InstallabilityManager) Prompt

func (parseManager InstallabilityManager) Prompt(parseInstallCtx context.Context) (InstallPromptResult, error)

func (InstallabilityManager) State

func (parseManager InstallabilityManager) State() InstallabilityState

func (InstallabilityManager) Subscribe

func (parseManager InstallabilityManager) Subscribe(parseInstallHandler func(InstallabilityState)) (InstallabilitySubscription, error)

type InstallabilityOptions

type InstallabilityOptions struct {
	Manifest *Manifest
}

type InstallabilityState

type InstallabilityState struct {
	ManifestValid   bool
	ManifestError   string
	PromptAvailable bool
	Installed       bool
	Reasons         []string
}

type InstallabilitySubscription

type InstallabilitySubscription = Subscription

InstallabilitySubscription is the handle returned by InstallabilityManager.Subscribe.

type Manifest

type Manifest struct {
	ID                        string               `json:"id,omitempty"`
	Name                      string               `json:"name,omitempty"`
	ShortName                 string               `json:"short_name,omitempty"`
	Description               string               `json:"description,omitempty"`
	StartURL                  string               `json:"start_url,omitempty"`
	Scope                     string               `json:"scope,omitempty"`
	Display                   ManifestDisplay      `json:"display,omitempty"`
	DisplayOverride           []ManifestDisplay    `json:"display_override,omitempty"`
	Orientation               ManifestOrientation  `json:"orientation,omitempty"`
	ThemeColor                string               `json:"theme_color,omitempty"`
	BackgroundColor           string               `json:"background_color,omitempty"`
	Lang                      string               `json:"lang,omitempty"`
	Dir                       string               `json:"dir,omitempty"`
	Categories                []string             `json:"categories,omitempty"`
	Icons                     []ManifestImage      `json:"icons,omitempty"`
	Screenshots               []ManifestImage      `json:"screenshots,omitempty"`
	Shortcuts                 []ManifestShortcut   `json:"shortcuts,omitempty"`
	PreferRelatedApplications bool                 `json:"prefer_related_applications,omitempty"`
	RelatedApplications       []RelatedApplication `json:"related_applications,omitempty"`
}

func (Manifest) Normalized

func (parseM Manifest) Normalized() Manifest

func (Manifest) Validate

func (parseM Manifest) Validate() error

type ManifestDiagnostics

type ManifestDiagnostics struct {
	Valid bool
	Error string
}

type ManifestDisplay

type ManifestDisplay string
const (
	ManifestDisplayBrowser               ManifestDisplay = "browser"
	ManifestDisplayMinimalUI             ManifestDisplay = "minimal-ui"
	ManifestDisplayStandalone            ManifestDisplay = "standalone"
	ManifestDisplayFullscreen            ManifestDisplay = "fullscreen"
	ManifestDisplayWindowControlsOverlay ManifestDisplay = "window-controls-overlay"
)

func (ManifestDisplay) Normalized

func (parseD ManifestDisplay) Normalized() ManifestDisplay

func (ManifestDisplay) Valid

func (parseD ManifestDisplay) Valid() bool

type ManifestImage

type ManifestImage struct {
	Src        string `json:"src,omitempty"`
	Sizes      string `json:"sizes,omitempty"`
	Type       string `json:"type,omitempty"`
	Purpose    string `json:"purpose,omitempty"`
	Label      string `json:"label,omitempty"`
	FormFactor string `json:"form_factor,omitempty"`
}

type ManifestOrientation

type ManifestOrientation string
const (
	ManifestOrientationAny                ManifestOrientation = "any"
	ManifestOrientationNatural            ManifestOrientation = "natural"
	ManifestOrientationLandscape          ManifestOrientation = "landscape"
	ManifestOrientationLandscapePrimary   ManifestOrientation = "landscape-primary"
	ManifestOrientationLandscapeSecondary ManifestOrientation = "landscape-secondary"
	ManifestOrientationPortrait           ManifestOrientation = "portrait"
	ManifestOrientationPortraitPrimary    ManifestOrientation = "portrait-primary"
	ManifestOrientationPortraitSecondary  ManifestOrientation = "portrait-secondary"
)

func (ManifestOrientation) Normalized

func (parseO ManifestOrientation) Normalized() ManifestOrientation

func (ManifestOrientation) Valid

func (parseO ManifestOrientation) Valid() bool

type ManifestShortcut

type ManifestShortcut struct {
	Name        string          `json:"name,omitempty"`
	ShortName   string          `json:"short_name,omitempty"`
	Description string          `json:"description,omitempty"`
	URL         string          `json:"url,omitempty"`
	Icons       []ManifestImage `json:"icons,omitempty"`
}

type OfflineQueueDiagnostics

type OfflineQueueDiagnostics struct {
	TotalEntries    int
	QueuedEntries   int
	RetryingEntries int
	DeadEntries     int
	OldestCreatedAt time.Time
	LatestUpdatedAt time.Time
}

type OfflineQueueEntry

type OfflineQueueEntry struct {
	State     string
	CreatedAt time.Time
	UpdatedAt time.Time
}

type RelatedApplication

type RelatedApplication struct {
	Platform string `json:"platform,omitempty"`
	URL      string `json:"url,omitempty"`
	ID       string `json:"id,omitempty"`
}

type ServiceWorkerAssetPlan

type ServiceWorkerAssetPlan struct {
	CacheName        string
	ManifestRevision string
	WasmURL          string
	ImmutableURLs    []string
	ShellURLs        []string
	PrecacheURLs     []string
}

func BuildServiceWorkerAssetPlan

func BuildServiceWorkerAssetPlan(parseManifest WasmReleaseManifest, parseOptions ...ServiceWorkerAssetPlanOptions) (ServiceWorkerAssetPlan, error)

BuildServiceWorkerAssetPlan builds a ServiceWorkerAssetPlan from a validated WasmReleaseManifest.

type ServiceWorkerAssetPlanOptions

type ServiceWorkerAssetPlanOptions struct {
	BaseURL       string
	CachePrefix   string
	ImmutableURLs []string
	ShellURLs     []string
}

type ServiceWorkerOptions

type ServiceWorkerOptions struct {
	URL   string
	Scope string
	// Type is the worker script type: use ServiceWorkerTypeClassic / ServiceWorkerTypeModule
	// (a typo'd string silently registers nothing useful).
	Type string
	// UpdateViaCache is the HTTP-cache policy for the worker script + its imports: use
	// UpdateViaCacheImports / UpdateViaCacheAll / UpdateViaCacheNone.
	UpdateViaCache string
}

type ServiceWorkerRegistration

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

func RegisterServiceWorker

func RegisterServiceWorker(parseServiceCtx context.Context, parseServiceOptions ServiceWorkerOptions) (ServiceWorkerRegistration, error)

RegisterServiceWorker is a non-browser stub that always returns an unavailable error.

func (ServiceWorkerRegistration) BackgroundSyncCapabilities

func (parseRegistration ServiceWorkerRegistration) BackgroundSyncCapabilities() BackgroundSyncCapabilities

func (ServiceWorkerRegistration) RegisterSync

func (parseRegistration ServiceWorkerRegistration) RegisterSync(parseSyncCtx context.Context, parseSyncTag string) error

func (ServiceWorkerRegistration) ReloadOnControllerChange

func (parseRegistration ServiceWorkerRegistration) ReloadOnControllerChange() (ServiceWorkerSubscription, error)

func (ServiceWorkerRegistration) SkipWaiting

func (parseRegistration ServiceWorkerRegistration) SkipWaiting(parseSkipCtx context.Context) error

func (ServiceWorkerRegistration) Snapshot

func (parseRegistration ServiceWorkerRegistration) Snapshot() ServiceWorkerSnapshot

func (ServiceWorkerRegistration) SubscribeLifecycle

func (parseRegistration ServiceWorkerRegistration) SubscribeLifecycle(parseLifecycleHandler func(ServiceWorkerSnapshot)) (ServiceWorkerSubscription, error)

func (ServiceWorkerRegistration) Unregister

func (parseRegistration ServiceWorkerRegistration) Unregister(parseUnregisterCtx context.Context) (bool, error)

func (ServiceWorkerRegistration) Update

func (parseRegistration ServiceWorkerRegistration) Update(parseUpdateCtx context.Context) error

type ServiceWorkerSnapshot

type ServiceWorkerSnapshot struct {
	Scope         string
	HasController bool
	Installing    ServiceWorkerVersion
	Waiting       ServiceWorkerVersion
	Active        ServiceWorkerVersion
}

type ServiceWorkerState

type ServiceWorkerState string
const (
	ServiceWorkerStateInstalling ServiceWorkerState = "installing"
	ServiceWorkerStateInstalled  ServiceWorkerState = "installed"
	ServiceWorkerStateActivating ServiceWorkerState = "activating"
	ServiceWorkerStateActivated  ServiceWorkerState = "activated"
	ServiceWorkerStateRedundant  ServiceWorkerState = "redundant"
)

type ServiceWorkerSubscription

type ServiceWorkerSubscription = Subscription

ServiceWorkerSubscription is the handle returned by ServiceWorkerRegistration.SubscribeLifecycle and ReloadOnControllerChange.

type ServiceWorkerVersion

type ServiceWorkerVersion struct {
	ScriptURL string
	State     ServiceWorkerState
}

type StoragePressureDiagnostics

type StoragePressureDiagnostics struct {
	Available         bool
	Persistent        bool
	UsageBytes        int64
	QuotaBytes        int64
	IndexedDBBytes    int64
	CacheStorageBytes int64
	UsageRatio        float64
	Pressure          string
}

type Subscription

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

Subscription is a cancellable handle returned by the package's subscribe APIs (service-worker lifecycle, installability). Cancel stops delivery and is safe to call more than once. The two named aliases below preserve the original API surface while sharing one implementation.

func (Subscription) Cancel

func (parseSubscription Subscription) Cancel()

Cancel stops the subscription's callbacks. No-op if already cancelled or never armed.

type UpdatePrompt

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

UpdatePrompt is the composite "a new version is available" flow on top of the service-worker lifecycle primitives. An app wires it to a banner: when a new service worker is waiting, Available() becomes true and the OnChange callback fires; calling Apply activates the new worker (SkipWaiting) and reloads once it takes control (ReloadOnControllerChange). This is the E3 10-rung "update-prompt flow" as one object, so apps don't hand-assemble the three primitives (the prior gap was that the primitives existed but the composite did not).

func NewUpdatePrompt

func NewUpdatePrompt(parseRegistration ServiceWorkerRegistration) *UpdatePrompt

NewUpdatePrompt builds an update-prompt controller for a registration.

func (*UpdatePrompt) Apply

func (parsePrompt *UpdatePrompt) Apply(parseCtx context.Context) error

Apply activates the waiting worker and reloads the page once it takes control. It arms the controller-change reload BEFORE skipping waiting so the reload fires on activation, not before.

func (*UpdatePrompt) Available

func (parsePrompt *UpdatePrompt) Available() bool

Available reports whether a new service worker is waiting to take over.

func (*UpdatePrompt) OnChange

func (parsePrompt *UpdatePrompt) OnChange(parseHandler func(bool))

OnChange registers the callback invoked whenever update-availability changes (e.g. to show or hide a banner). It is called with the current availability immediately if already started.

func (*UpdatePrompt) Start

func (parsePrompt *UpdatePrompt) Start() error

Start subscribes to the service-worker lifecycle and begins tracking whether a waiting worker (a ready update) exists. It is idempotent.

func (*UpdatePrompt) Stop

func (parsePrompt *UpdatePrompt) Stop()

Stop cancels the lifecycle subscription.

type VersionSkewRefreshDecision

type VersionSkewRefreshDecision struct {
	Mismatch             bool
	ShouldReload         bool
	BypassCache          bool
	LoopGuarded          bool
	SnapshotBeforeReload []byte
	RestoreAfterReload   bool
	Reason               string
}

func EvaluateVersionSkewRefresh

func EvaluateVersionSkewRefresh(parseInput VersionSkewRefreshInput) VersionSkewRefreshDecision

EvaluateVersionSkewRefresh decides whether a stale wasm/client build should perform one cache-bypassing reload and carry a compatible state snapshot across that refresh.

type VersionSkewRefreshInput

type VersionSkewRefreshInput struct {
	ClientBuildID      string
	ServerBuildID      string
	ReloadAlreadyTried bool
	StateSnapshotJSON  []byte
	VersionsCanMigrate bool
}

type WasmReleaseArtifact

type WasmReleaseArtifact struct {
	Path   string `json:"path,omitempty"`
	Bytes  int64  `json:"bytes,omitempty"`
	SHA256 string `json:"sha256,omitempty"`
}

type WasmReleaseFlags

type WasmReleaseFlags struct {
	Trimpath    bool   `json:"trimpath,omitempty"`
	LDFlags     string `json:"ldflags,omitempty"`
	GCFlags     string `json:"gcflags,omitempty"`
	BuildVCS    string `json:"buildvcs,omitempty"`
	Compression bool   `json:"compression,omitempty"`
}

type WasmReleaseManifest

type WasmReleaseManifest struct {
	Package   string                         `json:"package,omitempty"`
	Profile   string                         `json:"profile,omitempty"`
	GOOS      string                         `json:"goos,omitempty"`
	GOARCH    string                         `json:"goarch,omitempty"`
	BuildID   string                         `json:"buildId,omitempty"`
	Flags     WasmReleaseFlags               `json:"flags"`
	Artifacts map[string]WasmReleaseArtifact `json:"artifacts,omitempty"`
}

func ParseWasmReleaseManifestJSON

func ParseWasmReleaseManifestJSON(parseData []byte) (WasmReleaseManifest, error)

ParseWasmReleaseManifestJSON parses and validates a WasmReleaseManifest from JSON bytes.

func (WasmReleaseManifest) Normalized

func (parseM WasmReleaseManifest) Normalized() WasmReleaseManifest

func (WasmReleaseManifest) Revision

func (parseM WasmReleaseManifest) Revision() string

func (WasmReleaseManifest) Validate

func (parseM WasmReleaseManifest) Validate() error

type WasmRolloutConfig

type WasmRolloutConfig struct {
	Stable          WasmReleaseManifest
	Canary          WasmReleaseManifest
	CanaryPercent   int
	Salt            string
	CacheTTLSeconds int
	Rollback        bool
}

type WasmRolloutDecision

type WasmRolloutDecision struct {
	Cohort           string
	BuildID          string
	WasmURL          string
	SHA256           string
	ManifestRevision string
	CacheTTLSeconds  int
	RolledBack       bool
}

func ChooseWasmRollout

func ChooseWasmRollout(parseConfig WasmRolloutConfig, parseClientID string) (WasmRolloutDecision, error)

ChooseWasmRollout deterministically assigns one client to the stable or canary wasm artifact. Rollback forces every client to stable immediately and caps the response TTL at one second so caches converge quickly.

Jump to

Keyboard shortcuts

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