3

I'm building a library that's a wrapper for a REST API.
The generated request classes already contained synchronous get, post, patch, put, delete methods.
These methods are generated depending on whether the corresponding HTTP method is supported by the API endpoint that maps to the current request class.

We recently decided to add an asynchronous API surface to the library, returning CompletableFutures of the response type instead of the response type directly.

I was wondering whether there was a naming convention for such methods like in dotnet with the "Async" suffix?

this post would suggest to use subscribe or observe, but observePost or subscribeToPost doesn't sound very intuitive.

baywet
  • 4,377
  • 4
  • 20
  • 49
  • 1
    Java's [HttpClient](https://docs.oracle.com/en/java/javase/15/docs/api/java.net.http/java/net/http/HttpClient.html) uses `send` and `sendAsync`, if that influences your choice at all. Personally I would use an "Async" suffix, especially since this method returns `CompletableFuture`. – Slaw Jan 15 '21 at 14:34
  • under the covers we're using OkHttpClient which uses execute (sync) and enqueue (async). But yes, we could align on that convention with the benefit of the naming being identical to our dotnet library – baywet Jan 15 '21 at 14:57

0 Answers0