FR: Revising the Threading Model and Async APIs
See original GitHub issueThere are several issues in the Admin SDK with respect to how it creates and uses threads:
- Most public APIs are asynchronous, and returns
Task
instances. 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.
ThreadFactory
is initialized statically, and not configurable.Tasks
API 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
Tasks
API. We can consider using theApiFutures
from 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(){...});
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:32 (15 by maintainers)
Top Results From Across the Web
Asynchronous APIs in Qt 6 | Multithreaded Programming
Read about the changes to asynchronous APIs in Qt 6 and discover how these updates can improve parallel processing and multithreaded ...
Read more >Asynchronous API Calls and Idling - The Building Coder
Application registers itself and its commands. · On one command, it kicks off a working thread (or a modeless dialog) and leaves it...
Read more >Developing and Testing an Asynchronous API with FastAPI ...
This tutorial looks at how to develop and test an asynchronous API with FastAPI, Postgres, pytest, and Docker using Test-driven Development ...
Read more >Task asynchronous programming model - Microsoft Learn
Asynchrony proves especially valuable for applications that access the UI thread because all UI-related activity usually shares one thread.
Read more >Chapter 4: Threads & Concurrency
Multi-threading Models ... Describe how the Linux operating system represents threads ... A POSIX standard (IEEE 1003.1c) API for thread creation and.
Read more >Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Well… in the end I came up with this:
@samodadela , ApiFuture extends java.util.concurrent.Future.
This article should be enough to learn how to use it.
If you still need extra help, try another articles from here.