mirror of
				https://github.com/KevinMidboe/immich.git
				synced 2025-10-29 17:40:28 +00:00 
			
		
		
		
	feat(server): resume queues (#2104)
* feat(server): resume queues * chore: regenerate open-api
This commit is contained in:
		@@ -4141,6 +4141,7 @@
 | 
			
		||||
        "enum": [
 | 
			
		||||
          "start",
 | 
			
		||||
          "pause",
 | 
			
		||||
          "resume",
 | 
			
		||||
          "empty"
 | 
			
		||||
        ]
 | 
			
		||||
      },
 | 
			
		||||
 
 | 
			
		||||
@@ -12,6 +12,7 @@ export enum QueueName {
 | 
			
		||||
export enum JobCommand {
 | 
			
		||||
  START = 'start',
 | 
			
		||||
  PAUSE = 'pause',
 | 
			
		||||
  RESUME = 'resume',
 | 
			
		||||
  EMPTY = 'empty',
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -69,6 +69,7 @@ export const IJobRepository = 'IJobRepository';
 | 
			
		||||
export interface IJobRepository {
 | 
			
		||||
  queue(item: JobItem): Promise<void>;
 | 
			
		||||
  pause(name: QueueName): Promise<void>;
 | 
			
		||||
  resume(name: QueueName): Promise<void>;
 | 
			
		||||
  empty(name: QueueName): Promise<void>;
 | 
			
		||||
  isActive(name: QueueName): Promise<boolean>;
 | 
			
		||||
  getJobCounts(name: QueueName): Promise<JobCounts>;
 | 
			
		||||
 
 | 
			
		||||
@@ -93,6 +93,12 @@ describe(JobService.name, () => {
 | 
			
		||||
      expect(jobMock.pause).toHaveBeenCalledWith(QueueName.METADATA_EXTRACTION);
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    it('should handle a resume command', async () => {
 | 
			
		||||
      await sut.handleCommand(QueueName.METADATA_EXTRACTION, { command: JobCommand.RESUME, force: false });
 | 
			
		||||
 | 
			
		||||
      expect(jobMock.resume).toHaveBeenCalledWith(QueueName.METADATA_EXTRACTION);
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    it('should handle an empty command', async () => {
 | 
			
		||||
      await sut.handleCommand(QueueName.METADATA_EXTRACTION, { command: JobCommand.EMPTY, force: false });
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -21,6 +21,9 @@ export class JobService {
 | 
			
		||||
      case JobCommand.PAUSE:
 | 
			
		||||
        return this.jobRepository.pause(queueName);
 | 
			
		||||
 | 
			
		||||
      case JobCommand.RESUME:
 | 
			
		||||
        return this.jobRepository.resume(queueName);
 | 
			
		||||
 | 
			
		||||
      case JobCommand.EMPTY:
 | 
			
		||||
        return this.jobRepository.empty(queueName);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -4,6 +4,7 @@ export const newJobRepositoryMock = (): jest.Mocked<IJobRepository> => {
 | 
			
		||||
  return {
 | 
			
		||||
    empty: jest.fn(),
 | 
			
		||||
    pause: jest.fn(),
 | 
			
		||||
    resume: jest.fn(),
 | 
			
		||||
    queue: jest.fn().mockImplementation(() => Promise.resolve()),
 | 
			
		||||
    isActive: jest.fn(),
 | 
			
		||||
    getJobCounts: jest.fn(),
 | 
			
		||||
 
 | 
			
		||||
@@ -45,6 +45,10 @@ export class JobRepository implements IJobRepository {
 | 
			
		||||
    return this.queueMap[name].pause();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  resume(name: QueueName) {
 | 
			
		||||
    return this.queueMap[name].resume();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  empty(name: QueueName) {
 | 
			
		||||
    return this.queueMap[name].empty();
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user