Skip to content

Add RemoteS3ConnectionProvider plugin implementations #191

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mosiac1
Copy link
Contributor

@mosiac1 mosiac1 commented Apr 1, 2025

Add generic implementations for the RemoteS3ConnectionProvider interface.

config, file and http

Added a README for the file and http ones as those are a bit more complex

@cla-bot cla-bot bot added the cla-signed label Apr 1, 2025
@mosiac1 mosiac1 force-pushed the feat/refactor/plugin-impls branch 3 times, most recently from bc398e6 to 801e9a1 Compare April 2, 2025 14:31
@mosiac1 mosiac1 force-pushed the feat/refactor-remote branch from 00c4af6 to abd2f9d Compare April 2, 2025 14:40
@mosiac1 mosiac1 force-pushed the feat/refactor-remote branch from 2dc5219 to 7c495ea Compare April 23, 2025 15:46
@mosiac1 mosiac1 marked this pull request as draft April 23, 2025 16:06
@mosiac1 mosiac1 force-pushed the feat/refactor/plugin-impls branch from 801e9a1 to c4ec16b Compare May 8, 2025 16:16
@mosiac1 mosiac1 changed the base branch from feat/refactor-remote to main May 8, 2025 16:17
@mosiac1 mosiac1 force-pushed the feat/refactor/plugin-impls branch from c4ec16b to 6547f3a Compare May 15, 2025 17:43
@mosiac1 mosiac1 marked this pull request as ready for review May 15, 2025 17:43
@mosiac1 mosiac1 force-pushed the feat/refactor/plugin-impls branch from 6547f3a to 85a33f4 Compare May 15, 2025 17:50
private String accessKey;
private String secretKey;

@NotNull
Copy link
Contributor

Choose a reason for hiding this comment

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

The annotations can be moved to the fields

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In all other Airlift conflig classes we use the annotations on getters

this.requestQueryFields = config.getRequestFields();
this.objectMapper = requireNonNull(objectMapper, "objectMapper is null");
if (config.getCacheSize() > 0) {
this.cache = Optional.of(newBuilder()
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
this.cache = Optional.of(newBuilder()
this.cache = config.getCacheSize() > 0 ? ..... : Optional.empty();

We can use a ternary op

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That line is already pretty long, I think a ternary would make it more complex. I would like to avoid it

prepareGet().setUri(uriBuilder.build()).build(),
createFullJsonResponseHandler(responseCodec));
HttpStatus statusCode = HttpStatus.fromStatusCode(response.getStatusCode());
if (statusCode.family() != HttpStatus.Family.SUCCESSFUL) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the only valid response is when the both HttpStatus.Family.SUCCESSFUL and response.hasValue() are true, we can check for this first and then go into invalid scenarios.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a bit of personal preference, but i like function logic to go like

if (badCase) {
    ....
}
return goodCase

{
this.httpClient = requireNonNull(httpClient, "httpClient is null");
this.responseCodec = requireNonNull(responseCodec, "responseCodec is null");
this.endpoint = config.getEndpoint();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
this.endpoint = config.getEndpoint();
this.endpoint = requireNotNull(config.getEndpoint());

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This field cannot be null since its in a config class and its annotated @NotNull
We usually trust the config validation and don't re-do it.

this.httpClient = requireNonNull(httpClient, "httpClient is null");
this.responseCodec = requireNonNull(responseCodec, "responseCodec is null");
this.endpoint = config.getEndpoint();
this.requestQueryFields = config.getRequestFields();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
this.requestQueryFields = config.getRequestFields();
this.requestQueryFields = requireNonNull(config.getRequestFields());

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same as above

Added generic implementations for the RemoteS3ConnectionProvider interface: static, file and http.

Added a README for the file and http ones as those are a bit more complex.

Added more tests to dynamic RemoteS3Facade creation
@mosiac1 mosiac1 force-pushed the feat/refactor/plugin-impls branch from 85a33f4 to a662e45 Compare May 16, 2025 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants