Skip to content

Package Manager APIs: do not enqueue jobs directly.

Follow up of !59801 (comment 558606010)

Problem

In package managers APIs, we can have this need on the upload endpoint to enqueue a job for the uploaded package file.

Right now, we directly enqueue the job from the API class but this is not recommended (we disabled a cop rule).

The package file is created with the CreatePackageFileService which is generic, which means that it is used for other package types that don't need to enqueue a job.

Proposal

We can't change CreatePackageFileService as it is used by almost all package types. Instead, compose services to create the package file and enqueue the right job:

(Taking NuGet as an example)

  • Create a Nuget::CreatePackageFileService.
  • Its #execute will
    1. call the CreatePackageFileService
    2. if the package file is created, enqueue the correct worker job

The API class can then simply use that new service the create the package file and enqueue a job at the same time.

MRs

Repository MR
Debian Repository Debian package API: do not enqueue jobs directly (!100215 - merged)
RubyGems Repository RubyGems package API: Do not enqueue jobs directly (!170696 - merged)
NuGet Repository NuGet package API: Do not enqueue jobs directly (!170649 - merged)
Edited by Björn Holtvogt