Sha256: b77237b657a748a8c1333b8b67483b232e82d994fe6ab61a48b6ec17bcaa2c1b

Contents?: true

Size: 1.61 KB

Versions: 4

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

# Copyright 2021 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.

module Gapic
  module Presenters
    ##
    # A presenter for grpc service config.
    #
    class ServiceConfigPresenter
      def initialize grpc_service_config
        @grpc_service_config = grpc_service_config
      end

      attr_reader :grpc_service_config

      def retry_policy_fields
        elems = []
        retry_policy = grpc_service_config&.retry_policy
        if retry_policy&.initial_delay_seconds
          elems << "initial_delay: #{Gapic::FormattingUtils.format_number retry_policy.initial_delay_seconds}"
        end
        if retry_policy&.max_delay_seconds
          elems << "max_delay: #{Gapic::FormattingUtils.format_number retry_policy.max_delay_seconds}"
        end
        if retry_policy&.multiplier
          elems << "multiplier: #{Gapic::FormattingUtils.format_number retry_policy.multiplier}"
        end
        if retry_policy&.status_codes
          elems << "retry_codes: #{retry_policy.status_codes}"
        end
        elems.empty? ? "{}" : "{\n  #{elems.join ', '}\n}"
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gapic-generator-0.10.1 lib/gapic/presenters/service_config_presenter.rb
gapic-generator-0.10.0 lib/gapic/presenters/service_config_presenter.rb
gapic-generator-0.9.1 lib/gapic/presenters/service_config_presenter.rb
gapic-generator-0.9.0 lib/gapic/presenters/service_config_presenter.rb