# Copyright 2019 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
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.CloudTasks.V2.Model.RateLimits do
  @moduledoc """
  Rate limits. This message determines the maximum rate that tasks can be dispatched by a queue, regardless of whether the dispatch is a first task attempt or a retry. Note: The debugging command, RunTask, will run a task even if the queue has reached its RateLimits.

  ## Attributes

  *   `maxBurstSize` (*type:* `integer()`, *default:* `nil`) - Output only. The max burst size. Max burst size limits how fast tasks in queue are processed when many tasks are in the queue and the rate is high. This field allows the queue to have a high rate so processing starts shortly after a task is enqueued, but still limits resource usage when many tasks are enqueued in a short period of time. The [token bucket]( algorithm is used to control the rate of task dispatches. Each queue has a token bucket that holds tokens, up to the maximum specified by `max_burst_size`. Each time a task is dispatched, a token is removed from the bucket. Tasks will be dispatched until the queue's bucket runs out of tokens. The bucket will be continuously refilled with new tokens based on max_dispatches_per_second. Cloud Tasks will pick the value of `max_burst_size` based on the value of max_dispatches_per_second. For queues that were created or updated using `queue.yaml/xml`, `max_burst_size` is equal to [bucket_size]( Since `max_burst_size` is output only, if UpdateQueue is called on a queue created by `queue.yaml/xml`, `max_burst_size` will be reset based on the value of max_dispatches_per_second, regardless of whether max_dispatches_per_second is updated. 
  *   `maxConcurrentDispatches` (*type:* `integer()`, *default:* `nil`) - The maximum number of concurrent tasks that Cloud Tasks allows to be dispatched for this queue. After this threshold has been reached, Cloud Tasks stops dispatching tasks until the number of concurrent requests decreases. If unspecified when the queue is created, Cloud Tasks will pick the default. The maximum allowed value is 5,000. This field has the same meaning as [max_concurrent_requests in queue.yaml/xml](
  *   `maxDispatchesPerSecond` (*type:* `float()`, *default:* `nil`) - The maximum rate at which tasks are dispatched from this queue. If unspecified when the queue is created, Cloud Tasks will pick the default. * The maximum allowed value is 500. This field has the same meaning as [rate in queue.yaml/xml](

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :maxBurstSize => integer() | nil,
          :maxConcurrentDispatches => integer() | nil,
          :maxDispatchesPerSecond => float() | nil


defimpl Poison.Decoder, for: GoogleApi.CloudTasks.V2.Model.RateLimits do
  def decode(value, options) do
    GoogleApi.CloudTasks.V2.Model.RateLimits.decode(value, options)

defimpl Poison.Encoder, for: GoogleApi.CloudTasks.V2.Model.RateLimits do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)