Skip to content
Discussion options

You must be logged in to vote

Specifically:

  1. Are Delegating Handler constructor dependencies expected to be singleton/transient-only?

Consider any delegating handler as a transient service. My opinion is that all handlers should be free of any state or dependencies.
In practice, in Ocelot, a constructed delegating handler for a route is a singleton being "cached" in MessageInvokerPool for performance reasons. This singleton behavior is not a problem because current Ocelot handlers don't inject any services either via the constructor or on the fly from the service provider. If a developer injects any stateful custom handlers into the Ocelot pipeline, they will be a bit surprised. For more details, read below where e…

Replies: 7 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by raman-m
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@raman-m
Comment options

@raman-m
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
Delegating Handlers Ocelot feature: Delegating Handlers Dependency Injection Ocelot feature: Dependency Injection
2 participants
Converted from issue

This discussion was converted from issue #2425 on September 28, 2026 10:41.