-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Increases usage of dependency injection #14
base: master
Are you sure you want to change the base?
Conversation
} | ||
|
||
public SocketConnector CreateSocketConnector(IRCd ircd, ServerElement config) { | ||
return new SocketConnector(log, ircd, config); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This (and SocketListenerFactory) are only really just returning an object conditionless at the moment, I am guessing this is being done with a bigger picture in mind? I can see it nicely abstracts the Log creation but I don't really have the bigger picture in my head at the moment
@@ -43,7 +45,7 @@ public class SocketListener { | |||
} | |||
public virtual void Stop() { | |||
if (_started) { | |||
_ircd.Log.Debug($"Shutting down listener [IP: {Info.Host}, Port: {Info.Port}, TLS: {Info.IsTls}]"); | |||
log.Debug($"Shutting down listener [IP: {Info.Host}, Port: {Info.Port}, TLS: {Info.IsTls}]"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can already see that this is so much better than passing around everything inside IRCd
This is a first draft to demonstrate how we can use factories to inject services into objects which are created after startup.
The factories are created at startup, with necessary services injected, and pass these into the constructors of the objects they create.
In the factories submitted so far, I have injected the Log object to construct SocketListener/SocketConnector. The IRCd class no longer needs to know that these classes require a Log.
Unfortunately I couldn't inject the IRCd class into the factory because it would have been a circular dependency.
Any thoughts?