Skip to content

Conversation

@lizardoluis
Copy link
Collaborator

@lizardoluis lizardoluis commented Jul 16, 2024

This PR breaks the object store creation logic into a separate crate object_store_factory.

The crate allows building object stores from various configurations and URLs. The key updates include:

  • build_object_store_from_config function:

    • Purpose: Constructs an object store based on a given scheme (Memory, Local, AmazonS3, GoogleCloudStorage) and configuration settings.
    • Details: Uses specific modules (memory, local, aws, google) to build the appropriate object store.
  • build_object_store_from_opts function:

    • Purpose: Constructs an object store based on a URL and associated configuration options.
    • Details: Parses the URL to determine the scheme and adjusts options accordingly. Supports Amazon S3 and Google Cloud Storage schemes with specific option modifications.

@lizardoluis lizardoluis self-assigned this Jul 16, 2024
@lizardoluis lizardoluis requested review from gruuya and mildbyte and removed request for gruuya July 16, 2024 08:12
@lizardoluis lizardoluis force-pushed the BEAC-167-object-store branch from 1c3a92f to 6f9ea5e Compare July 16, 2024 09:44
@lizardoluis lizardoluis force-pushed the BEAC-167-object-store branch from 6f9ea5e to d9a49f1 Compare July 24, 2024 14:09
@lizardoluis lizardoluis marked this pull request as ready for review July 24, 2024 14:31
@lizardoluis lizardoluis changed the title BEAC-167: Create a crate inside of Seafowl that instantiates an object store based on URL, settings and environment variables BEAC-167: Create a crate that instantiates an object store based on URL, settings and environment variables Jul 24, 2024
}

#[derive(Deserialize, Debug, PartialEq, Eq, Clone)]
pub struct S3 {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should re-use the configs from your crate here (same for GCS, etc.).

Copy link
Collaborator Author

@lizardoluis lizardoluis Jul 25, 2024

Choose a reason for hiding this comment

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

@gruuya This change will be a snow ball as these structs are used in several parts of the code. Would be ok to address this change in a separate PR, so that we reduce the complexity of it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yup, sounds good.

Comment on lines 104 to 112
("AWS_ACCESS_KEY_ID", AmazonS3ConfigKey::AccessKeyId),
("AWS_SECRET_ACCESS_KEY", AmazonS3ConfigKey::SecretAccessKey),
("AWS_DEFAULT_REGION", AmazonS3ConfigKey::Region),
("AWS_ENDPOINT", AmazonS3ConfigKey::Endpoint),
("AWS_SESSION_TOKEN", AmazonS3ConfigKey::Token),
(
"AWS_CONTAINER_CREDENTIALS_RELATIVE_URI",
AmazonS3ConfigKey::ContainerCredentialsRelativeUri,
),
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the first elements are redundant, since you can get them from the second element(s): config_key.as_ref().to_uppercase()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I changed it completely to be more robust and accept more variables. I implemented something similar to their from_env() algorithm like here https://docs.rs/object_store/latest/src/object_store/aws/builder.rs.html#429-443.

Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

/// # Errors
///
/// * If the URL scheme is unsupported or there is an error parsing the URL or options, an error is returned.
pub async fn build_object_store_from_opts(
Copy link
Contributor

Choose a reason for hiding this comment

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

This should also support building a local FS object store using the file:// protocol

Copy link
Contributor

Choose a reason for hiding this comment

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

Should be resolve now with 26bb61e.

@lizardoluis lizardoluis merged commit 276bc64 into main Jul 26, 2024
@lizardoluis lizardoluis deleted the BEAC-167-object-store branch July 26, 2024 13:26
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.

4 participants