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

Proposal: Wire for dependency injection #429

Draft
wants to merge 3 commits into
base: config
Choose a base branch
from
Draft

Proposal: Wire for dependency injection #429

wants to merge 3 commits into from

Conversation

ondrej-fabry
Copy link
Member

@ondrej-fabry ondrej-fabry commented May 4, 2020

This PR introduces new way to do dependency injection for the cn-infra application components (plugins). It uses github.com/google/wire library to generate code for connecting the components. This encourages explicit initialization at compile-time instead of using magic to resolve dependencies during runtime. Here's guide for the wire library: https://github.com/google/wire/blob/master/docs/guide.md

By switching to this method we could dramatically improve the Ligato code-base:

  • make the application setup much more readable to users
  • remove the requirement of defining Init()/AfterInit()/Close() methods
  • the "plugin" concept could become obsolete
    • packages agent and infra could be removed
    • the boiler-plate files options.go could be removed
    • various cn-infra components could be used separately
  • make the actual program initialization much faster (no reflection)
  • help catch dependency-related issues during compilation instead of panic at runtime

Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
@ondrej-fabry ondrej-fabry added the ❗ WIP [don't merge] DO NOT MERGE! label May 4, 2020
@ondrej-fabry ondrej-fabry changed the base branch from master to config May 4, 2020 14:11
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
@sonarcloud
Copy link

sonarcloud bot commented May 27, 2020

SonarCloud Quality Gate failed.

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 7 Code Smells

No Coverage information No Coverage information
3.3% 3.3% Duplication

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

Successfully merging this pull request may close these issues.

1 participant