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

Register MediaTypes through SPI #8938

Merged
merged 2 commits into from
Jul 28, 2023
Merged

Conversation

nknize
Copy link
Collaborator

@nknize nknize commented Jul 27, 2023

This PR provides a new SPI interface MediaContentProvider. Modules, Plugins, Extensions, implement this interface and provide the concrete MediaType implementations (and MIME aliases) through getMediaTypes and getAdditionalMediaTypes, respectively. This enables downstream extensions (e.g., serverless or cloud native implementations) as well as plugins or core modules to register their own custom MediaType through the interface. All types are registered through ServiceLoader.load(MediaTypeProvider.class) when the classloader loads the MediaTypeRegistry instead of having to register the types explicitly in application code. XContentType is also cutover to use this SPI interface through the :libs:opensearch-x-content library and the manual registration logic in TransportService is removed.

relates #5910
relates #8110

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@nknize nknize added the pending backport Identifies an issue or PR that still needs to be backported label Jul 27, 2023
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

  • RESULT: UNSTABLE ❕
  • TEST FAILURES:
      1 org.opensearch.search.suggest.CompletionSuggestSearchIT.testSkipDuplicates

@codecov
Copy link

codecov bot commented Jul 27, 2023

Codecov Report

Merging #8938 (d64bef5) into main (5495c64) will increase coverage by 0.04%.
Report is 2 commits behind head on main.
The diff coverage is 95.45%.

@@             Coverage Diff              @@
##               main    #8938      +/-   ##
============================================
+ Coverage     71.08%   71.13%   +0.04%     
- Complexity    57276    57281       +5     
============================================
  Files          4758     4759       +1     
  Lines        269869   269881      +12     
  Branches      39487    39488       +1     
============================================
+ Hits         191836   191970     +134     
+ Misses        61891    61742     -149     
- Partials      16142    16169      +27     
Files Changed Coverage Δ
...a/org/opensearch/common/xcontent/XContentType.java 100.00% <ø> (ø)
...ava/org/opensearch/transport/TransportService.java 80.14% <ø> (+0.32%) ⬆️
...rg/opensearch/core/xcontent/MediaTypeRegistry.java 85.29% <92.30%> (ø)
.../opensearch/client/indices/CreateIndexRequest.java 77.77% <100.00%> (+1.11%) ⬆️
...g/opensearch/client/indices/PutMappingRequest.java 72.41% <100.00%> (ø)
.../opensearch/core/common/io/stream/StreamInput.java 88.64% <100.00%> (ø)
...n/java/org/opensearch/core/xcontent/MediaType.java 100.00% <100.00%> (ø)
...ensearch/common/xcontent/spi/XContentProvider.java 100.00% <100.00%> (ø)
.../java/org/opensearch/rest/AbstractRestChannel.java 90.69% <100.00%> (ø)

... and 472 files with indirect coverage changes

nknize added 2 commits July 27, 2023 18:58
This commit provides a new SPI interface MediaContentProvider. Modules,
Plugins, Extensions, implement this interface and provide the concrete
MediaType implementations (and MIME aliases) through getMediaTypes and
getAdditionalMediaTypes, respectively. This enables downstream
extensions (e.g., serverless or cloud native implementations) to
register their own custom MediaType and define the serialization format
that is registered when the classloader loads the MediaTypeRegistry
instead of having to register the types explicitly in application code.

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
@nknize nknize force-pushed the xcontentTypeToSPI branch from c69ec94 to d64bef5 Compare July 27, 2023 23:59
@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@github-actions
Copy link
Contributor

Gradle Check (Jenkins) Run Completed with:

@reta reta merged commit 3952d5e into opensearch-project:main Jul 28, 2023
baba-devv pushed a commit to baba-devv/OpenSearch that referenced this pull request Jul 28, 2023
* Register MediaTypes through SPI

This commit provides a new SPI interface MediaContentProvider. Modules,
Plugins, Extensions, implement this interface and provide the concrete
MediaType implementations (and MIME aliases) through getMediaTypes and
getAdditionalMediaTypes, respectively. This enables downstream
extensions (e.g., serverless or cloud native implementations) to
register their own custom MediaType and define the serialization format
that is registered when the classloader loads the MediaTypeRegistry
instead of having to register the types explicitly in application code.

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>

* pass the MediaTypeProvider classloader to the SPI ServiceLoader

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>

---------

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
baba-devv pushed a commit to baba-devv/OpenSearch that referenced this pull request Jul 29, 2023
* Register MediaTypes through SPI

