Skip to content
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

Introduce IoC / simple DI to improve extendibility #118

Closed
RassK opened this issue Apr 7, 2021 · 3 comments
Closed

Introduce IoC / simple DI to improve extendibility #118

RassK opened this issue Apr 7, 2021 · 3 comments

Comments

@RassK
Copy link
Contributor

RassK commented Apr 7, 2021

Why

Introduce very simple DI to make current solution more extendable.

What

Due full IoC containers add unnecessary complexity and reduce performance I would offer "Factory configurator" pattern.
Instead of hosting anything like IoC containers, factory configurator will take reference only for implementations of the concrete interfaces (see example below). OTel repo will host DefaultFactoryConfiguration and a distro will host eg: SplunkFactoryConfiguration where it could override the sub services / factories or construct whole implementation from scratch. Factory configuration type could be loaded either from environment variable, from static, etc. IFactoryConfiguration reference must be passed down the line (I expect it will be in the Tracer instance?)

This feature is connected to: #117

class SomeFactoryConfiguration : IFactoryConfiguration
{
   // Singleton services
   public IMyService { get; } = new MyDistroService();

   // Transient services
   public IMyFactory { get; } = new MyDistroFactory();
}
@pellared
Copy link
Member

pellared commented Apr 7, 2021

It is also related to #116

nit: I would prefer to have methods in interfaces than properties like

class SomeFactoryConfiguration : IFactoryConfiguration
{
   // Singleton services
   public IMyService MyService() => new MyDistroService();

   // Transient services
   public IMyFactory MyFactory() => new MyDistroFactory();
}

@RassK
Copy link
Contributor Author

RassK commented Apr 8, 2021

Leaving a note: We have to get rid of enums and prob return to constant string values. Enums are not extendable.

@macrogreg
Copy link
Contributor

Closing since this is basically the same as #117

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants