8000 Refactor rest handlers into coroutines by goedderz · Pull Request #21750 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 7 commits into from
May 15, 2025

Conversation

goedderz
Copy link
Member
@goedderz goedderz commented May 7, 2025

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 the waitForFuture() methods of RestHandler.

This PR refactors most existing RestHandlers using that, so they consistently use async<T> or futures::Future<T> instead of WAITING mechanisms, starting at implementing executeAsync() instead of execute(). This gets rid of both any waitForFuture calls, and any need for RestStatus::WAITING, and thus mostly of RestStatus 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.

  • 🔨 Refactoring/simplification

goedderz added 5 commits May 7, 2025 09:50
…e+waitForFuture

The following handlers are changed:

- RestAgencyHandler
- RestAdminLogHandler
- RestDocumentHandler
- RestGraphHandler
- RestImportHandler
- RestLogHandler
- RestLogInternalHandler
- RestMetricsHandler
- RestReplicationHandler
- RestTransactionHandler
- RestUsageMetricsHandler
8000
@goedderz goedderz added this to the devel milestone May 7, 2025
@goedderz goedderz requested a review from Copilot May 7, 2025 13:00
@goedderz goedderz self-assigned this May 7, 2025
@cla-bot cla-bot bot added the cla-signed label May 7, 2025
Copy link
@Copilot Copilot AI left a 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;

@goedderz
Copy link
Member Author
goedderz commented May 7, 2025

@goedderz
Copy link
Member Author
goedderz commented May 7, 2025

ASan/LSan/UBsan tests successful:
https://app.circleci.com/pipelines/github/arangodb/arangodb/34477

Copy link
Contributor
@johann-listunov johann-listunov left a 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.

@goedderz goedderz merged commit f222093 into devel May 15, 2025
7 checks passed
@goedderz goedderz deleted the feature/refactor-rest-handlers-into-coroutines branch May 15, 2025 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0