Use of Async Connections

26 views
Skip to first unread message

Caio Carvalho

unread,
Sep 22, 2022, 10:38:58 AM9/22/22
to Fusio
Hi,
I currently have a PHP sandbox action that starts an ElasticSearch connection through the Connector's getConnection method and later consumes said connection to use the index function.
However, I want my action to continue its execution even if I can't have the ElasticSearch logs, so I want to run that getConnection method asynchronously or have that connection established asynchronously in some other time-efficient way, is it possible to do that?

Thank you in advance,
Caio R. Carvalho

Christoph Kappestein

unread,
Sep 22, 2022, 3:30:12 PM9/22/22
to Fusio
Hi Caio,

so maybe you can take a look at the ElasticSearch client, there is an option "setAsync" which could result in the behaviour which you have described.
The adapter uses the client from s. https://github.com/elastic/elasticsearch-php

best regards
Christoph

Caio Carvalho

unread,
Sep 23, 2022, 9:46:28 AM9/23/22
to Fusio
Hi, thank you for the response
As a follow up question, would that be possible to do just on a PHP sandbox action? Without writing a different adapter class.
Also, what happens by default if the connection that the connector class is trying to establish times out? 

Thank you, once again
Caio

Christoph Kappestein

unread,
Sep 25, 2022, 4:01:31 AM9/25/22
to Fusio
Hi Caio,

you can do this also in the PHPSandbox action, you would only need to set the async setter at the connection and then make your calls.
If the connection times out you will most likely get an exception and Fusio will return a 500 error.

In general we have also an "async" option at every action, if this is activated it means, that the user receives directly a 202 response and the actions gets executed in the background.

best regards
Christoph
Reply all
Reply to author
Forward
0 new messages