-
Notifications
You must be signed in to change notification settings - Fork 851
Refactor rest handlers into coroutines #21750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor rest handlers into coroutines #21750
Conversation
…e+waitForFuture The following handlers are changed: - RestAgencyHandler - RestAdminLogHandler - RestDocumentHandler - RestGraphHandler - RestImportHandler - RestLogHandler - RestLogInternalHandler - RestMetricsHandler - RestReplicationHandler - RestTransactionHandler - RestUsageMetricsHandler
…cute+waitForFuture
…actor-rest-handlers-into-coroutines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors multiple REST handlers to eliminate the legacy waiting mechanism in favor of modern C++ coroutines. Key changes include replacing functions like execute() and waitForFuture() with executeAsync() combined with co_await/co_return patterns, consistent conversion of error‐and–success paths, and corresponding adjustments to helper and utility functions.
Reviewed Changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
arangod/RestHandler/RestReplicationHandler.{h,cpp} | Converted execute() to executeAsync() and replaced waitForFuture() with co_await/co_return. |
arangod/RestHandler/RestMetricsHandler.{h,cpp} | Refactored the metrics handler to use asynchronous coroutine patterns. |
arangod/RestHandler/RestLog*, RestDocumentHandler.{h,cpp} | Updated various Rest*Handlers to use async and executeAsync() with coroutines. |
arangod/RestHandler/RestImportHandler*.{h,cpp} | Changed the synchronous execute() method to a coroutine-based executeAsync(). |
arangod/Agency/RestAgencyHandler*.{h,cpp} | Refactored agency handler methods to use coroutines, including changes to pollIndex and error reporting. |
Comments suppressed due to low confidence (1)
arangod/RestHandler/RestLogHandler.h:39
- The new function name 'executeAsync' clearly communicates its async nature; ensure that similar naming conventions are uniformly applied across all refactored handlers.
auto executeAsync() -> futures::Future<futures::Unit> override;
TSan tests successful: https://app.circleci.com/pipelines/github/arangodb/arangodb/34478 |
ASan/LSan/UBsan tests successful: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, besides the one question.
Scope & Purpose
As a prerequisite to rewriting the RestHandler's state machine (
runHandlerStateMachine()
) into a coroutine, which in turn is a prerequisite to e.g. make AQL setup & shutdown operations asynchronous, we need to get rid of existing async/WAITING glue code, namely thewaitForFuture()
methods ofRestHandler
.This PR refactors most existing RestHandlers using that, so they consistently use
async<T>
orfutures::Future<T>
instead ofWAITING
mechanisms, starting at implementingexecuteAsync()
instead ofexecute()
. This gets rid of both anywaitForFuture
calls, and any need forRestStatus::WAITING
, and thus mostly ofRestStatus
as a whole.The only missing RestHandlers are the AQL-related ones: RestCursorHandler and its derivatives RestSimpleHandler and RestSimpleQueryHandler, and RestAqlHandler. This will be adressed together with the refactored state machine.