Replies: 1 comment
-
|
Hello, The public API enforces transient lifetime for all handlers discovered via Register() or RegisterFromAssembly(). This prevents captive dependencies and thread safety issues by default. For stateless, thread-safe handlers where you need singleton performance, manually register the handler before calling AddLiteBus: var services = new ServiceCollection();
// 1. Manually register as singleton
services.AddSingleton<MyStatelessSingletonHandler>();
// 2. AddLiteBus will detect existing registration and skip its own
services.AddLiteBus(modules =>
{
modules.AddCommandModule(cmd => cmd.RegisterFromAssembly(typeof(MyCommand).Assembly));
});It's a good feature to have and I'll add it in next versions. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello
Is it possible to register the handlers with different ServiceLifetime, for example as Singleton instead of the default Transient registration?
Beta Was this translation helpful? Give feedback.
All reactions