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

Generate dependency graph for all objects in application container #80

Closed
davydovanton opened this issue Feb 10, 2018 · 5 comments
Closed
Assignees
Labels

Comments

@davydovanton
Copy link
Member

I created a simple proof of concept for generation graph of all dependencies in container: link to gist file.

For this I used "custom" auto_inject register for creating included_keys class method with all dependencies.

After that I detect all classes with this method and generate "AST" with associations between classes.

With this changes we can detect unused dependencies in container, build GUI graph for easily understand system (like UML diagrams) and ect.

We can start build something like this for dry-system, WDYT? I can create a simple plan with small steps for this feature if you want.

@davydovanton
Copy link
Member Author

davydovanton commented May 20, 2019

After discussion with @solnic we decided to create a graph of all registered dependencies in dry-system. Also, we want to provide public API for working with this graph. It’ll allow using dry-system-graph for everyone.

Our strategic product goals now: build GUI graph for dependencies, detect unused keys and calculate heat map.

Implementation

We want to use dry-events and dry-monitoring for sending events that something was registered in the container. After that, create a new library for detecting it and detecting what and when was called. And build a graph depend on these events.

After that, we want to create plugins for GUI, unused keys and etc.

Schematically it can look like this. In dry-event we subscribe on something that happen in dry-system (registered, joined and called):

2019-05-20 15 56 44

After that we can build a directed graph with weight for edges:

2019-05-20 15 56 39

Current state and TODO

dry-events and monitoring

  • Understand how to work with dry-events and update (or make documentation);
  • Have a call with @mensfeld do understand what our next steps in dry-monitoring library;

dry-system dependency graph

  • Update #register method for broadcasting events;
  • Update injectable object for dry-system for broadcasting events on dependency injection;
    • main issue - how to understand what was injected and target for this;
  • Describe dry-system monitoring/event mechanism in documentation;
  • Move allow logic to dry-system (instead auto_inject);
  • Create a dry-system-graph library and subscribe to dry-system notifications for generation graph of dependencies;
  • Create documentation for dry-system-graph project and create a simple example of how to build own plugins;
  • Make a plugin (based on the pure rack) for show dependency graph on a web page;

@davydovanton davydovanton self-assigned this May 20, 2019
@timriley
Copy link
Member

This looks like an exciting development, @davydovanton! Mind if I ask a few questions? I'm sure many of these might've been clear to those of you chatting in person, but it might help for people like me, following from afar and perhaps interested in helping.

(1) Firstly, is the goal of this to be able to get the dependency graph simply from booting the system? Or will it need the system to actually be run and exercised in order to generate the graph? (i.e. have actual web requests run over it, in the case of a web app)

(2) Would you mind explaining a bit more what you meant here?

Move allow logic to dry-system (instead auto_inject);

Thanks! I'll be following this closely and will try to help where I can!

@davydovanton
Copy link
Member Author

@timriley thanks for questions! Really love it 👏

(1) I hope we will able to detect nodes/edges after call register method and include Inject[...] line. I want to use running application only for optional detecting weight across nodes (dependencies).

(2) Forgot to update comment and link this PR - dry-rb/dry-auto_inject#59

@davydovanton
Copy link
Member Author

The current state of the feature:

We merged notifications to dry-system #113 and create a simple WIP project https://github.com/dry-rb/dry-system-dependency_graph. And now working on building and working with the dependency graph.

Generated dependency graph for repository example:
https://github.com/dry-rb/dry-system-dependency_graph/blob/master/examples/standalone/dependency_graph.png

@timriley
Copy link
Member

Since the initial dependency_graph plugin is already implemented, I'm closing this issue.

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

No branches or pull requests

2 participants