-
Notifications
You must be signed in to change notification settings - Fork 0
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
fix: topics subscription resiliency #38
Conversation
} | ||
case TopicSubscribeError(): | ||
print("Subscribe error: ${sub.errorCode} ${sub.message}"); | ||
} | ||
|
||
// unsubscribing should not affect the topic client's ability |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is really useful, I imagine it was great as almost a TDD approach to working on this feature. In the long run though, we probably want to keep these examples as simple as humanly possible, so we might want to move this to an "advanced topics example" or something.
Not in any way, shape, or form a blocker for this PR :) just calling it out as something to be aware of for future touching up on these examples/docs and stuff.
@@ -30,6 +70,10 @@ class TopicSubscription implements TopicSubscribeResponse { | |||
} | |||
return null; | |||
} | |||
|
|||
void unsubscribe() async { | |||
await _stream.cancel(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this lgtm! I didn't pull it down and test it or anything, we should definitely have a second person test it next week, but definitely looks good to merge for now!
@@ -21,7 +23,7 @@ class TopicClient implements ITopicClient { | |||
TopicClient( | |||
CredentialProvider credentialProvider, TopicConfiguration configuration) | |||
: _pubsubClient = ClientPubsub(credentialProvider, configuration) { | |||
_logger.level = determineLoggerLevel(configuration.logLevel); | |||
// _logger.level = determineLoggerLevel(configuration.logLevel); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
errant comments, maybe remove in a later PR.
|
||
@override | ||
void close() { | ||
_pubsubClient.close(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:thu
cc @bruuuuuuuce merging it now but we should loop back and test it more thoroughly |
addresses #27
if subscription was not cancelled explicitly using the
unsubscribe
method on theTopicSubscription
class, the topic client will attempt to re-establish a connection.adds a grpc manager class for the topic client so we can easily extend the internal topic client to use multiple grpc connections in the future if needed.
manually tested and confirmed that:
unsubscribe
will cancel the subscription and still allow the topic client to subscribe to a topic afterwards