/// <inheritdoc/> protected internal override object ExecuteScalarWithRetry(SpannerCommand command) { GaxPreconditions.CheckState(!Disposed, "This transaction has been disposed"); command.Transaction = SpannerTransaction; return(command.ExecuteScalar()); }
/// <summary> /// Gets the value of the specified column as a pure Protobuf type. /// </summary> /// <param name="i">The index of the column whose value will be returned.</param> /// <returns>The raw protobuf as a <see cref="Value"/>.</returns> /// <exception cref="InvalidOperationException">The reader is not currently positioned on a valid row.</exception> public Value GetJsonValue(int i) { GaxPreconditions.CheckState(_rowValid, "The reader is not currently positioned on a valid row."); return(_innerList[i]); }
/// <inheritdoc/> public override void ActivateOptions() { // Validate configuration GaxPreconditions.CheckState(string.IsNullOrWhiteSpace(CredentialFile) || string.IsNullOrWhiteSpace(CredentialJson), $"{nameof(CredentialFile)} and {nameof(CredentialJson)} must not both be set."); GaxPreconditions.CheckState(LogId != null, $"{nameof(LogId)} must be set."); GaxPreconditions.CheckState(MaxUploadBatchSize > 0, $"{nameof(MaxUploadBatchSize)} must be > 0"); GaxPreconditions.CheckEnumValue <LocalQueueType>(LocalQueueType, nameof(LocalQueueType)); base.ActivateOptions(); // Initialise services if not already initialised for testing _client = _client ?? BuildLoggingServiceClient(); _scheduler = _scheduler ?? SystemScheduler.Instance; _clock = _clock ?? SystemClock.Instance; _platform = _platform ?? Platform.Instance(); // Normalize string configuration ResourceType = string.IsNullOrWhiteSpace(ResourceType) ? null : ResourceType; ProjectId = string.IsNullOrWhiteSpace(ProjectId) ? null : ProjectId; LogId = string.IsNullOrWhiteSpace(LogId) ? null : LogId; switch (LocalQueueType) { case LocalQueueType.Memory: GaxPreconditions.CheckState(MaxMemoryCount > 0 || MaxMemorySize > 0, $"Either {nameof(MaxMemoryCount)} or {nameof(MaxMemorySize)} must be configured to be > 0"); break; default: throw new InvalidOperationException($"Invalid {nameof(Log4Net.LocalQueueType)}: '{LocalQueueType}'"); } GaxPreconditions.CheckState(ServerErrorBackoffDelaySeconds >= 1, $"{nameof(ServerErrorBackoffDelaySeconds)} must be >= 1 second."); GaxPreconditions.CheckState(ServerErrorBackoffMultiplier > 1.1999999, $"{nameof(ServerErrorBackoffMultiplier)} must be >= 1.2"); GaxPreconditions.CheckState(ServerErrorBackoffMaxDelaySeconds >= 20, $"{nameof(ServerErrorBackoffMaxDelaySeconds)} must be >= 20 seconds."); ActivateLogIdAndResource(); switch (LocalQueueType) { case LocalQueueType.Memory: _logQ = new MemoryLogQueue(MaxMemorySize, MaxMemoryCount); break; default: throw new InvalidOperationException($"Invalid {nameof(Log4Net.LocalQueueType)}: '{LocalQueueType}'"); } _initIdTask = Task.Run(_logQ.GetPreviousExecutionIdAsync); var logsLostWarningEntry = new LogEntry { TextPayload = s_logsLostWarningMessage, Severity = LogSeverity.Warning, LogName = _logName, Resource = _resource, // Patterns included in custom labels will not be used in this "logs lost" entry. // The pattern itself will be logged, regardless of the "UsePatternWithinCustomLabels" setting. // This is acceptable as most patterns will be irrelevant in this context. Labels = { _customLabels.ToDictionary(x => x.Key, x => x.Value) }, }; var serverErrorBackoffSettings = new BackoffSettings( delay: TimeSpan.FromSeconds(ServerErrorBackoffDelaySeconds), delayMultiplier: ServerErrorBackoffMultiplier, maxDelay: TimeSpan.FromSeconds(ServerErrorBackoffMaxDelaySeconds) ); _logUploader = new LogUploader( _client, _scheduler, _clock, _logQ, logsLostWarningEntry, MaxUploadBatchSize, serverErrorBackoffSettings); if (_usePatternWithinCustomLabels) { // Initialize a pattern layout for each custom label. _customLabelsPatterns = _customLabels.Select(x => new CustomLabelPattern(x.Key, new PatternLayout(x.Value))).ToArray(); } _isActivated = true; }
partial void Modify_MutateRowsRequest(ref MutateRowsRequest request, ref CallSettings settings) { GaxPreconditions.CheckState(request.IsIdempotent(), "Non-idempotent MutateRows requests are not allowed. Specify a version with all SetCell mutations."); ApplyResourcePrefixHeader(ref settings, request.TableName); }
/// <summary> /// Validates that at most one of the given values is not null. /// </summary> /// <param name="message">The message if the condition is violated.</param> /// <param name="values">The values to check for nullity.</param> /// <exception cref="InvalidOperationException">More than one value is null.</exception> protected void ValidateAtMostOneNotNull(string message, params object[] values) { int notNull = values.Count(v => v != null); GaxPreconditions.CheckState(notNull < 2, message); }