Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Module registration changes #998

Merged
merged 12 commits into from
Feb 20, 2013

Conversation

grumpydev
Copy link
Member

Switched per-request module registration so only a single module is registered - the fact we registered all of them was wasteful because we guarantee we only resolve one per request anyway - this gives a massive per-request speedup when using lots of modules.

Module key generator is gone as part of this change.

Other boostrappers will need to be updated.

Also update TinyIoC - optimised the speed of AutoRegister to reduce startup times with lots of types defined.

We were registering every module on every request, which is slow
and wasteful when we only resolve one per request. Changed it so
now we store the module type rather than the "key", and with the
per request container bootstrappers we register a single module
per request, then resolve it.

Not 100% sure if we should split out the register and resolve calls
in the classes that derrive from the request container base class
(currently it expects them to register and resolve in the GetModule
method)

Currently non-request container bootstrappers are broken.
@@ -51,14 +51,14 @@ public override sealed IEnumerable<INancyModule> GetAllModules(NancyContext cont
}

/// <summary>
/// Gets a specific, per-request, module instance from the key
/// Retrieves a specific <see cref="NancyModule"/> implementation - should be per-request lifetime
Copy link
Member

Choose a reason for hiding this comment

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

Nitpicking but it should probably say INancyModule and not NancyModule

@@ -487,12 +438,12 @@ public override IEnumerable<INancyModule> GetAllModules(NancyContext context)
}

/// <summary>
/// Retrieves a specific <see cref="NancyModule"/> implementation based on its key
/// Retrieves a specific <see cref="NancyModule"/> implementation - should be per-request lifetime
Copy link
Member

Choose a reason for hiding this comment

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

Another INancyModule ;)

thecodejunkie added a commit that referenced this pull request Feb 20, 2013
@thecodejunkie thecodejunkie merged commit 6033029 into NancyFx:master Feb 20, 2013
@grumpydev grumpydev deleted the ModuleRegistrationChanges branch April 7, 2014 09:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants