Exemple #1
0
        async Task IListener.StartAsync(CancellationToken cancellationToken)
        {
retry:

            using (var scope = logger.BeginScope("IListener"))
            {
                var eventId = new Microsoft.Extensions.Logging.EventId(1);
                logger.LogInformation("StartAsync");

                try
                {
                    var credentials = CreatorService.GetCredentials(triggerAttribute);
                    var tasks       = Enumerable.Range(1, triggerAttribute.NrListeners).Select(c => StartListener(credentials, cancellationToken));

                    await Task.WhenAll(tasks);
                }
                catch (Exception ex)
                {
                    logger.LogError(ex, ex.Message);
                }
            }

            System.Threading.Thread.Sleep(30 * 1000);
            goto retry;
        }
        internal static TransparentApiClient.Google.PubSub.V1.Resources.Topics GetTopicsClient(GooglePubSubAttribute googlePubSubAttribute)
        {
            var key = googlePubSubAttribute.GetHashCode();

            if (publisherClientV2Cache.ContainsKey(key))
            {
                return(publisherClientV2Cache[key]);
            }
            else
            {
                var credentials     = CreatorService.GetCredentials(googlePubSubAttribute);
                var publisherClient = new TransparentApiClient.Google.PubSub.V1.Resources.Topics(credentials);
                publisherClientV2Cache.AddOrUpdate(key, publisherClient, (newkey, oldValue) => publisherClient);
                return(publisherClient);
            }
        }