mirror of
https://github.com/immich-app/immich.git
synced 2025-03-01 15:11:21 +01:00
feat(server): resume queues (#2104)
* feat(server): resume queues * chore: regenerate open-api
This commit is contained in:
parent
8563bd463c
commit
9adbbd42be
9 changed files with 21 additions and 0 deletions
3
mobile/openapi/lib/model/job_command.dart
generated
3
mobile/openapi/lib/model/job_command.dart
generated
|
@ -25,12 +25,14 @@ class JobCommand {
|
||||||
|
|
||||||
static const start = JobCommand._(r'start');
|
static const start = JobCommand._(r'start');
|
||||||
static const pause = JobCommand._(r'pause');
|
static const pause = JobCommand._(r'pause');
|
||||||
|
static const resume = JobCommand._(r'resume');
|
||||||
static const empty = JobCommand._(r'empty');
|
static const empty = JobCommand._(r'empty');
|
||||||
|
|
||||||
/// List of all possible values in this [enum][JobCommand].
|
/// List of all possible values in this [enum][JobCommand].
|
||||||
static const values = <JobCommand>[
|
static const values = <JobCommand>[
|
||||||
start,
|
start,
|
||||||
pause,
|
pause,
|
||||||
|
resume,
|
||||||
empty,
|
empty,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -72,6 +74,7 @@ class JobCommandTypeTransformer {
|
||||||
switch (data.toString()) {
|
switch (data.toString()) {
|
||||||
case r'start': return JobCommand.start;
|
case r'start': return JobCommand.start;
|
||||||
case r'pause': return JobCommand.pause;
|
case r'pause': return JobCommand.pause;
|
||||||
|
case r'resume': return JobCommand.resume;
|
||||||
case r'empty': return JobCommand.empty;
|
case r'empty': return JobCommand.empty;
|
||||||
default:
|
default:
|
||||||
if (!allowNull) {
|
if (!allowNull) {
|
||||||
|
|
|
@ -4141,6 +4141,7 @@
|
||||||
"enum": [
|
"enum": [
|
||||||
"start",
|
"start",
|
||||||
"pause",
|
"pause",
|
||||||
|
"resume",
|
||||||
"empty"
|
"empty"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -12,6 +12,7 @@ export enum QueueName {
|
||||||
export enum JobCommand {
|
export enum JobCommand {
|
||||||
START = 'start',
|
START = 'start',
|
||||||
PAUSE = 'pause',
|
PAUSE = 'pause',
|
||||||
|
RESUME = 'resume',
|
||||||
EMPTY = 'empty',
|
EMPTY = 'empty',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,6 +69,7 @@ export const IJobRepository = 'IJobRepository';
|
||||||
export interface IJobRepository {
|
export interface IJobRepository {
|
||||||
queue(item: JobItem): Promise<void>;
|
queue(item: JobItem): Promise<void>;
|
||||||
pause(name: QueueName): Promise<void>;
|
pause(name: QueueName): Promise<void>;
|
||||||
|
resume(name: QueueName): Promise<void>;
|
||||||
empty(name: QueueName): Promise<void>;
|
empty(name: QueueName): Promise<void>;
|
||||||
isActive(name: QueueName): Promise<boolean>;
|
isActive(name: QueueName): Promise<boolean>;
|
||||||
getJobCounts(name: QueueName): Promise<JobCounts>;
|
getJobCounts(name: QueueName): Promise<JobCounts>;
|
||||||
|
|
|
@ -93,6 +93,12 @@ describe(JobService.name, () => {
|
||||||
expect(jobMock.pause).toHaveBeenCalledWith(QueueName.METADATA_EXTRACTION);
|
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 () => {
|
it('should handle an empty command', async () => {
|
||||||
await sut.handleCommand(QueueName.METADATA_EXTRACTION, { command: JobCommand.EMPTY, force: false });
|
await sut.handleCommand(QueueName.METADATA_EXTRACTION, { command: JobCommand.EMPTY, force: false });
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,9 @@ export class JobService {
|
||||||
case JobCommand.PAUSE:
|
case JobCommand.PAUSE:
|
||||||
return this.jobRepository.pause(queueName);
|
return this.jobRepository.pause(queueName);
|
||||||
|
|
||||||
|
case JobCommand.RESUME:
|
||||||
|
return this.jobRepository.resume(queueName);
|
||||||
|
|
||||||
case JobCommand.EMPTY:
|
case JobCommand.EMPTY:
|
||||||
return this.jobRepository.empty(queueName);
|
return this.jobRepository.empty(queueName);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ export const newJobRepositoryMock = (): jest.Mocked<IJobRepository> => {
|
||||||
return {
|
return {
|
||||||
empty: jest.fn(),
|
empty: jest.fn(),
|
||||||
pause: jest.fn(),
|
pause: jest.fn(),
|
||||||
|
resume: jest.fn(),
|
||||||
queue: jest.fn().mockImplementation(() => Promise.resolve()),
|
queue: jest.fn().mockImplementation(() => Promise.resolve()),
|
||||||
isActive: jest.fn(),
|
isActive: jest.fn(),
|
||||||
getJobCounts: jest.fn(),
|
getJobCounts: jest.fn(),
|
||||||
|
|
|
@ -45,6 +45,10 @@ export class JobRepository implements IJobRepository {
|
||||||
return this.queueMap[name].pause();
|
return this.queueMap[name].pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resume(name: QueueName) {
|
||||||
|
return this.queueMap[name].resume();
|
||||||
|
}
|
||||||
|
|
||||||
empty(name: QueueName) {
|
empty(name: QueueName) {
|
||||||
return this.queueMap[name].empty();
|
return this.queueMap[name].empty();
|
||||||
}
|
}
|
||||||
|
|
1
web/src/api/open-api/api.ts
generated
1
web/src/api/open-api/api.ts
generated
|
@ -1222,6 +1222,7 @@ export interface GetAssetCountByTimeBucketDto {
|
||||||
export const JobCommand = {
|
export const JobCommand = {
|
||||||
Start: 'start',
|
Start: 'start',
|
||||||
Pause: 'pause',
|
Pause: 'pause',
|
||||||
|
Resume: 'resume',
|
||||||
Empty: 'empty'
|
Empty: 'empty'
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue