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

SOLR-16847 Give v2 APIs access to solrconfig.xml config #1778

Merged
merged 6 commits into from
Aug 1, 2023

Conversation

stillalex
Copy link
Member

@stillalex stillalex commented Jul 12, 2023

https://issues.apache.org/jira/browse/SOLR-16847

Description

Please provide a short description of the changes you're making with this pull request.

Solution

Please provide a short description of the approach taken to implement your solution.

Tests

Please describe the tests you've developed or run to confirm this patch implements the feature or solves the problem.

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Solr maintainers access to contribute to my PR branch. (optional but recommended)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.
  • I have added documentation for the Reference Guide

@sonatype-lift
Copy link

sonatype-lift bot commented Jul 12, 2023

Sonatype Lift is retiring

Sonatype Lift will be retiring on Sep 12, 2023, with its analysis stopping on Aug 12, 2023. We understand that this news may come as a disappointment, and Sonatype is committed to helping you transition off it seamlessly. If you’d like to retain your data, please export your issues from the web console.
We are extremely grateful and thank you for your support over the years.

📖 Read about the impacts and timeline

Copy link
Contributor

@gerlowskija gerlowskija left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks awesome, thanks @stillalex !

I left a few comments inline; if you can respond to those I'll switch this to 'Approve' and start testing/merging.

A bit of a larger macro question: should this PR modify an existing v2 API/request-handler to implement APIConfigProvider as a way to validate (and exhibit) the approach? Or would that bloat the PR too much (because it'd involve converting a new API to JAX-RS?)

solr/core/src/java/org/apache/solr/core/PluginBag.java Outdated Show resolved Hide resolved

@Override
protected void configure() {
bindFactory(cfgProvider).to(cfgProvider.getConfigClass());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Q] In HK2 you can set a "scope" for bindings, that impacts how often factories are asked to produce a new instance. e.g. We have a few bindings in JerseyApplications that are RequestScoped - meaning that Jersey prompts the factory on each API call.

In the case of these config objects - I think right now we expect them to be driven by solrconfig.xml config, which should be static through the life of the Jersey application. Tbh I forget what "scope" is used as a default when no explicit value is provided, but we should make sure it fits this expectations. It'd prob be wasteful if each API call triggered provide(), returning a functionally equivalent object each time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the perf aspect, this will get called on each call. my thought was that the config object gets created once and simply returned as many times as needed. I would suggest we leave as is and revisit this pattern if needed, but let me double check again on the scope parts.

@stillalex stillalex force-pushed the SOLR-16847-api-config-access branch from d34c8ce to 4017b23 Compare July 26, 2023 14:43
@stillalex
Copy link
Member Author

A bit of a larger macro question: should this PR modify an existing v2 API/request-handler to implement APIConfigProvider as a way to validate (and exhibit) the approach? Or would that bloat the PR too much (because it'd involve converting a new API to JAX-RS?)

this was my original thought, but to avoid this growing too large I was thinking we can push this in and pickup some API that needs it next, so we can iterate if needed. I also made sure this works by adding a test to showcase the functionality.

@gerlowskija
Copy link
Contributor

I was thinking we can push this in and pickup some API that needs it next, so we can iterate if needed.

SGTM, as long as you or I remember to follow up on that 😛

This LGTM, gonna run tests this afternoon and look to merge!

@gerlowskija gerlowskija merged commit 9c43fc1 into apache:main Aug 1, 2023
2 checks passed
@stillalex stillalex deleted the SOLR-16847-api-config-access branch August 1, 2023 20:05
@stillalex
Copy link
Member Author

thank you @gerlowskija!

gerlowskija pushed a commit that referenced this pull request Aug 4, 2023
Prior to this commit, v2 APIs had no clean way to access any solrconfig.xml
configuration for their associated "requestHandler".  This commit introduces
an interface, APIConfigProvider, which allows us to inject this configuration
to v2 API classes at call time in a "strongly-typed" way.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants