How to best deal with Futures/Promises inside Activities

Hi team,

Our temporal application uses Activities to make calls to a third party API. The way we have currently implemented this, is by using a client in between the API and out temporal service which returns us Futures for any of the calls we make to the API. In our temporal activities, we await the result of these futures and return the results from the activities so they can be used in the workflows.

We’re wondering if this is the correct way to deal with these Futures. We were able to find documentation that told us not to manipulate threads in the Workflows, but nothing specifically about doing this in Activities, hence the question.

Any help and suggestions are greatly appreciated!
Thanks

There are no restrictions on what activity code can do. So using Futures or any other threading/synchronization is absolutely OK.

You can also consider implementing activity fully asynchronously to not block a thread while it is waiting.

Brilliant, thanks a lot for the clarification!