Move $collStats
logic to its stage implementation #2423
Open
Description
What should be done?
$collStats
created the whole parallel universe for itself not only in the Stage interface but also in the aggregate
command implementation. Could we fold that special case in the general design?
At the moment, the complexity is around $collStats
does not always need to query database, and if does it uses its specific query to fetch data. There are other stages that does not query database such as $documents and $listSessions.
The proposed design separates Stages
to ProducerStage
and ProcessorStage
(see #3102), each ProducerStage
may decide how to produce document iterator.
Where?
https://github.com/FerretDB/FerretDB/blob/main/internal/handlers/pg/msg_aggregate.go
Also find issue link in the code base
Definition of Done
- remove
Type()
interface - remove
$collStats
specific code from msg_aggregate.go, it should be in collStats.go. - calling database is optional by design (see proposed design Reorganise aggregation by deciding how initial document is fetched #3102)
- integration/compatibility tests added/updated;
- spot refactorings done;