Skip to content

Refactor RestHandler state machine into a coroutine #21787

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

Open
wants to merge 77 commits into
base: devel
Choose a base branch
from

Conversation

goedderz
Copy link
Member

@goedderz goedderz commented May 27, 2025

Scope & Purpose

Refactor the RestHandler's state machine into a coroutine. This is foundational work to allow rewriting more code into (asynchronous) coroutines.

  • 🔨 Refactoring/simplification

Checklist

  • Covered by existing tests

goedderz and others added 30 commits February 13, 2025 14:09
- Temporarily disabled LogContext (ScopedValue in rest handler state
  machine)
- Made more stuff async
- Fixed an issue by moving a coro from Future to async, because futures
  don't pass ExecContext as coros (just as an awaitable)
- Fixed an issue by moving WAITING<->coro adapter further up the stack
…e+waitForFuture

The following handlers are changed:

- RestAgencyHandler
- RestAdminLogHandler
- RestDocumentHandler
- RestGraphHandler
- RestImportHandler
- RestLogHandler
- RestLogInternalHandler
- RestMetricsHandler
- RestReplicationHandler
- RestTransactionHandler
- RestUsageMetricsHandler
…ub.com:arangodb/arangodb into feature/refactor-resthandler-state-machine-into-coro
@goedderz goedderz marked this pull request as ready for review June 27, 2025 11:27
@goedderz goedderz requested a review from a team June 27, 2025 17:57
Copy link
Member

@neunhoef neunhoef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks overall very good and is going exactly in the right direction. I have added some minor comments, some of which need addressing. And a CHANGELOG entry is missing. In particular I checked that the log context is now in the async context and will thus be moved from thread local variable to thread local variable if a coroutine is suspended on one thread and resumed on another. Therefore it is now allowed to use ScopedValue and log contexts in coroutines (with its lifetime bound to the coroutine context object).

add_library(arango_async INTERFACE)
target_include_directories(arango_async INTERFACE
add_library(arango_async STATIC
include/Async/async.h
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these header files listed here? Usually, we seem to only add the .cpp files.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are dependencies, the library needs to be rebuilt if the headers change. That being said, I think the build system does detect them as such anyway, so it shouldn't be necessary for that. Where it does make a difference is for IDEs like Visual Studio, when the CMake files are used as a basis for a project. In particular if the header files don't have a corresponding source file of the same name, in which case they should at least be detected by heuristics.

All in all, while I don't think it's hugely important, I do think it's generally preferable to add header files as well.

Copy link
Contributor

@jvolmer jvolmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the code much better readable, really cool! I added some questions and minor comments.

@goedderz goedderz requested a review from neunhoef July 17, 2025 15:16
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.

3 participants