dry-rb / dry-rb/dry-container

Proposal: Meta information for container objects

Open
#46 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Ruby
Stars
339
Forks
41
PR merge metrics
No merged PRs in 30d

Description

I think it'll be helpful to store some meta-information about dependency in a container. Some ideas where you can use this information:

* Aliases for DI frameworks (dry-auto_inject in our case);
* Store graph of all dependencies in a dependency. After we can calculate what we need to load and check before current dep and it will provide to detect "dependency deadlock" (when A dependency load B dependency and B dependency load A);
* Rules for DI framework (hello java). For example, it can allow loading dependency in specific scope:

```ruby
container.register('users.repositories.users', only_in: 'users.operations.*') { ... }

module Books
module Operations
class Create
include Import['users.repositories.users'] # => raise error on booting
end
end
end
```

* Passing context into dependencies
* Etc

WDYT? I can implement simple PoC for meta information, and after that we can start play with it if you like the idea

Contributor guide

Open the contributing guide

Research direction

Begin by reviewing the existing container registration and resolution behavior; the issue does not name specific files or tests. Compare the proposed metadata uses and clarify which capability should be implemented first, along with its observable behavior and test coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.