Skip to content

Proposal: Wire for dependency injection#429

Draft
ondrej-fabry wants to merge 3 commits intoconfigfrom
wire
Draft

Proposal: Wire for dependency injection#429
ondrej-fabry wants to merge 3 commits intoconfigfrom
wire

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>
@sonarqubecloud
Copy link

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