Skip to content

Commit f17e561

Browse files
Changing parameters names in CosmosPagedFlux back to original names (#45087)
* Initial draft * Added unit test * Update CosmosClientBuilderTest.java * Update CosmosClientBuilderTest.java * Adding simple extensibility for CosmosPagedFlux * Refactoring the refactoring to avoid LINT errors * Update sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncDatabase.java Co-authored-by: Tomas Varon <[email protected]> * Reacting to code review feedback * Revert "Reacting to code review feedback" This reverts commit d54c91b. * Reapply "Reacting to code review feedback" This reverts commit 4f280d0. * Update CosmosAsyncClient.java * Update CosmosPagedFlux.java * Update CosmosPagedFlux.java * Renaming CosmosPagedFlux.createFromList to CosmosPagedFlux.fromList * Update CHANGELOG.md --------- Co-authored-by: Tomas Varon <[email protected]>
1 parent 41f647d commit f17e561

File tree

3 files changed

+45
-6
lines changed

3 files changed

+45
-6
lines changed

sdk/cosmos/azure-cosmos-tests/src/test/java/com/azure/cosmos/CosmosClientBuilderTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ public <T> CosmosPagedFlux<T> queryItems(SqlQuerySpec querySpec, CosmosQueryRequ
361361
CacheKey key = new CacheKey(classType.getCanonicalName(), querySpec);
362362
List<?> cachedResult = this.queryCache.get(key);
363363
if (cachedResult != null) {
364-
return CosmosPagedFlux.createFromList((List<T>)cachedResult, false);
364+
return CosmosPagedFlux.fromList((List<T>)cachedResult, false);
365365
}
366366

367367
return super

sdk/cosmos/azure-cosmos/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### 4.69.0-beta.1 (Unreleased)
44

55
#### Features Added
6+
* Added API to allow customers to wrap/extend `CosmosAsyncContainer` - [PR 43724](https://github.com/Azure/azure-sdk-for-java/pull/43724) and [PR 45087](https://github.com/Azure/azure-sdk-for-java/pull/45087)
67

78
#### Breaking Changes
89

sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/util/CosmosPagedFlux.java

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,64 @@ public class CosmosPagedFlux<T> extends ContinuablePagedFlux<String, T, FeedResp
3131
// Ensure there can only be package-internal implementations
3232
CosmosPagedFlux() {}
3333

34+
/**
35+
* Gets a {@link Flux} of {@link FeedResponse} starting at the first page.
36+
*
37+
* @return A {@link Flux} of {@link FeedResponse}.
38+
*/
3439
@Override
3540
public Flux<FeedResponse<T>> byPage() {
3641
throw new UnsupportedOperationException("Has to be overridden in child classes.");
3742
}
3843

44+
/**
45+
* Gets a {@link Flux} of {@link FeedResponse} beginning at the page identified by the given continuation token.
46+
*
47+
* @param continuationToken A continuation token identifying the page to select.
48+
* @return A {@link Flux} of {@link FeedResponse}.
49+
*/
3950
@Override
40-
public Flux<FeedResponse<T>> byPage(String s) {
51+
public Flux<FeedResponse<T>> byPage(String continuationToken) {
4152
throw new UnsupportedOperationException("Has to be overridden in child classes.");
4253
}
4354

55+
/**
56+
* Gets a {@link Flux} of {@link FeedResponse} starting at the first page requesting each page to contain a
57+
* number of elements equal to the preferred page size.
58+
* <p>
59+
* The service may or may not honor the preferred page size therefore the client <em>MUST</em> be prepared to handle
60+
* pages with different page sizes.
61+
*
62+
* @param preferredPageSize The preferred page size.
63+
* @return A {@link Flux} of {@link FeedResponse}.
64+
*/
4465
@Override
45-
public Flux<FeedResponse<T>> byPage(int i) {
66+
public Flux<FeedResponse<T>> byPage(int preferredPageSize) {
4667
throw new UnsupportedOperationException("Has to be overridden in child classes.");
4768
}
4869

70+
/**
71+
* Gets a {@link Flux} of {@link FeedResponse} beginning at the page identified by the given continuation token
72+
* requesting each page to contain the number of elements equal to the preferred page size.
73+
* <p>
74+
* The service may or may not honor the preferred page size therefore the client <em>MUST</em> be prepared to handle
75+
* pages with different page sizes.
76+
*
77+
* @param continuationToken A continuation token identifying the page to select.
78+
* @param preferredPageSize The preferred page size.
79+
* @return A {@link Flux} of {@link FeedResponse}.
80+
*/
4981
@Override
50-
public Flux<FeedResponse<T>> byPage(String s, int i) {
82+
public Flux<FeedResponse<T>> byPage(String continuationToken, int preferredPageSize) {
5183
throw new UnsupportedOperationException("Has to be overridden in child classes.");
5284
}
5385

86+
/**
87+
* Handle for invoking "side-effects" on each FeedResponse returned by CosmosPagedFlux
88+
*
89+
* @param newFeedResponseConsumer handler
90+
* @return CosmosPagedFlux instance with attached handler
91+
*/
5492
public CosmosPagedFlux<T> handle(Consumer<FeedResponse<T>> newFeedResponseConsumer) {
5593
throw new UnsupportedOperationException("Has to be overridden in child classes.");
5694
}
@@ -81,11 +119,11 @@ public void subscribe(CoreSubscriber<? super T> coreSubscriber) {
81119
* Creates an instance of a CosmosPagedFlux for mocking purposes or when injecting CosmosPagedFlux
82120
* instances from a different data source
83121
* @param items - the list of items to be returned
84-
* @param isChangeFeed - a flag incidcating whether the CosmsoPagedFluy will be returned from a change feed API
122+
* @param isChangeFeed - a flag indicating whether the CosmosPagedFlux will be returned from a change feed API
85123
* @return an instance of CosmosPagedFlux
86124
* @param <T> The type of the items
87125
*/
88-
public static <T> CosmosPagedFlux<T> createFromList(List<T> items, boolean isChangeFeed) {
126+
public static <T> CosmosPagedFlux<T> fromList(List<T> items, boolean isChangeFeed) {
89127
return new CosmosPagedFluxStaticListImpl<>(
90128
items,
91129
isChangeFeed

0 commit comments

Comments
 (0)