This commit provides a new SPI interface MediaContentProvider. Modules,
Plugins, Extensions, implement this interface and provide the concrete
MediaType implementations (and MIME aliases) through getMediaTypes and
getAdditionalMediaTypes, respectively. This enables downstream
extensions (e.g., serverless or cloud native implementations) to
register their own custom MediaType and define the serialization format
that is registered when the classloader loads the MediaTypeRegistry
instead of having to register the types explicitly in application code.

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>

* pass the MediaTypeProvider classloader to the SPI ServiceLoader

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>

---------

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
@nknize nknize added backport 2.x Backport to 2.x branch and removed pending backport Identifies an issue or PR that still needs to be backported labels Aug 1, 2023
opensearch-trigger-bot bot pushed a commit that referenced this pull request Aug 1, 2023
* Register MediaTypes through SPI

This commit provides a new SPI interface MediaContentProvider. Modules,
Plugins, Extensions, implement this interface and provide the concrete
MediaType implementations (and MIME aliases) through getMediaTypes and
getAdditionalMediaTypes, respectively. This enables downstream
extensions (e.g., serverless or cloud native implementations) to
register their own custom MediaType and define the serialization format
that is registered when the classloader loads the MediaTypeRegistry
instead of having to register the types explicitly in application code.

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>

* pass the MediaTypeProvider classloader to the SPI ServiceLoader

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>

---------

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
(cherry picked from commit 3952d5e)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
nknize pushed a commit that referenced this pull request Aug 1, 2023
This commit provides a new SPI interface MediaContentProvider. Modules,
Plugins, Extensions, implement this interface and provide the concrete
MediaType implementations (and MIME aliases) through getMediaTypes and
getAdditionalMediaTypes, respectively. This enables downstream
extensions (e.g., serverless or cloud native implementations) to
register their own custom MediaType and define the serialization format
that is registered when the classloader loads the MediaTypeRegistry
instead of having to register the types explicitly in application code.

---------


(cherry picked from commit 3952d5e)

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
kaushalmahi12 pushed a commit to kaushalmahi12/OpenSearch that referenced this pull request Sep 12, 2023
* Register MediaTypes through SPI

This commit provides a new SPI interface MediaContentProvider. Modules,
Plugins, Extensions, implement this interface and provide the concrete
MediaType implementations (and MIME aliases) through getMediaTypes and
getAdditionalMediaTypes, respectively. This enables downstream
extensions (e.g., serverless or cloud native implementations) to
register their own custom MediaType and define the serialization format
that is registered when the classloader loads the MediaTypeRegistry
instead of having to register the types explicitly in application code.

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>

* pass the MediaTypeProvider classloader to the SPI ServiceLoader

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>

---------

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
Signed-off-by: Kaushal Kumar <ravi.kaushal97@gmail.com>
brusic pushed a commit to brusic/OpenSearch that referenced this pull request Sep 25, 2023
* Register MediaTypes through SPI

This commit provides a new SPI interface MediaContentProvider. Modules,
Plugins, Extensions, implement this interface and provide the concrete
MediaType implementations (and MIME aliases) through getMediaTypes and
getAdditionalMediaTypes, respectively. This enables downstream
extensions (e.g., serverless or cloud native implementations) to
register their own custom MediaType and define the serialization format
that is registered when the classloader loads the MediaTypeRegistry
instead of having to register the types explicitly in application code.

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>

* pass the MediaTypeProvider classloader to the SPI ServiceLoader

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>

---------

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
Signed-off-by: Ivan Brusic <ivan.brusic@flocksafety.com>
shiv0408 pushed a commit to Gaurav614/OpenSearch that referenced this pull request Apr 25, 2024
* Register MediaTypes through SPI

This commit provides a new SPI interface MediaContentProvider. Modules,
Plugins, Extensions, implement this interface and provide the concrete
MediaType implementations (and MIME aliases) through getMediaTypes and
getAdditionalMediaTypes, respectively. This enables downstream
extensions (e.g., serverless or cloud native implementations) to
register their own custom MediaType and define the serialization format
that is registered when the classloader loads the MediaTypeRegistry
instead of having to register the types explicitly in application code.

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>

* pass the MediaTypeProvider classloader to the SPI ServiceLoader

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>

---------

Signed-off-by: Nicholas Walter Knize <nknize@apache.org>
Signed-off-by: Shivansh Arora <hishiv@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x Backport to 2.x branch enhancement Enhancement or improvement to existing feature or request skip-changelog v2.10.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants