feat(orchestrator): add SSE events, queue controls, and mosaic rails sync
This commit is contained in:
39
apps/orchestrator/src/api/queue/queue.controller.ts
Normal file
39
apps/orchestrator/src/api/queue/queue.controller.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { Controller, Get, HttpCode, Post, UseGuards } from "@nestjs/common";
|
||||
import { Throttle } from "@nestjs/throttler";
|
||||
import { QueueService } from "../../queue/queue.service";
|
||||
import { OrchestratorApiKeyGuard } from "../../common/guards/api-key.guard";
|
||||
import { OrchestratorThrottlerGuard } from "../../common/guards/throttler.guard";
|
||||
|
||||
@Controller("queue")
|
||||
@UseGuards(OrchestratorApiKeyGuard, OrchestratorThrottlerGuard)
|
||||
export class QueueController {
|
||||
constructor(private readonly queueService: QueueService) {}
|
||||
|
||||
@Get("stats")
|
||||
@Throttle({ status: { limit: 200, ttl: 60000 } })
|
||||
async getStats(): Promise<{
|
||||
pending: number;
|
||||
active: number;
|
||||
completed: number;
|
||||
failed: number;
|
||||
delayed: number;
|
||||
}> {
|
||||
return this.queueService.getStats();
|
||||
}
|
||||
|
||||
@Post("pause")
|
||||
@Throttle({ strict: { limit: 10, ttl: 60000 } })
|
||||
@HttpCode(200)
|
||||
async pause(): Promise<{ message: string }> {
|
||||
await this.queueService.pause();
|
||||
return { message: "Queue processing paused" };
|
||||
}
|
||||
|
||||
@Post("resume")
|
||||
@Throttle({ strict: { limit: 10, ttl: 60000 } })
|
||||
@HttpCode(200)
|
||||
async resume(): Promise<{ message: string }> {
|
||||
await this.queueService.resume();
|
||||
return { message: "Queue processing resumed" };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user