internal static GoogleBigQueryAttribute GetAttributeByConfiguration(GoogleBigQueryAttribute googleBigQueryAttribute) { if (string.IsNullOrWhiteSpace(googleBigQueryAttribute.ConfigurationNodeName)) { return(googleBigQueryAttribute); } var credentialsString = Environment.GetEnvironmentVariable($"{googleBigQueryAttribute.ConfigurationNodeName}.{nameof(Credentials)}", EnvironmentVariableTarget.Process); var credentialsFileName = Environment.GetEnvironmentVariable($"{googleBigQueryAttribute.ConfigurationNodeName}.{nameof(CredentialsFileName)}", EnvironmentVariableTarget.Process); var projectId = Environment.GetEnvironmentVariable($"{googleBigQueryAttribute.ConfigurationNodeName}.{nameof(ProjectId)}", EnvironmentVariableTarget.Process); var datasetId = Environment.GetEnvironmentVariable($"{googleBigQueryAttribute.ConfigurationNodeName}.{nameof(DatasetId)}", EnvironmentVariableTarget.Process); var tableId = Environment.GetEnvironmentVariable($"{googleBigQueryAttribute.ConfigurationNodeName}.{nameof(TableId)}", EnvironmentVariableTarget.Process); GoogleBigQueryAttribute newGoogleBigQueryAttribute = null; if (string.IsNullOrWhiteSpace(credentialsFileName) && string.IsNullOrWhiteSpace(credentialsString)) { newGoogleBigQueryAttribute = new GoogleBigQueryAttribute(projectId, datasetId, tableId); } else { if (string.IsNullOrWhiteSpace(credentialsString)) { newGoogleBigQueryAttribute = new GoogleBigQueryAttribute(credentialsFileName, projectId, datasetId, tableId); } else { var credentials = System.Text.Encoding.UTF8.GetBytes(credentialsString); newGoogleBigQueryAttribute = new GoogleBigQueryAttribute(credentials, projectId, datasetId, tableId); } } return(newGoogleBigQueryAttribute); }
public static BigQueryService GetPublisherClient(GoogleBigQueryAttribute googleBigQueryAttribute, Type itemType) { var key = $"{googleBigQueryAttribute.GetHashCode()}-{itemType.GetType().FullName}".GetHashCode(); if (publisherClientCache.ContainsKey(key)) { var expiringBigQueryService = publisherClientCache[key]; if ((DateTime.UtcNow - expiringBigQueryService.CreatedUtc).TotalHours > 1) { var bigQueryService = new BigQueryService(googleBigQueryAttribute, itemType); var expiringBigQueryService1 = new ExpiringBigQueryService(DateTime.UtcNow, bigQueryService); publisherClientCache.AddOrUpdate(key, expiringBigQueryService1, (newkey, oldValue) => expiringBigQueryService1); return(bigQueryService); } return(expiringBigQueryService.BigQueryService); } else { var bigQueryService = new BigQueryService(googleBigQueryAttribute, itemType); var expiringBigQueryService = new ExpiringBigQueryService(DateTime.UtcNow, bigQueryService); publisherClientCache.AddOrUpdate(key, expiringBigQueryService, (newkey, oldValue) => expiringBigQueryService); return(bigQueryService); } }
public BigQueryService(GoogleBigQueryAttribute googleBigQueryAttribute, Type itemType) { this.googleBigQueryAttribute = GoogleBigQueryAttribute.GetAttributeByConfiguration(googleBigQueryAttribute); if (itemType != null) { (this.tableSchema, this.dictionaryOfProperties) = TableSchemaBuilderService.GetTableSchema(itemType); } }
public AsyncCollector(GoogleBigQueryAttribute googleBigQueryAttribute) { this.googleBigQueryAttribute = googleBigQueryAttribute; }