2023-11-10 14:48:31 -08:00
|
|
|
import { Authorized, Post, RestController } from '@/decorators';
|
2023-09-07 05:44:19 -07:00
|
|
|
import { OrchestrationRequest } from '@/requests';
|
|
|
|
import { Service } from 'typedi';
|
2023-10-30 08:22:32 -07:00
|
|
|
import { SingleMainInstancePublisher } from '@/services/orchestration/main/SingleMainInstance.publisher';
|
2023-11-10 14:48:31 -08:00
|
|
|
import { License } from '../License';
|
2023-09-07 05:44:19 -07:00
|
|
|
|
2023-11-15 07:54:33 -08:00
|
|
|
@Authorized('any')
|
2023-09-07 05:44:19 -07:00
|
|
|
@RestController('/orchestration')
|
|
|
|
@Service()
|
|
|
|
export class OrchestrationController {
|
2023-11-10 14:48:31 -08:00
|
|
|
constructor(
|
|
|
|
private readonly orchestrationService: SingleMainInstancePublisher,
|
|
|
|
private readonly licenseService: License,
|
|
|
|
) {}
|
2023-09-07 05:44:19 -07:00
|
|
|
|
|
|
|
/**
|
2023-11-10 14:48:31 -08:00
|
|
|
* These endpoints do not return anything, they just trigger the messsage to
|
2023-09-07 05:44:19 -07:00
|
|
|
* the workers to respond on Redis with their status.
|
|
|
|
*/
|
2023-11-10 14:48:31 -08:00
|
|
|
@Post('/worker/status/:id')
|
2023-09-07 05:44:19 -07:00
|
|
|
async getWorkersStatus(req: OrchestrationRequest.Get) {
|
2023-11-10 14:48:31 -08:00
|
|
|
if (!this.licenseService.isWorkerViewLicensed()) return;
|
2023-09-07 05:44:19 -07:00
|
|
|
const id = req.params.id;
|
|
|
|
return this.orchestrationService.getWorkerStatus(id);
|
|
|
|
}
|
|
|
|
|
2023-11-10 14:48:31 -08:00
|
|
|
@Post('/worker/status')
|
2023-09-07 05:44:19 -07:00
|
|
|
async getWorkersStatusAll() {
|
2023-11-10 14:48:31 -08:00
|
|
|
if (!this.licenseService.isWorkerViewLicensed()) return;
|
2023-09-07 05:44:19 -07:00
|
|
|
return this.orchestrationService.getWorkerStatus();
|
|
|
|
}
|
|
|
|
|
2023-11-10 14:48:31 -08:00
|
|
|
@Post('/worker/ids')
|
2023-09-07 05:44:19 -07:00
|
|
|
async getWorkerIdsAll() {
|
2023-11-10 14:48:31 -08:00
|
|
|
if (!this.licenseService.isWorkerViewLicensed()) return;
|
2023-09-07 05:44:19 -07:00
|
|
|
return this.orchestrationService.getWorkerIds();
|
|
|
|
}
|
|
|
|
}
|