While working on a project that uses DispatchR with a limited handler set, I noticed an issue with handler registration.
In this project, one service only needs to register two handlers, so DispatchR is configured with IncludeHandlers, and I expected DispatchR to register only those handlers from the assembly. However, stream request handlers from the same assembly were still being registered.
After checking the registration logic, it looks like IncludeHandlers / ExcludeHandlers are only applied to concrete IRequestHandler<,> implementations. Concrete IStreamRequestHandler<,> implementations are included through otherHandlerTypes, so they bypass IsHandlerIncluded(...).
This causes applications that intentionally register only a small subset of handlers to pull unrelated stream handlers into DI. In my case, the service started requiring dependencies for handlers it does not use.
The expected behavior is that IncludeHandlers / ExcludeHandlers should apply to both:
- concrete
IRequestHandler<,>
- concrete
IStreamRequestHandler<,>
Pipeline and notification discovery should remain unchanged.
I opened a PR with a fix here: #51
While working on a project that uses DispatchR with a limited handler set, I noticed an issue with handler registration.
In this project, one service only needs to register two handlers, so DispatchR is configured with
IncludeHandlers, and I expected DispatchR to register only those handlers from the assembly. However, stream request handlers from the same assembly were still being registered.After checking the registration logic, it looks like
IncludeHandlers/ExcludeHandlersare only applied to concreteIRequestHandler<,>implementations. ConcreteIStreamRequestHandler<,>implementations are included throughotherHandlerTypes, so they bypassIsHandlerIncluded(...).This causes applications that intentionally register only a small subset of handlers to pull unrelated stream handlers into DI. In my case, the service started requiring dependencies for handlers it does not use.
The expected behavior is that
IncludeHandlers/ExcludeHandlersshould apply to both:IRequestHandler<,>IStreamRequestHandler<,>Pipeline and notification discovery should remain unchanged.
I opened a PR with a fix here: #51