Skip to content

cleanup(gax): rename paginator to stream#1611

Merged
dbolduc merged 1 commit intogoogleapis:mainfrom
dbolduc:paginator-into-stream
Mar 28, 2025
Merged

cleanup(gax): rename paginator to stream#1611
dbolduc merged 1 commit intogoogleapis:mainfrom
dbolduc:paginator-into-stream

Conversation

@dbolduc
Copy link
Member

@dbolduc dbolduc commented Mar 25, 2025

Noticed in #1541

https://rust-lang.github.io/api-guidelines/naming.html#ad-hoc-conversions-follow-as_-to_-into_-conventions-c-conv

My read on this is that we should use into_ because this is a cheap operation that consumes the underlying type. It is at a similar level of abstraction, but I think the "cheap" part is why into_ fits better than to_.

This is not a break, because the renamed APIs (added in #1466) have not been released yet.

@codecov
Copy link

codecov bot commented Mar 25, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.72%. Comparing base (457d0ff) to head (0c08b5b).
Report is 23 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1611   +/-   ##
=======================================
  Coverage   95.72%   95.72%           
=======================================
  Files          43       43           
  Lines        1823     1823           
=======================================
  Hits         1745     1745           
  Misses         78       78           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dbolduc dbolduc marked this pull request as ready for review March 25, 2025 15:58
///
/// This API is gated by the `unstable-stream` feature.
pub fn to_stream(self) -> impl futures::Stream<Item = Result<T, E>> + Unpin {
pub fn into_stream(self) -> impl futures::Stream<Item = Result<T, E>> + Unpin {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does the same argument apply to:

fn to_stream(self) -> impl futures::Stream<Item = PollingResult<ResponseType, MetadataType>>

??

If not: what happens if we ever change the implementation of Paginator? Do we need to rename this function?

Copy link
Member Author

Choose a reason for hiding this comment

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

If not: what happens if we ever change the implementation of Paginator? Do we need to rename this function?

Good point.

Changing the implementation from being cheap to being expensive (for example) would be an unwanted behavior change. The name into_* enforces this (albeit very softly).

Does the same argument apply to lro::Poller::to_stream ?

Mostly. My plan was to rename that in a separate PR.

It is weirder in that it is a trait, which could have any implementation1. I think the name into_* suggests things we want about the implementation though.

Footnotes

  1. I need to consider https://github.com/googleapis/google-cloud-rust/issues/1609#issuecomment-2751674686 to see if we can seal the trait, and thus be confident that it has only one implementation, and that into_* is appropriate.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am worried about the naming changing back and forth. It may be better to give this a non-standard name so people do not have expectations about performance, even if it is sealed.

With that said, I had forgotten you may be waiting for an answer. Approved so you can make progress, but I am going to open a tracking bug.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not blocked on this PR going through. It does not have to go through.

I am going to open a tracking bug.

I think we should make a decision now and probably never look back.

My vote is for into_stream. I think that is the best name at this time.

Copy link
Collaborator

Choose a reason for hiding this comment

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

My vote is for into_stream. I think that is the best name at this time.

Since it also applies to Poller, I think I buy that.

@dbolduc dbolduc merged commit 4fa3e62 into googleapis:main Mar 28, 2025
20 checks passed
@dbolduc dbolduc deleted the paginator-into-stream branch March 28, 2025 18:46
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.

2 participants