summaryrefslogtreecommitdiff
path: root/hooks/queuer.ts
diff options
context:
space:
mode:
Diffstat (limited to 'hooks/queuer.ts')
-rw-r--r--hooks/queuer.ts21
1 files changed, 9 insertions, 12 deletions
diff --git a/hooks/queuer.ts b/hooks/queuer.ts
index 1461809..d2987ca 100644
--- a/hooks/queuer.ts
+++ b/hooks/queuer.ts
@@ -1,20 +1,22 @@
-import type { IEither, ITraceable, ITraceableLogger } from "@liz-ci/utils";
+import { getStdout, type IEither, type Traceable } from "@liz-ci/utils";
import type { Job } from "@liz-ci/model";
type QueuePosition = string;
export class QueueError extends Error {}
export interface IJobQueuer<TJob> {
- queue: <L extends ITraceableLogger<L>>(
- job: ITraceable<TJob, L>,
+ queue: (
+ job: TJob,
) => Promise<IEither<QueueError, QueuePosition>>;
}
-export class LaminarJobQueuer implements IJobQueuer<Job> {
+export class LaminarJobQueuer implements IJobQueuer<Traceable<Job>> {
constructor(
private readonly queuePositionPrefix: string,
) {}
- public async queue({ item: job, logger }: Traceable<Job>) {
+ public async queue(j: Traceable<Job>) {
+ const { item: job, logger: _logger } = j;
+ const logger = _logger.addTracer(() => `[LaminarJobQueuer.queue.${job}]`);
const laminarCommand = [
"laminarc",
"queue",
@@ -27,12 +29,7 @@ export class LaminarJobQueuer implements IJobQueuer<Job> {
laminarCommand,
);
- return (await getStdout(laminarCommand)).mapBoth(
- (e) => {
- const err = `we bwoke oh noesss D:`;
- logger.error(err, e);
- return Either.left<QueueError, QueuePosition>(e);
- },
+ return (await getStdout(j.map(() => laminarCommand))).mapRight(
(stdout) => {
logger.log(stdout);
@@ -40,7 +37,7 @@ export class LaminarJobQueuer implements IJobQueuer<Job> {
const jobUrl = `${this.queuePositionPrefix}/jobs/${jobName}/${jobId}`;
logger.log(`all queued up and weady to go~ (˘ω˘) => ${jobUrl}\n`);
- return Either.right<QueueError, QueuePosition>(jobUrl);
+ return jobUrl;
},
);
}