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

[Preview] Change Feed Processor: Refactors manual checkpoint API #2488

Merged
merged 21 commits into from
Jun 3, 2021

Conversation

ealsur
Copy link
Member

@ealsur ealsur commented May 20, 2021

Based on the feedback on #2331 on the preview API, it would be better for the Manual Checkpoint API to be slightly refactored.

Current API is:

// Adds support for manual checkpoint on the typed API
public delegate Task ChangeFeedHandlerWithManualCheckpoint<T>(
	ChangeFeedProcessorContext context,
	IReadOnlyCollection<T> changes,
	Func<Task<(bool isSuccess, Exception error)>> tryCheckpointAsync,
	CancellationToken cancellationToken);

// Adds supports for manual checkpointing with stream handling
public delegate Task ChangeFeedStreamHandlerWithManualCheckpoint(
	ChangeFeedProcessorContext context,
	Stream changes,
	Func<Task<(bool isSuccess, Exception error)>> tryCheckpointAsync,
	CancellationToken cancellationToken);

Proposed API:

// Adds support for manual checkpoint on the typed API
public delegate Task ChangeFeedHandlerWithManualCheckpoint<T>(
	ChangeFeedProcessorContext context,
	IReadOnlyCollection<T> changes,
	Func<Task> checkpointAsync,
	CancellationToken cancellationToken);

// Adds supports for manual checkpointing with stream handling
public delegate Task ChangeFeedStreamHandlerWithManualCheckpoint(
	ChangeFeedProcessorContext context,
	Stream changes,
	Func<Task> checkpointAsync,
	CancellationToken cancellationToken);

The change is on the checkpoint delegate.

The reasoning behind the change is that Task already exposes an exception if it fails. So the Try signature returning a bool and Exception is ambiguous because the Task itself could also capture an exception.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Please follow the required format: "[Internal] Category: (Adds|Fixes|Refactors|Removes) Description"

Internal should be used for PRs that have no customer impact. This flag is used to help generate the changelog to know which PRs should be included. Examples:
Diagnostics: Adds GetElapsedClientLatency to CosmosDiagnostics
PartitionKey: Fixes null reference when using default(PartitionKey)
[v4] Client Encryption: Refactors code to external project
[Internal] Query: Adds code generator for CosmosNumbers for easy additions in the future.

@ealsur ealsur changed the title [Preview] Change Feed Processor: Changes manual checkpoint API [Preview] Change Feed Processor: Refactors manual checkpoint API May 20, 2021
@github-actions github-actions bot dismissed their stale review May 20, 2021 17:41

All good!

j82w
j82w previously approved these changes May 26, 2021
@j82w
Copy link
Contributor

j82w commented May 26, 2021

@kirankumarkolli and @FabianMeiswinkel please take a look at the API changes

Copy link
Member

@FabianMeiswinkel FabianMeiswinkel left a comment

Choose a reason for hiding this comment

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

LGTM except for NITs where try/catch could be removed completely

@kirankumarkolli
Copy link
Member

@ealsur , @j82w is it possible to cover these are breaking changes explicitly in preview release notes?

@ealsur ealsur dismissed stale reviews from FabianMeiswinkel and j82w via a83499f May 28, 2021 15:23
@j82w
Copy link
Contributor

j82w commented Jun 2, 2021

@ealsur , @j82w is it possible to cover these are breaking changes explicitly in preview release notes?

We can do a breaking changes section in the preview notes

@@ -1526,31 +1521,26 @@ public abstract class Container
/// </summary>
/// <param name="context">The context related to the changes.</param>
/// <param name="changes">The changes that happened.</param>
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be something a little more obvious like changesPayload?

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, in this case, it is actually the list (IReadOnlyCollection<T>) of changes that happened. Those changes in the collection could be inserts or updates, but they are still changes. Not sure how the word payload makes it more clear?

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, the current API that is GA uses changes as name, so I rather keep the same as we have no feedback that indicates the name brings confusion?

Copy link
Contributor

Choose a reason for hiding this comment

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

Then it's fine. It just seemed a little off that a stream would be called changes.

@ealsur ealsur merged commit cb23ff2 into master Jun 3, 2021
@ealsur ealsur deleted the users/ealsur/checkpointreview branch June 3, 2021 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants