Decouple command preparation from command execution

Created on 23 September 2020, almost 4 years ago
Updated 27 November 2023, 7 months ago

Problem/Motivation

Various workflows could benefit from an ability to prepare and execute commands in separate stages, rather than in one step such as when calling Drupal\http_client_manager\HttpClient::call()

For instance, for reasons of API design, I'm processing some calls using a queue. It would be valuable to leverage Guzzle Service command validation prior to queuing, which is currently impossible due to http_client_manager's design which produces the Guzzle Service command within the call() method.

Decoupling these steps may lead to a means to address Can Guzzle Promise be utilized? (3096785) →

Proposed resolution

Provide additional public methods in Drupal\http_client_manager\HttpClientInterface to:

  • allow retrieval of the prepared instance of GuzzleHttp\Command\CommandInterface
  • allow execution of the command directly

Remaining tasks

I'm going to produce a patch with these changes for your review

API changes

Additional public methods in Drupal\http_client_manager\HttpClientInterface (prepare/execute)

✨ Feature request
Status

Fixed

Version

3.0

Component

Code

Created by

🇺🇸United States Electric Doorknob

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇯🇵Japan tyler36 Osaka

    Any progress on this? Happy to review if needed.

  • Status changed to Needs review 7 months ago
  • 🇮🇹Italy aronne

    Hi guys,
    sorry for the delay.
    I'm gonna upload the patch you were asking for.

    Hope that's what you were looking for.
    I already tested it and it works fine.

    Regards,
    aronne

  • Status changed to RTBC 7 months ago
  • 🇯🇵Japan tyler36 Osaka

    Patch #5 applied cleanly to on Drupal 10.1.6 with the following HTTP_client_manager versions
    - 3.1
    - 9.3.10

    Tested multiple API calls in Drush with REPL

    \Drupal::service('http_client_manager.factory')->get('pokemon_api')->Berries()
    =  GuzzleHttp\Command\Result {#7614
        count: 64,
        results: [
          [
            "name" => "cheri",
            "url" => "https://pokeapi.co/api/v2/berry/1/",
          ],
    ...
    

    Admin pages of API are correct and unchanged, as expected.
    Thank you.

  • Status changed to Fixed 7 months ago
  • 🇮🇹Italy aronne

    Ok thank you @tyler36,
    patch committed on dev branch and is gonna get released soon.

    Regards,
    aronne

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.69.0 2024