Documentation
¶
Overview ¶
Package reloadwait isolates browser runtime orchestration for devserver.
Devserver uses this package to keep refresh-server lifecycle, generation- based cancellation, readiness waiting, framework runtime reload hooks, and final browser payload broadcasts in one place.
Index ¶
- func BroadcastReloadAfterReadinessWithGeneration(options BroadcastReloadAfterReadinessWithGenerationOptions)
- func BroadcastReloadPayloadIfGenerationCurrent(options BroadcastReloadPayloadIfGenerationCurrentOptions)
- func CallFrameworkRuntimeReloadEndpointWithContext(reloadContext context.Context, appPort int, ...) error
- func ExecuteFrameworkRuntimeReloadRequestsWithContext(reloadContext context.Context, appPort int, ...) error
- func ExecuteInvalidateAsync(options ExecuteInvalidateAsyncOptions)
- func NewRefreshRuntimeMux(refreshManager *broadcast.Manager) *http.ServeMux
- func NotifyViteFileMapChangedWithContext(invalidateContext context.Context, vitePort int) error
- func ResolveDirectoryPathFromFilePath(path string) string
- func ResolveRefreshRuntimePortFromEnvironmentOrDefault(defaultPort int) int
- func ResolveViteReadyURL(vitePort int) string
- func ResolveViteReadyURLs(vitePort int) []string
- func ShouldBroadcastReloadPayloadAfterReadiness(reloadOptions eventpipeline.ReloadOpts) bool
- func StopRefreshRuntime(refreshRuntimeState RefreshRuntimeState)
- func WaitForReloadReadiness(options WaitForReloadReadinessOptions) bool
- type BroadcastReloadAfterReadinessWithGenerationOptions
- type BroadcastReloadPayloadIfGenerationCurrentOptions
- type CancelableGeneration
- func (tracker *CancelableGeneration) BeginNextGenerationAndClearCancel() (uint64, context.CancelFunc)
- func (tracker *CancelableGeneration) CancelAndAdvance()
- func (tracker *CancelableGeneration) ClearCancelForGeneration(generation uint64)
- func (tracker *CancelableGeneration) IsGenerationCurrent(generation uint64) bool
- func (tracker *CancelableGeneration) SetCancelForGeneration(generation uint64, cancel context.CancelFunc) bool
- type ExecuteInvalidateAsyncOptions
- type RefreshRuntimeStartResult
- type RefreshRuntimeState
- type WaitForReloadReadinessOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BroadcastReloadAfterReadinessWithGeneration ¶
func BroadcastReloadAfterReadinessWithGeneration( options BroadcastReloadAfterReadinessWithGenerationOptions, )
BroadcastReloadAfterReadinessWithGeneration waits for readiness, performs framework runtime reload requests, and then broadcasts when still current.
func BroadcastReloadPayloadIfGenerationCurrent ¶
func BroadcastReloadPayloadIfGenerationCurrent( options BroadcastReloadPayloadIfGenerationCurrentOptions, )
BroadcastReloadPayloadIfGenerationCurrent sends payload only if generation is still current before and after refresh-manager lookup.
func CallFrameworkRuntimeReloadEndpointWithContext ¶
func CallFrameworkRuntimeReloadEndpointWithContext( reloadContext context.Context, appPort int, reloadRequest wavewatch.FrameworkRuntimeReloadRequest, ) error
CallFrameworkRuntimeReloadEndpointWithContext posts to one framework runtime reload endpoint exposed by the running app process.
func ExecuteFrameworkRuntimeReloadRequestsWithContext ¶
func ExecuteFrameworkRuntimeReloadRequestsWithContext( reloadContext context.Context, appPort int, reloadRequests []wavewatch.FrameworkRuntimeReloadRequest, ) error
ExecuteFrameworkRuntimeReloadRequestsWithContext executes one or more runtime reload endpoint requests and returns on first failure.
func ExecuteInvalidateAsync ¶
func ExecuteInvalidateAsync(options ExecuteInvalidateAsyncOptions)
ExecuteInvalidateAsync runs invalidate outside watcher critical path and falls back to hard reload when invalidate fails.
func NewRefreshRuntimeMux ¶
NewRefreshRuntimeMux builds the refresh server endpoint mux.
func NotifyViteFileMapChangedWithContext ¶
NotifyViteFileMapChangedWithContext posts to Vite's filemap-changed notify endpoint with explicit cancellation context.
func ResolveDirectoryPathFromFilePath ¶
ResolveDirectoryPathFromFilePath returns the cleaned parent directory for a path.
func ResolveRefreshRuntimePortFromEnvironmentOrDefault ¶
ResolveRefreshRuntimePortFromEnvironmentOrDefault resolves refresh port from env.
func ResolveViteReadyURL ¶
ResolveViteReadyURL resolves the canonical Vite readiness probe URL.
func ResolveViteReadyURLs ¶
ResolveViteReadyURLs resolves all supported Vite readiness probe URLs.
func ShouldBroadcastReloadPayloadAfterReadiness ¶
func ShouldBroadcastReloadPayloadAfterReadiness( reloadOptions eventpipeline.ReloadOpts, ) bool
ShouldBroadcastReloadPayloadAfterReadiness reports whether payload should be sent after readiness checks complete.
func StopRefreshRuntime ¶
func StopRefreshRuntime(refreshRuntimeState RefreshRuntimeState)
StopRefreshRuntime terminates refresh server and manager resources.
func WaitForReloadReadiness ¶
func WaitForReloadReadiness( options WaitForReloadReadinessOptions, ) bool
WaitForReloadReadiness applies readiness policy for reload options.
Types ¶
type BroadcastReloadAfterReadinessWithGenerationOptions ¶
type BroadcastReloadAfterReadinessWithGenerationOptions struct {
ReadinessContext context.Context
ReadinessCancel context.CancelFunc
ReloadBroadcastGeneration uint64
ReloadOptions eventpipeline.ReloadOpts
ClearCancelForGeneration func(uint64)
IsGenerationCurrent func(uint64) bool
WaitForReloadReadiness func(
context.Context,
eventpipeline.ReloadOpts,
) bool
ExecuteFrameworkRuntimeReloadRequestsWithContext func(
context.Context,
[]wavewatch.FrameworkRuntimeReloadRequest,
) error
TriggerRestartNoGo func()
ShouldBroadcastReloadPayloadAfterReadiness func(
eventpipeline.ReloadOpts,
) bool
BroadcastReloadPayloadIfGenerationCurrent func(
uint64,
broadcast.Payload,
)
Log *slog.Logger
}
BroadcastReloadAfterReadinessWithGenerationOptions configures deferred reload broadcast behavior.
type BroadcastReloadPayloadIfGenerationCurrentOptions ¶
type BroadcastReloadPayloadIfGenerationCurrentOptions struct {
ReloadBroadcastGeneration uint64
Payload broadcast.Payload
IsGenerationCurrent func(uint64) bool
CurrentRefreshManager func() *broadcast.Manager
}
BroadcastReloadPayloadIfGenerationCurrentOptions configures conditional payload broadcast.
type CancelableGeneration ¶
type CancelableGeneration struct {
// contains filtered or unexported fields
}
CancelableGeneration tracks a monotonically increasing generation id and the active cancellation handle for that generation.
func (*CancelableGeneration) BeginNextGenerationAndClearCancel ¶
func (tracker *CancelableGeneration) BeginNextGenerationAndClearCancel() ( uint64, context.CancelFunc, )
BeginNextGenerationAndClearCancel increments generation and returns any previously tracked cancellation handle.
func (*CancelableGeneration) CancelAndAdvance ¶
func (tracker *CancelableGeneration) CancelAndAdvance()
CancelAndAdvance advances generation and cancels the previously active handle.
func (*CancelableGeneration) ClearCancelForGeneration ¶
func (tracker *CancelableGeneration) ClearCancelForGeneration( generation uint64, )
ClearCancelForGeneration clears cancel only if generation is still current.
func (*CancelableGeneration) IsGenerationCurrent ¶
func (tracker *CancelableGeneration) IsGenerationCurrent( generation uint64, ) bool
IsGenerationCurrent reports whether generation still matches current value.
func (*CancelableGeneration) SetCancelForGeneration ¶
func (tracker *CancelableGeneration) SetCancelForGeneration( generation uint64, cancel context.CancelFunc, ) bool
SetCancelForGeneration installs cancel only if generation is still current.
type ExecuteInvalidateAsyncOptions ¶
type ExecuteInvalidateAsyncOptions struct {
BrowserDecision eventpipeline.BrowserPhaseDecision
InvalidateGeneration uint64
SetCancelForGeneration func(
invalidateGeneration uint64,
invalidateCancel context.CancelFunc,
) bool
ClearCancelForGeneration func(
invalidateGeneration uint64,
)
IsGenerationCurrent func(
invalidateGeneration uint64,
) bool
LaunchAsyncWork func(
runAsyncWork func(context.Context),
)
NotifyViteFileMapChangedWithContext func(context.Context) error
BroadcastReload func(eventpipeline.ReloadOpts)
UsingVite bool
Log *slog.Logger
}
ExecuteInvalidateAsyncOptions configures one asynchronous Vite invalidate attempt.
type RefreshRuntimeStartResult ¶
type RefreshRuntimeStartResult struct {
State RefreshRuntimeState
RunManager func()
RunServer func()
}
RefreshRuntimeStartResult contains started refresh server state plus runtime runners.
func StartRefreshRuntime ¶
func StartRefreshRuntime( preferredPort int, log *slog.Logger, ) (RefreshRuntimeStartResult, error)
StartRefreshRuntime initializes refresh server resources and returns runners that should be launched by the caller.
type RefreshRuntimeState ¶
type RefreshRuntimeState struct {
Manager *broadcast.Manager
Server *http.Server
Port int
Cancel context.CancelFunc
}
RefreshRuntimeState captures running refresh server resources.
type WaitForReloadReadinessOptions ¶
type WaitForReloadReadinessOptions struct {
ReadinessContext context.Context
ReloadOptions eventpipeline.ReloadOpts
UsingVite bool
IsViteRunning func() bool
CycleViteAndWaitForReadinessWithContext func(context.Context) bool
WaitForAppWithContext func(context.Context) bool
WaitForViteWithContext func(context.Context) bool
Log *slog.Logger
}
WaitForReloadReadinessOptions configures reload readiness policy execution.