<commit_before>﻿// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using Google.Api.Gax;
using Google.Api.Gax.Grpc;
using Google.Apis.Auth.OAuth2;
using Google.Cloud.PubSub.V1.Tasks;
using Google.Protobuf;
using Grpc.Auth;
using Grpc.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

// This class uses TaskHelper.ConfigureAwait, rather than directly calling .ConfigureAwait().
// When running in a non-test environment this indirectly calls .ConfigureAwait(false).
// Disable the ConfigureAwaitChecker warning:
#pragma warning disable CAC001
#pragma warning disable CAC002

namespace Google.Cloud.PubSub.V1
{
    /// <summary>
    /// A PubSub publisher that is associated with a specific <see cref="TopicName"/>.
    /// </summary>
    public abstract class PublisherClient
    {
        private static readonly GrpcChannelOptions s_unlimitedSendReceiveChannelOptions = GrpcChannelOptions.Empty
            .WithMaxReceiveMessageSize(-1)
            .WithMaxSendMessageSize(-1);

        // TODO: Logging

        /// <summary>
        /// Settings for the <see cref="PublisherClient"/>.
        /// </summary>
        public sealed class Settings
        {
            /// <summary>
            /// Create a new instance.
            /// </summary>
            public Settings() { }

            internal Settings(Settings other)
            {
                BatchingSettings = other.BatchingSettings;
                Scheduler = other.Scheduler;
                EnableMessageOrdering = other.EnableMessageOrdering;
            }

            /// <summary>
            /// <see cref="BatchingSettings"/> that control how messages are batched when sending.
            /// If <c>null</c>, defaults to <see cref="DefaultBatchingSettings"/>.<commit_msg>fix(PubSub): Increased grpc.max_metadata_size value to 4 M.B.<commit_after>﻿// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using Google.Api.Gax;
using Google.Api.Gax.Grpc;
using Google.Apis.Auth.OAuth2;
using Google.Cloud.PubSub.V1.Tasks;
using Google.Protobuf;
using Grpc.Auth;
using Grpc.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

// This class uses TaskHelper.ConfigureAwait, rather than directly calling .ConfigureAwait().
// When running in a non-test environment this indirectly calls .ConfigureAwait(false).
// Disable the ConfigureAwaitChecker warning:
#pragma warning disable CAC001
#pragma warning disable CAC002

namespace Google.Cloud.PubSub.V1
{
    /// <summary>
    /// A PubSub publisher that is associated with a specific <see cref="TopicName"/>.
    /// </summary>
    public abstract class PublisherClient
    {
        private static readonly GrpcChannelOptions s_unlimitedSendReceiveChannelOptions = GrpcChannelOptions.Empty
            .WithMaxReceiveMessageSize(-1)
            .WithMaxSendMessageSize(-1)
            // Set max metadata size to 4 MB i.e., 4194304 bytes.
            .WithCustomOption("grpc.max_metadata_size", 4194304);

        // TODO: Logging

        /// <summary>
        /// Settings for the <see cref="PublisherClient"/>.
        /// </summary>
        public sealed class Settings
        {
            /// <summary>
            /// Create a new instance.
            /// </summary>
            public Settings() { }

            internal Settings(Settings other)
            {
                BatchingSettings = other.BatchingSettings;
                Scheduler = other.Scheduler;
                EnableMessageOrdering = other.EnableMessageOrdering;
            }

            /// <summary>
            /// <see cref="BatchingSettings"/> that control how messages are batched when sending.
            /// If <c>null</c>, defaults to <see cref="DefaultBatchingSettings"/>.
{'fraction_non_alphanumeric': 0.09819068916446433, 'fraction_numerical': 0.010977841024598495, 'mean_word_length': 2.5703918722786647, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1373844', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1247, 'n_words': 441}