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

feat: reconnect topic subscriptions on error #478

Merged
merged 4 commits into from
Sep 8, 2023
Merged

Conversation

nand4011
Copy link
Contributor

@nand4011 nand4011 commented Sep 8, 2023

Instead of returning an error message, attempt to reconnect to a topic on error by remaking the subscription.

Instead of returning an error message, attempt to reconnect to a topic
on error by remaking the subscription.
return _logger.LogTraceTopicRequestSuccess(RequestTypeTopicSubscribe, cacheName, topicName,
response);
}

private async ValueTask<TopicMessage?> GetNextRelevantMessageFromGrpcStreamAsync(AsyncServerStreamingCall<_SubscriptionItem> subscription,
CancellationToken cancellationToken, string cacheName, string topicName)
private class SubscriptionWrapper : IDisposable
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't do this since I wanted to keep the pr surface as small as possible, but what are people's thoughts on making this the IAsyncEnumerator that the subscription response returns?
https://github.com/momentohq/client-sdk-dotnet/blob/main/src/Momento.Sdk/Responses/TopicSubscribeResponse.cs#L67
That would mean the topic is only actually subscribed to while the enumerator is in use, but it feels like a more simple layer to encapsulate this grpc logic.

Copy link
Member

Choose a reason for hiding this comment

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

If that feels more natural for DotNet users then I think be cool to start with that. I'm not the most experienced in dotnet though be good get @kvcache and also maybe ask a few of our customers in slack who use dotnet what they think. Can DM you with few good targets. Also ok w/ me starting here and fast following w/ wrapper or change to add this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There will be no user facing change, but it would make the subscription response object cleaner.

Copy link
Contributor

@kvcache kvcache left a comment

Choose a reason for hiding this comment

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

looks reasonable to me

@nand4011 nand4011 merged commit e459101 into main Sep 8, 2023
7 checks passed
@nand4011 nand4011 deleted the topics-reconnect branch September 8, 2023 21:13
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.

3 participants