question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Function to extract all di entities by type

See original GitHub issue

Started in slack

Could you provide a way to extract all DI entities (with their tags) from a DI container? This would be very useful for CLI applications, where you have some tagged processors controlled by cli flag that do same work in different context. Consider this example using kotlinx-cli:

val di = DI {
  bind<MavenScannerService<*>>("mavenCentral") with singleton { MavenScannerServiceImpl(...) }
  bind<MavenScannerService<*>>("jCenter") with singleton { MavenScannerServiceImpl(...) }
  bind<MavenScannerService<*>>("google") with singleton { MavenScannerServiceImpl(...) }
}

fun main(args: Array<string>) {
  val parser = ArgParser("scanner")
  val scanners: Set<Pair<String?, DIProvider<MavenScannerService<*>>>> = di.direct.allProviderBindings<MavenScannerService<*>>() // <--------------- New API, alternatives for instances and factories omitted

  val scanner by parser.argument(
    type = ArgType.Choice(scanners.mapNotNull { it.first }, { scanners.find { (tag, _) ->  it == tag } }),
    description = "Repository alias to scan for"
  )
  parser.parse(args)

  // do stuff with scanner
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
romainbslcommented, Feb 22, 2022

I will think about that. This is kind of hacking the container, I will see if we really want to document this.

If so, I will create a another issue. Thx

0reactions
mpetuskacommented, Feb 22, 2022

While this definitely solves my issue, could I ask that this issue is reopened in order to lift up those undocumented APIs into public domain?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Extract custom entities from documents in their native format ...
You can now use natural language processing (NLP) to extract custom entities from your PDF, Word, and plain text documents using the same...
Read more >
Use Custom Entity Extraction AI Model to Extract ... - YouTube
Use Custom Entity Extraction AI Model to Extract the Useful Entities from your Business Data · Key moments. View all · Key moments...
Read more >
Extracting Entities with Automated Data Wrappers
Google shows us how automated data wrappers may be used to extract entity information from web pages and make The knowledge graph better....
Read more >
Extracting and Representing Entities, Types, and Relations
for extracting all entities and long-range relations simultaneously over full paragraphs while jointly linking these entities to a KG.
Read more >
The entity cannot be constructed in a LINQ to Entities query
The entity cannot be constructed in a LINQ to Entities query · System.NotSupportedException: 'The entity or complex type 'StudentInfoAjax.Models. · You can map...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found