Documentation
¶
Overview ¶
Package hooks schedules finite, detached checkout synchronization workers.
Index ¶
- Variables
- func Directory(stateDir string) string
- func LaunchDetached(executable, directory, job string) error
- type Activity
- type Engine
- func (engine Engine) Log(err error)
- func (engine Engine) Record(activity Activity)
- func (engine Engine) RecordJob(job string, event Event, activity Activity)
- func (engine Engine) Retry(event Event) error
- func (engine Engine) Run(ctx context.Context, job string) error
- func (engine Engine) Schedule(event Event) error
- func (engine Engine) Start(ctx context.Context, destination string, start func(context.Context) error) error
- func (engine Engine) Statuses() ([]Activity, error)
- type Event
- type Target
Constants ¶
This section is empty.
Variables ¶
var ErrCooldown = errors.New("service startup cooling down")
var ErrUnchanged = errors.New("checkout unchanged")
Functions ¶
func Directory ¶ added in v0.2.1
Directory is the versioned hook state under diffx's private state root.
func LaunchDetached ¶
LaunchDetached closes every inherited stream so hook hosts can finish as soon as Schedule returns. The worker reports errors to its bounded private log.
Types ¶
type Activity ¶
type Activity struct {
Time time.Time `json:"time"`
Stage string `json:"stage,omitempty"`
Status string `json:"status,omitempty"`
Job string `json:"job,omitempty"`
InputPath string `json:"inputPath,omitempty"`
Path string `json:"path,omitempty"`
Agent string `json:"agent,omitempty"`
RunID string `json:"runId,omitempty"`
Branch string `json:"branch,omitempty"`
BranchID string `json:"branchId,omitempty"`
RepositoryKey string `json:"repositoryKey,omitempty"`
CheckoutKey string `json:"checkoutKey,omitempty"`
Base string `json:"base,omitempty"`
Head string `json:"head,omitempty"`
Destination string `json:"destination,omitempty"`
SubmissionID string `json:"submissionId,omitempty"`
DiagnosticID string `json:"diagnosticId,omitempty"`
ContextID string `json:"contextId,omitempty"`
Attempt int `json:"attempt,omitempty"`
FileCount int `json:"fileCount,omitempty"`
Reason string `json:"reason,omitempty"`
Error string `json:"error,omitempty"`
}
Activity contains collection and delivery metadata, never captured contents.
type Engine ¶
type Engine struct {
Directory string
Expand func(context.Context, Event) ([]Event, error)
ValidateLocation func(Event, Event) error
Normalize func(context.Context, Event) (Event, error)
Resolve func(context.Context, Event) (Target, error)
Collect func(context.Context, Event, string) (ingestion.Request, string, error)
Deliver func(context.Context, Target, ingestion.Request) (string, error)
// Confirm checks cached context freshness only after collection reports
// unchanged. Production callers provide it to detect other producers.
Confirm func(context.Context, Target, string) (bool, error)
// SuppressInitialEmpty proves a clean capture has no retained stream history.
// Errors keep the conservative publication path.
SuppressInitialEmpty func(context.Context, Target, ingestion.Request) (bool, error)
Launch func(string) error
Timeout time.Duration
}
func (Engine) Record ¶
Record persists a bounded JSONL activity entry. Logging failures never affect collection. The short blocking lock preserves concurrent lifecycle events.
func (Engine) RecordJob ¶
RecordJob also atomically replaces the job's readable latest status. Callers supply stage/status and can override event metadata (e.g. its original path).
func (Engine) Retry ¶
Retry is bounded, event-driven, and restricted to the invoking environment's route and config. Credentials are inherited, never read from persisted jobs.
func (Engine) Run ¶
Run owns one checkout until all observed requests are processed. Queue writes and worker exit share a short lock, preventing a trigger losing its worker.
func (Engine) Schedule ¶
Schedule writes only a small request. Collection and transport never run here.
func (Engine) Start ¶
func (engine Engine) Start(ctx context.Context, destination string, start func(context.Context) error) error
Start serializes startup attempts across checkouts and suppresses repeated failures. Call after a health probe fails; callback should probe again before starting, since another worker may have started the service while waiting.
type Event ¶
type Event struct {
Path string `json:"path"`
InputPath string `json:"inputPath,omitempty"`
Identity string `json:"identity,omitempty"`
Branch string `json:"branch,omitempty"`
Base string `json:"base,omitempty"`
Resolved bool `json:"resolved,omitempty"`
Retry bool `json:"-"`
Agent string `json:"agent"`
RunID string `json:"runId,omitempty"`
SessionName string `json:"sessionName,omitempty"`
ConfigFile string `json:"configFile,omitempty"`
Routing string `json:"routing,omitempty"`
RecoveryRouting string `json:"recoveryRouting,omitempty"`
}
type Target ¶
type Target = submission.Target
Identity identifies the server's persistent database (or memory instance). An unknown identity disables suppression and prevents uncertain replay.