-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: topics subscription resiliency (#38)
* fix: topics subscription resiliency * comment out logging config in topic client * add topic grpc manager and unsubscribe method * edit example, dart analyze
- Loading branch information
Showing
5 changed files
with
157 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'package:client_sdk_dart/client_sdk_dart.dart'; | ||
import 'package:client_sdk_dart/generated/cachepubsub.pbgrpc.dart'; | ||
import 'package:grpc/grpc.dart'; | ||
import 'package:logging/logging.dart'; | ||
|
||
class TopicGrpcManager { | ||
late final ClientChannel _channel; | ||
late final PubsubClient _client; | ||
final _logger = Logger('MomentoTopicClient'); | ||
|
||
TopicGrpcManager(CredentialProvider credentialProvider) { | ||
_channel = ClientChannel(credentialProvider.cacheEndpoint); | ||
_client = PubsubClient(_channel, | ||
options: CallOptions(metadata: { | ||
'authorization': credentialProvider.apiKey, | ||
'agent': 'dart:0.1.0' | ||
})); | ||
} | ||
|
||
PubsubClient get client => _client; | ||
ClientChannel get channel => _channel; | ||
|
||
void close() { | ||
try { | ||
_channel.shutdown(); | ||
} catch (e) { | ||
_logger.warning("Error shutting down channel: $e"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters