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

Remove/gofr dependency s3 #1324

Closed
wants to merge 19 commits into from
Closed

Conversation

Umang01-hash
Copy link
Member

@Umang01-hash Umang01-hash commented Dec 20, 2024

Pull Request Template

Description:

Checklist:

  • I have formatted my code using goimport and golangci-lint.
  • All new code is covered by unit tests.
  • This PR does not decrease the overall code coverage.
  • I have reviewed the code comments and documentation for clarity.

Thank you for your contribution!

aryanmehrotra
aryanmehrotra previously approved these changes Dec 24, 2024
@@ -41,7 +39,7 @@ type jsonReader struct {
}

// ReadAll reads either JSON or text files based on file extension and returns a corresponding RowReader.
Copy link
Contributor

Choose a reason for hiding this comment

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

It no longer returns a RowHeader, but an any

@@ -41,7 +39,7 @@ type jsonReader struct {
}

// ReadAll reads either JSON or text files based on file extension and returns a corresponding RowReader.
func (f *S3File) ReadAll() (file.RowReader, error) {
func (f *S3File) ReadAll() (any, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I have a problem with the any here

Can't you define an interface that jsonReader and csvReader would satisfy?

I don't know at least something with Next, Scan and other if needed.

My main problem is a fact an exported method returns any in its signature, but also unexported structures.

I'm not even sure someone will be able to use the code once refactored

Shouldn't you document things?

Copy link
Member Author

@Umang01-hash Umang01-hash Dec 30, 2024

Choose a reason for hiding this comment

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

@ccoVeille We can do it maybe but then also if the return type would be file.RowReader or something we have defined in GoFr then we can't remove GoFr's dependency from this datasource.

And even doing it with any is not working here.😐

Copy link
Contributor

Choose a reason for hiding this comment

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

Your problems is about dependency import cycle?

Or about depending on external sources, so it leads to add things to gofr go.mod ?

If it's the first one, the solution is often to add a new package where you will move the interface definitions. This package will depends on nothing inside gofr.

Then for compatibility purpose, you replace the existing type at gofr level by aliases to the one at package level.

But here, once again, I might have totally misunderstood what you are trying to achieve

Copy link
Member Author

Choose a reason for hiding this comment

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

@ccoVeille

Or about depending on external sources, so it leads to add things to gofr go.mod ?

We aim to externalize all the datasources. The code in the datasource packages shouldn't depend on GoFr, so we don't have to worry about updating GoFr versions in these packages. This approach also maintains modularity and helps in keeping our binary size light.

However, if we keep the interface definition anywhere inside GoFr, we would need to import it inside the datasource packages for return types, which we want to avoid.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, but having data sources that returns any seems a problem to me.

But maybe other users of gofr could tell what they think about it, maybe a discussion could happen on the discord server

Copy link
Contributor

Choose a reason for hiding this comment

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

Can't we move the file.RowHeader and other interface in data sources package?

Another solution is to duplicate the interface definitions which is acceptable.

Then unit tests can be added to validate interface are compatible

@Umang01-hash Umang01-hash changed the base branch from remove/gofr_dependency_ftp to development December 30, 2024 05:03
@Umang01-hash Umang01-hash dismissed aryanmehrotra’s stale review December 30, 2024 05:03

The base branch was changed.

@Umang01-hash
Copy link
Member Author

Closing this PR as of now.
Further options needs to be explored to make these datasources independent of GoFr.

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.

Remove datasources' dependency on GoFr
3 participants