Documentation
¶
Overview ¶
Package job provides the Job[T] type: a discoverer-backed, parallelised, optionally-retried unit of work implementing interfaces.AnyJob.
Index ¶
- func Adapt(r interfaces.Runnable) interfaces.AnyJob
- func FilterByLang(jobs []TaggedJob, goFlag, pyFlag, tsFlag bool) []interfaces.AnyJob
- func Single(name, group string, tool interfaces.ToolSpec, ...) interfaces.AnyJob
- type Builder
- func (b *Builder[T]) Build() interfaces.AnyJob
- func (b *Builder[T]) WithDiscoverer(d interfaces.Discoverer[T]) *Builder[T]
- func (b *Builder[T]) WithMapper(fn func(root string, item T) engine.WorkUnit) *Builder[T]
- func (b *Builder[T]) WithOptions(opts ...Option) *Builder[T]
- func (b *Builder[T]) WithTool(t interfaces.ToolSpec) *Builder[T]
- type Conditional
- type Job
- type JobConfig
- type LangTag
- type Option
- type TaggedJob
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Adapt ¶
func Adapt(r interfaces.Runnable) interfaces.AnyJob
Adapt lifts a runner-less Runnable into an AnyJob for gate composition, so callers compose typed Runnables instead of threading a nil CommandRunner.
func FilterByLang ¶
func FilterByLang(jobs []TaggedJob, goFlag, pyFlag, tsFlag bool) []interfaces.AnyJob
FilterByLang returns the jobs whose LangTag matches the enabled flags. LangInfra jobs are always included - they validate shared infrastructure (Docker, k8s, proto) that must pass regardless of which language changed.
func Single ¶
func Single( name, group string, tool interfaces.ToolSpec, argsFn func(root string) []string, dirFn func(root string) string, opts ...Option, ) interfaces.AnyJob
Single creates a Job[string] that runs exactly one command. tool.Cmd overrides the executable prefix when set (e.g. ["uv", "run", "ruff"]).
Types ¶
type Builder ¶
type Builder[T any] struct { // contains filtered or unexported fields }
Builder[T] assembles a Job[T] via a fluent API. Field order minimises GC pointer-scan range: interfaces, func, strings, slices.
func (*Builder[T]) Build ¶
func (b *Builder[T]) Build() interfaces.AnyJob
Build constructs and returns the Job[T].
func (*Builder[T]) WithDiscoverer ¶
func (b *Builder[T]) WithDiscoverer(d interfaces.Discoverer[T]) *Builder[T]
WithDiscoverer sets the Discoverer that yields work items.
func (*Builder[T]) WithMapper ¶
WithMapper sets the function that converts (root, item) into a WorkUnit.
func (*Builder[T]) WithOptions ¶
WithOptions appends execution options.
type Conditional ¶
type Conditional struct {
// contains filtered or unexported fields
}
Conditional wraps an AnyJob and runs it only when condition returns true. When the condition is false the job returns a single Skip result.
func When ¶
func When( job interfaces.AnyJob, condition func(ctx context.Context, root string) bool, ) *Conditional
When wraps job with a condition; the job runs only when condition returns true.
func (*Conditional) Execute ¶
func (c *Conditional) Execute( ctx context.Context, runner interfaces.CommandRunner, root string, ) (types.StepResults, error)
Execute implements interfaces.AnyJob.
func (*Conditional) Meta ¶
func (c *Conditional) Meta() types.JobMeta
Meta implements interfaces.AnyJob.
type Job ¶
type Job[T any] struct { // contains filtered or unexported fields }
Job[T] discovers work items of type T, maps each to a WorkUnit, and fans them out in parallel. It implements interfaces.AnyJob. Field order minimises GC pointer-scan range: interfaces, func, strings, value types.
func (*Job[T]) Execute ¶
func (j *Job[T]) Execute( ctx context.Context, runner interfaces.CommandRunner, root string, ) (types.StepResults, error)
Execute implements interfaces.AnyJob. It checks the required tool (skip if missing), discovers items (skip if none), maps each to a WorkUnit, fans them out via FanOut, then optionally downgrades failures to warnings when WarnOnly is set.
type JobConfig ¶
type JobConfig struct {
// Concurrency is the max number of parallel workers; 0 means runtime.NumCPU.
Concurrency int
// Retry is the max number of retry attempts after a step failure (0 = no retry).
Retry int
// RetryDelay is the pause between retry attempts.
RetryDelay time.Duration
// WarnOnly downgrades Fail results to Warn so the job never blocks a gate.
WarnOnly bool
}
JobConfig holds execution parameters applied to every step in the job.
type LangTag ¶
type LangTag string
LangTag identifies which language stack a job belongs to.
const ( // LangGo tags jobs that belong to the Go stack. LangGo LangTag = "go" // LangPython tags jobs that belong to the Python stack. LangPython LangTag = "python" // LangTS tags jobs that belong to the TypeScript stack. LangTS LangTag = "ts" // LangInfra covers Docker, k8s, proto, and shellcheck jobs that must run // regardless of which language-specific flags are set. LangInfra LangTag = "infra" )
type Option ¶
type Option func(*JobConfig)
Option configures a JobConfig.
func WithConcurrency ¶
WithConcurrency sets the maximum number of parallel workers.
func WithRetryDelay ¶
WithRetryDelay sets the pause between retry attempts.
func WithWarnOnly ¶
func WithWarnOnly() Option
WithWarnOnly marks the job non-blocking: Fail results are downgraded to Warn.
type TaggedJob ¶
type TaggedJob struct {
// AnyJob is the embedded job being tagged; its methods are promoted.
interfaces.AnyJob
// Lang is the language stack this job belongs to, used by FilterByLang.
Lang LangTag
}
TaggedJob pairs an AnyJob with its language tag.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package decorators provides logging, metrics, tracing, and recovery wrappers for interfaces.AnyJob.
|
Package decorators provides logging, metrics, tracing, and recovery wrappers for interfaces.AnyJob. |