-   Notifications  You must be signed in to change notification settings 
- Fork 298
Closed
Description
There are several issues in the Admin SDK with respect to how it creates and uses threads:
- Most public APIs are asynchronous, and returns Taskinstances. This tends to make implementing simple use cases unnecessarily complex (e.g. creating a custom token and sending back as a servlet response).
- Main thread pool is initialized statically, and not configurable.
- ThreadFactoryis initialized statically, and not configurable.
- TasksAPI is visible to user code. A user can kick off arbitrary background tasks using this API, which will get executed on the main thread pool of the SDK, un-regulated.
In order to address these limitations, we can consider the following changes:
- Expose synchronous/blocking variants of public APIs where it makes sense (most notably at FirebaseAuth).
BlockingFirebaseAuth auth = FirebaseAuth.getBlockingInstance(); String customToken = auth.createCustomToken("user1"); - Make the thread pool and thread factory configurable via app options.
- Hide or decommission the TasksAPI. We can consider using theApiFuturesfrom Google Cloud Commons (this is similar to Guava'sListenableFutures) as a replacement.
FirebaseAuth auth = FirebaseAuth.getInstance(); ApiFuture<String> customTokenFuture = auth.createCustomToken("user1"); // The following should not be supported // Tasks.call(new Callable(){...}); bajabob