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

Decrease pub visibility of scylla-cql definitions #933

Merged
merged 4 commits into from
Mar 28, 2024

Conversation

muzarski
Copy link
Contributor

@muzarski muzarski commented Feb 15, 2024

Motivation

Some definitions in scylla-cql crate need to be public, so the scylla crate can make use of them. However, currently all of the definitions are implicitly re-exported outside and can be seen by the driver users. The idea is to explicitly re-export the types/functions that should be visible outside (and leave the rest of the public definitions for the internal usage of scylla crate).

re-exported types

The main difficulty was to decide on what types should be re-exported publicly. The types that got re-exported can be seen in the documentation (cargo doc --open).

Error types

I wasn't sure whether error types such as scylla_cql::frame::frame_errors::FrameError should be public. As of now, they are left public but this can be further discussed.

Pre-review checklist

  • I have split my patch into logically separate commits.
  • All commit messages clearly explain what they change and why.
  • I added relevant tests for new features and bug fixes.
  • All commits compile, pass static checks and pass test.
  • PR description sums up the changes and reasons why they should be introduced.
  • I have provided docstrings for the public items that I want to introduce.
  • I have adjusted the documentation in ./docs/source/.
  • I added appropriate Fixes: annotations to PR description.

Copy link
Collaborator

@wprzytula wprzytula left a comment

Choose a reason for hiding this comment

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

Looks like a careful step in the right direction.
This PR only hides some definitions, without modyfing any import paths - which is good from the aspect of not breaking existing code.

For comparison, please see my approach to module refactor, which additionally restructures import paths in a way that makes more sense for me:
https://github.com/wprzytula/scylla-rust-driver/blob/restructure-modules/scylla/src/cql/mod.rs

@wprzytula wprzytula added the API-stability Part of the effort to stabilize the API label Mar 13, 2024
@wprzytula wprzytula added this to the 1.0.0 milestone Mar 13, 2024
@wprzytula wprzytula added the waiting-on-author Waiting for a response from issue/PR author label Mar 27, 2024
@Lorak-mmk Lorak-mmk removed the waiting-on-author Waiting for a response from issue/PR author label Mar 27, 2024
@Lorak-mmk
Copy link
Collaborator

@muzarski we can merge after you rebase on main (there is a conflict)

Pub re-exported the structs of scylla_cql::frame module
and its submodules that contain any of the symbols that
should be exposed publicly.

This means that the following submodules will be private:
- scylla_cql::frame::request
- scylla_cql::frame::server_event_type
- scylla_cql::frame::protocol_features
Re-exported the Consistency and SerialConsistency types.

Hidden utility functions such as `read/write_int`.
pub re-exported submodules that contain publicly used types.

The submodules re-exported as pub:
- scylla_cql::frame::response::cql_to_rust
- scylla_cql::frame::response::result

The submodules re-exported as pub(crate):
- scylla_cql::frame::response::authenticate
- scylla_cql::frame::response::error
- scylla_cql::frame::response::event
- scylla_cql::frame::response::supported
Re-exported types that should be exposed to users.
Re-exported types:
- ColumnSpec
- ColumnType
- CqlValue
- PartitionKeyIndex
- Row
- TableSpec

Note for reviewers: As mentioned in
scylladb#925 (comment),
we should not expose the `PreparedMetadata` structure. I believe
the same applies to `ResultMetadata`. That's why I decided not to
re-export them.
@muzarski
Copy link
Contributor Author

v2: resolved conflicts with main

Copy link

cargo semver-checks found no API-breaking changes in this PR! 🎉🥳
Checked commit: 73bbf87

Comment on lines +118 to +121
pub(crate) use scylla_cql::frame::response::*;

pub mod result {
pub(crate) use scylla_cql::frame::response::result::*;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure if I'm happy with the glob imports here. Being pub(crate) ones, they are relatively benign though.

@Lorak-mmk Lorak-mmk merged commit 8155fd4 into scylladb:main Mar 28, 2024
11 checks passed
@Lorak-mmk Lorak-mmk mentioned this pull request May 9, 2024
@muzarski muzarski deleted the decrease-pub-usage branch October 29, 2024 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API-stability Part of the effort to stabilize the API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants