✨ feat(event-handlers): add support for custom suspending event handlers in Velocity#341
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds Velocity support for coroutine-based (suspend) event handlers by registering a custom CustomHandlerAdapter into Velocity’s internal VelocityEventManager via MethodHandles-based reflection. Also updates the Velocity server module’s dependencies and bumps the project version.
Changes:
- Introduces
VelocityEventManagerReflectionto accesshandlerAdaptersand constructCustomHandlerAdapterreflectively. - Refactors
SuspendingEventHandlerto register the new adapter and detect suspend handlers withoutkotlin-reflect. - Adds a
compileOnlydependency onvelocity-proxy-ctdand bumps the root version to3.9.5.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| surf-api-velocity/surf-api-velocity-server/src/main/kotlin/dev/slne/surf/api/velocity/server/SuspendingEventHandler.kt | Registers a custom suspending handler adapter into Velocity’s event manager using the new reflection helper. |
| surf-api-velocity/surf-api-velocity-server/src/main/java/dev/slne/surf/api/velocity/server/reflection/VelocityEventManagerReflection.java | New reflection utility to access Velocity internals (field + constructor) via VarHandle/MethodHandle. |
| surf-api-velocity/surf-api-velocity-server/build.gradle.kts | Adds velocity-proxy-ctd as compileOnly to compile against Velocity internals. |
| gradle/libs.versions.toml | Adds version-catalog alias for velocity-proxy-ctd. |
| gradle.properties | Bumps project version from 3.9.4 to 3.9.5. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces support for custom suspending event handler adapters for the Velocity platform, along with an update to dependencies and the project version. The main changes involve adding reflection-based integration with Velocity internals, refactoring the event handler registration to use this new mechanism, and updating build configuration to include the necessary dependencies.
Velocity suspending event handler support:
VelocityEventManagerReflection, a utility class using reflection to access and create custom handler adapters in Velocity's event system.SuspendingEventHandlerto useVelocityEventManagerReflectionfor registering a custom handler adapter, enabling support for suspending (Kotlin coroutine) event handlers. The registration logic and validation were updated accordingly.Dependency and build configuration updates:
velocity-proxy-ctdto the dependencies for accessing Velocity internals, and updatedsurf-api-velocity-serverto use it as acompileOnlydependency. [1] [2]3.9.4to3.9.5ingradle.properties.