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)

CommentFileSizeAuthor
#5 3172739-5.patch4.26 KBaronne

Comments

Electric Doorknob created an issue. See original summary.

aronne’s picture

Hi @Electric Doorknob,
it sounds nice to me.
Waiting for your patch :)

Thx,
aronne.

aronne’s picture

Status: Active » Postponed (maintainer needs more info)

Hi there @Electric Doorknob,
any news about the patch you said you were working on?

Kind regards,
aronne.

tyler36’s picture

Any progress on this? Happy to review if needed.

aronne’s picture

Version: 8.x-2.x-dev » 3.x-dev
Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new4.26 KB

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

tyler36’s picture

Status: Needs review » Reviewed & tested by the community

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.

  • aronne authored 836d3c1b on 3.x
    Issue #3172739 by aronne: Decouple command preparation from command...
aronne’s picture

Status: Reviewed & tested by the community » Fixed

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

Regards,
aronne

Status: Fixed » Closed (fixed)

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