removePublisherClient function

Future<void> removePublisherClient({
  1. Object? credentials,
  2. String? userAgent,
  3. String? projectId,
})

Removes a publisher client from the current event loop's cache and closes it.

Implementation

Future<void> removePublisherClient({
  Object? credentials,
  String? userAgent,
  String? projectId,
}) async {
  final LinkedHashMap<_CacheKey, _CacheEntry> loopCache =
      _publisherClientCache.get();
  final String finalUserAgent = _getFinalUserAgent(userAgent);
  final _CacheKey cacheKey = _getCacheKey(
    credentials: credentials,
    finalUserAgent: finalUserAgent,
    projectId: projectId,
  );

  final _CacheEntry? entry = loopCache.remove(cacheKey);
  if (entry != null) {
    await _closeClient(entry.$1);
  }
}