@lage-run/scheduler
v1.4.3
Published
Scheduler for Lage
Downloads
2,201
Readme
@lage-run/scheduler
This package provides:
Scheduler
interface- `
- a default cache provider that uses
backfill
Usage
import { Logger } from "@lage-run/logger";
import { RemoteFallbackCacheProvider, TargetHasher } from "@lage-run/cache";
import { SimpleScheduler } from "@lage-run/scheduler";
import { TargetGraph } from "@lage-run/target-graph";
const root = "/root-of-repo";
const logger = new Logger();
const cacheProvider = new RemoteFallbackCacheProvider({ root, logger, ... });
const hasher = new TargetHasher({ root, ... });
const runner = new NpmScriptRunner({
logger,
...
})
const runnerPicker = new TargetRunnerPicker({
runners: {
npmScript: runner
}
})
const scheduler = new SimpleScheduler({
logger,
concurrency,
cacheProvider,
hasher,
continueOnError: true,
shouldCache: true,
shouldResetCache: false,
runner
});
const targetGraphBuilder = new TargetGraphBuilder();
const packageInfos = getPackageInfos(rootDir);
const builder = new TargetGraphBuilder(rootDir, packageInfos);
// these would normally come from the CLI
const tasks = ["build", "test"];
const packages = ["package-a", "package-b"];
const targetGraph = builder.buildTargetGraph(tasks, packages);
await scheduler.run(root, targetGraph);
// If an error happened...
scheduler.abort();