Automatically detect lingering server calls
- Lingua principale
- Java
- Stelle
- 12.1k
- Fork
- 4k
- Merge medio
- 2g 17h
- PR unite (30g)
- 37
Descrizione
### Problem
When subscribing to a server streaming call, it's tedious to set up machinery for canceling the stream when no longer needed.
### Describe the solution you'd like
When a user calls `stub.foo(observer)`, gRPC attaches a [Cleaner](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/ref/Cleaner.html) to it which cancels the corresponding `ClientCallStreamObserver` when the inbound stream observer object becomes unreachable.
Since there is some runtime cost of registering Cleaners for each and every streaming call (and there can be thousands of them at any given time, and an unlimited number in the app lifetime), this may best be an opt-in feature. Not sure about exact API, and whether it should be opt-in per-app, per-method, or per-call.
Adding a cleaner also holds a ref to `ClientCallStreamObserver` as long as the inbound stream observer object is alive in the heap, even if the call itself has completed. We need to make sure this doesn't leak significant resources.
### Describe alternatives you've considered
Per-app opt-in is a form of "debug mode" where lingering connections are logged, and then in prod the machinery may be set-up manually in strategic places.
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia dal punto di ingresso dello streaming `stub.foo(observer)` e dal ciclo di vita di `ClientCallStreamObserver` descritto nell'issue; esamina il comportamento di `Cleaner` di Java e le relative implicazioni per la ritenzione delle risorse. Il lavoro non è ancora circoscritto a un file o a un test: per considerarlo completato, è necessario aver deciso un'API opt-in e aver verificato il comportamento di cancellazione, logging e pulizia delle chiamate completate.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- java
- Ambito
- backend-api-design
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100