Nancy: Is there a way to dynamically register module with Nancy?

Created on 4 Dec 2015  路  12Comments  路  Source: NancyFx/Nancy

Hello,

I am going to dynamically register a module via manually loading assembly( *.dll ). Any ideas?

Big Thanks.

Most helpful comment

@brgrz Just wrote a post for you. Thx. Make Nancy Support Hot-plugging

All 12 comments

@khellang Hello, Any ideas? Thanks.

You can override the Modules property in the bootstrapper and return a list of ModuleRegistration. The default implementation looks like this; https://github.com/NancyFx/Nancy/blob/master/src/Nancy/Bootstrapper/NancyBootstrapperBase.cs#L107-L121.

@khellang Thanks for your information. Unfortunately, this is not what I really want. By your way, We can customize Modules List; Howerver, It need to reboot NancyHost everytime when you want to register a new module at runtime. What I want to do is to reflect a dll dynamically and register the module to NancyHost at runtime. In fact, is to achieve NancyModule hot-plugging. Any Ideas? Thanks!

Nope. This is not possible. Nancy scans for modules and registers them in the container once, at startup. This is because of caching of route handlers etc.

@khellang How about if we create multiple NancyHost instance or Mutitiple Process to handle NancyModule hot-plugging. Eh, This is not a good way. Anyway, thank you for your prompt reply. Otherwise, maybe I'll have to debug & research your source code all night. :D

The only way I can think of is to run self hosted and whenever you have a new DLL to load you kill the host, load the DLL, then spin it back up again - you will also need to dispose the bootstrapper and create a new instance of it each time.

@khellang @grumpydev Hi Guys, Nancy support module hot-plugging is possilbe, I just make a small-changes of Nancy. It works well. :D If you are interested, we can discuss together. I have to go to bed, now it is half past three in the morning. :D

@Hell0wor1d How did you do it? Why not sharing it with the community? PR or a gist maybe?

@brgrz Just wrote a post for you. Thx. Make Nancy Support Hot-plugging

Thanks, great job.

I understand this issue is closed, but what are the chances it will find it's way into the official build?

Sorry, but I think this is not up to date anymore.. Is there currently a way for registrating only specific modules by code??

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thecodejunkie picture thecodejunkie  路  8Comments

jchannon picture jchannon  路  7Comments

thecodejunkie picture thecodejunkie  路  4Comments

epsitec picture epsitec  路  5Comments

jlennox picture jlennox  路  5Comments