Skip to content

✨ feat(event-handlers): add support for custom suspending event handlers in Velocity#341

Merged
twisti-dev merged 2 commits into
version/26.1from
fix/suspending-event-handlers
May 9, 2026
Merged

✨ feat(event-handlers): add support for custom suspending event handlers in Velocity#341
twisti-dev merged 2 commits into
version/26.1from
fix/suspending-event-handlers

Conversation

@twisti-dev
Copy link
Copy Markdown
Contributor

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:

  • Added VelocityEventManagerReflection, a utility class using reflection to access and create custom handler adapters in Velocity's event system.
  • Refactored SuspendingEventHandler to use VelocityEventManagerReflection for 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:

  • Added velocity-proxy-ctd to the dependencies for accessing Velocity internals, and updated surf-api-velocity-server to use it as a compileOnly dependency. [1] [2]
  • Bumped project version from 3.9.4 to 3.9.5 in gradle.properties.

@twisti-dev twisti-dev self-assigned this May 9, 2026
Copilot AI review requested due to automatic review settings May 9, 2026 17:09
Copy link
Copy Markdown
Contributor

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

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 VelocityEventManagerReflection to access handlerAdapters and construct CustomHandlerAdapter reflectively.
  • Refactors SuspendingEventHandler to register the new adapter and detect suspend handlers without kotlin-reflect.
  • Adds a compileOnly dependency on velocity-proxy-ctd and bumps the root version to 3.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.

@twisti-dev twisti-dev enabled auto-merge May 9, 2026 17:19
@twisti-dev twisti-dev disabled auto-merge May 9, 2026 17:19
@twisti-dev twisti-dev merged commit adb7cd4 into version/26.1 May 9, 2026
7 checks passed
@twisti-dev twisti-dev deleted the fix/suspending-event-handlers branch May 9, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants