Documentation
¶
Overview ¶
Package wavewatch defines Wave's file-watch and hook execution contract used by framework tooling, devservers, and build pipelines.
This package exists so watch-hook runtime/buildtime behavior can evolve independently from end-user JSON parsing concerns in waveconfig.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FrameworkRuntimeReloadRequest ¶
type FrameworkRuntimeReloadRequest struct {
// EndpointPath is the framework runtime endpoint path to call.
EndpointPath string
// ReloadAttemptID is the attempt identifier propagated as request header.
ReloadAttemptID string
// ExpectedBuildID is the expected framework build identifier propagated as
// request header.
ExpectedBuildID string
// ReloadTrigger is the reload trigger identifier propagated as request
// header.
ReloadTrigger string
}
FrameworkRuntimeReloadRequest describes one framework runtime reload request that must run before browser reload payload broadcast.
type HookContext ¶
type HookContext struct {
// ExecutionContext is canceled when the surrounding execution pipeline is
// canceled (for example, concurrent stage cancellation after build failure).
ExecutionContext context.Context
// FilePath is the absolute path of the changed file.
FilePath string
// ChangedFilePaths contains all changed file paths associated with the hook
// execution context. For deduped pattern hook execution, this includes all
// files in the matched batch.
ChangedFilePaths []string
// AppStoppedForBatch is true when app process shutdown already happened for
// this batch, so callback logic must not depend on live app endpoints.
AppStoppedForBatch bool
}
HookContext provides callback context during file-change handling.
type OnChangeHook ¶
type OnChangeHook struct {
// Cmd is a shell command to run.
Cmd string `json:"Cmd,omitempty"`
// CommandTimeoutMilliseconds overrides stage-level command timeout for this
// hook when > 0.
CommandTimeoutMilliseconds int `json:"CommandTimeoutMilliseconds,omitempty"`
// DisableStageCommandTimeout disables stage-level command timeout for this
// hook.
DisableStageCommandTimeout bool `json:"DisableStageCommandTimeout,omitempty"`
// CallbackTimeoutMilliseconds overrides stage-level callback timeout for this
// hook when > 0.
CallbackTimeoutMilliseconds int `json:"CallbackTimeoutMilliseconds,omitempty"`
// DisableStageCallbackTimeout disables stage-level callback timeout for this
// hook.
DisableStageCallbackTimeout bool `json:"DisableStageCallbackTimeout,omitempty"`
// RunCombinedDevBuildHookCommands executes configured development build hooks
// in order (Core.DevBuildHook then framework dev build hook).
RunCombinedDevBuildHookCommands bool `json:"RunCombinedDevBuildHookCommands,omitempty"`
// Timing controls when this hook runs relative to Wave's rebuild process.
Timing OnChangeTiming `json:"Timing,omitempty"`
// Exclude contains glob patterns for files to exclude from triggering this
// hook.
Exclude []string `json:"Exclude,omitempty"`
// Callback is a Go function to run. It is framework-facing and not
// JSON-configurable.
Callback func(*HookContext) (*RefreshAction, error) `json:"-"`
}
OnChangeHook defines one command/callback action triggered by a watched-file match.
type OnChangeTiming ¶
type OnChangeTiming string
OnChangeTiming controls when one hook runs relative to rebuild work.
const ( // OnChangeStrategyPre runs before rebuild. OnChangeStrategyPre OnChangeTiming = "pre" // OnChangeStrategyPost runs after rebuild. OnChangeStrategyPost OnChangeTiming = "post" // OnChangeStrategyConcurrent runs concurrently with rebuild. OnChangeStrategyConcurrent OnChangeTiming = "concurrent" // OnChangeStrategyConcurrentNoWait runs fire-and-forget during rebuild. OnChangeStrategyConcurrentNoWait OnChangeTiming = "concurrent-no-wait" )
type RefreshAction ¶
type RefreshAction struct {
ReloadBrowser bool
WaitForApp bool
WaitForVite bool
TriggerRestart bool
RecompileGo bool
FrameworkRuntimeReloadRequest *FrameworkRuntimeReloadRequest
}
RefreshAction describes follow-up actions after one callback/hook completes.
func (RefreshAction) IsZero ¶
func (refreshAction RefreshAction) IsZero() bool
IsZero reports whether this RefreshAction requests no follow-up work.
func (RefreshAction) Merge ¶
func (refreshAction RefreshAction) Merge(other RefreshAction) RefreshAction
Merge combines two RefreshActions with OR semantics.
TriggerRestart is evaluated by callers, and framework runtime reload request uses first-non-nil precedence.
type SortedHooks ¶
type SortedHooks struct {
Pre []OnChangeHook
Concurrent []OnChangeHook
ConcurrentNoWait []OnChangeHook
Post []OnChangeHook
}
SortedHooks stores hooks partitioned by execution stage.
type WatchedFile ¶
type WatchedFile struct {
Pattern string `json:"Pattern"`
OnChangeHooks []OnChangeHook `json:"OnChangeHooks,omitempty"`
RecompileGoBinary bool `json:"RecompileGoBinary,omitempty"`
RestartApp bool `json:"RestartApp,omitempty"`
OnlyRunClientDefinedRevalidateFunc bool `json:"OnlyRunClientDefinedRevalidateFunc,omitempty"`
RunOnChangeOnly bool `json:"RunOnChangeOnly,omitempty"`
SkipRebuildingNotification bool `json:"SkipRebuildingNotification,omitempty"`
TreatAsNonGo bool `json:"TreatAsNonGo,omitempty"`
SortedHooks *SortedHooks `json:"-"`
}
WatchedFile defines one watched glob pattern and its hook behavior.
func (*WatchedFile) Sort ¶
func (watchedFile *WatchedFile) Sort()
Sort populates SortedHooks by grouping OnChangeHooks according to Timing.