How to: Grpc fire and forget async api call in Kotlin

I have a gRPC endpoint: A. I would like to async call another Grpc endpoint: B and return response back without having to wait for the response from B.

How would I create a “fire and forget” async coroutine to make the request?

I know that GlobalScope.launch is highly discouraged due to possible memory leaks.
Why not use GlobalScope.launch?

API call for Endpoint B takes probably less than 2 seconds.

Is GlobalScope.launch the okay way to achieve this or is there a better way?

Read more here: Source link