Skip to content

cache actionHandlers on creation#34

Merged
octonato merged 1 commit intolightbend:mainfrom
jrudolph:avoid-per-call-reflection-lookup
Jun 15, 2021
Merged

cache actionHandlers on creation#34
octonato merged 1 commit intolightbend:mainfrom
jrudolph:avoid-per-call-reflection-lookup

Conversation

@jrudolph
Copy link
Copy Markdown
Contributor

Otherwise, all the ActionReflection code (looking up methods and annotations, etc) will be re-executed for every single call.

Copy link
Copy Markdown
Contributor

@johanandren johanandren left a comment

Choose a reason for hiding this comment

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

Good catch!

Copy link
Copy Markdown
Contributor

@patriknw patriknw left a comment

Choose a reason for hiding this comment

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

LGTM

private object creationContext extends ActionCreationContext {
override def serviceCallFactory(): ServiceCallFactory = rootContext.serviceCallFactory()
}
private val actionHandlers: Map[String, ActionHandler] = services.view.mapValues(_.factory.create(creationContext)).toMap
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think we say anything about the expected concurrency in the action instances, or have a good reason for creating a new instance for each request, so I think this change is fine.

@jrudolph jrudolph force-pushed the avoid-per-call-reflection-lookup branch from 4705111 to 616892f Compare June 15, 2021 18:30
@octonato octonato merged commit 651f5ba into lightbend:main Jun 15, 2021
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.

4 participants