{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.AppMesh.Types.VirtualGatewayHttpConnectionPool
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AppMesh.Types.VirtualGatewayHttpConnectionPool where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | An object that represents a type of connection pool.
--
-- /See:/ 'newVirtualGatewayHttpConnectionPool' smart constructor.
data VirtualGatewayHttpConnectionPool = VirtualGatewayHttpConnectionPool'
  { -- | Number of overflowing requests after @max_connections@ Envoy will queue
    -- to upstream cluster.
    VirtualGatewayHttpConnectionPool -> Maybe Natural
maxPendingRequests :: Prelude.Maybe Prelude.Natural,
    -- | Maximum number of outbound TCP connections Envoy can establish
    -- concurrently with all hosts in upstream cluster.
    VirtualGatewayHttpConnectionPool -> Natural
maxConnections :: Prelude.Natural
  }
  deriving (VirtualGatewayHttpConnectionPool
-> VirtualGatewayHttpConnectionPool -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VirtualGatewayHttpConnectionPool
-> VirtualGatewayHttpConnectionPool -> Bool
$c/= :: VirtualGatewayHttpConnectionPool
-> VirtualGatewayHttpConnectionPool -> Bool
== :: VirtualGatewayHttpConnectionPool
-> VirtualGatewayHttpConnectionPool -> Bool
$c== :: VirtualGatewayHttpConnectionPool
-> VirtualGatewayHttpConnectionPool -> Bool
Prelude.Eq, ReadPrec [VirtualGatewayHttpConnectionPool]
ReadPrec VirtualGatewayHttpConnectionPool
Int -> ReadS VirtualGatewayHttpConnectionPool
ReadS [VirtualGatewayHttpConnectionPool]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VirtualGatewayHttpConnectionPool]
$creadListPrec :: ReadPrec [VirtualGatewayHttpConnectionPool]
readPrec :: ReadPrec VirtualGatewayHttpConnectionPool
$creadPrec :: ReadPrec VirtualGatewayHttpConnectionPool
readList :: ReadS [VirtualGatewayHttpConnectionPool]
$creadList :: ReadS [VirtualGatewayHttpConnectionPool]
readsPrec :: Int -> ReadS VirtualGatewayHttpConnectionPool
$creadsPrec :: Int -> ReadS VirtualGatewayHttpConnectionPool
Prelude.Read, Int -> VirtualGatewayHttpConnectionPool -> ShowS
[VirtualGatewayHttpConnectionPool] -> ShowS
VirtualGatewayHttpConnectionPool -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VirtualGatewayHttpConnectionPool] -> ShowS
$cshowList :: [VirtualGatewayHttpConnectionPool] -> ShowS
show :: VirtualGatewayHttpConnectionPool -> String
$cshow :: VirtualGatewayHttpConnectionPool -> String
showsPrec :: Int -> VirtualGatewayHttpConnectionPool -> ShowS
$cshowsPrec :: Int -> VirtualGatewayHttpConnectionPool -> ShowS
Prelude.Show, forall x.
Rep VirtualGatewayHttpConnectionPool x
-> VirtualGatewayHttpConnectionPool
forall x.
VirtualGatewayHttpConnectionPool
-> Rep VirtualGatewayHttpConnectionPool x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep VirtualGatewayHttpConnectionPool x
-> VirtualGatewayHttpConnectionPool
$cfrom :: forall x.
VirtualGatewayHttpConnectionPool
-> Rep VirtualGatewayHttpConnectionPool x
Prelude.Generic)

-- |
-- Create a value of 'VirtualGatewayHttpConnectionPool' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'maxPendingRequests', 'virtualGatewayHttpConnectionPool_maxPendingRequests' - Number of overflowing requests after @max_connections@ Envoy will queue
-- to upstream cluster.
--
-- 'maxConnections', 'virtualGatewayHttpConnectionPool_maxConnections' - Maximum number of outbound TCP connections Envoy can establish
-- concurrently with all hosts in upstream cluster.
newVirtualGatewayHttpConnectionPool ::
  -- | 'maxConnections'
  Prelude.Natural ->
  VirtualGatewayHttpConnectionPool
newVirtualGatewayHttpConnectionPool :: Natural -> VirtualGatewayHttpConnectionPool
newVirtualGatewayHttpConnectionPool Natural
pMaxConnections_ =
  VirtualGatewayHttpConnectionPool'
    { $sel:maxPendingRequests:VirtualGatewayHttpConnectionPool' :: Maybe Natural
maxPendingRequests =
        forall a. Maybe a
Prelude.Nothing,
      $sel:maxConnections:VirtualGatewayHttpConnectionPool' :: Natural
maxConnections = Natural
pMaxConnections_
    }

-- | Number of overflowing requests after @max_connections@ Envoy will queue
-- to upstream cluster.
virtualGatewayHttpConnectionPool_maxPendingRequests :: Lens.Lens' VirtualGatewayHttpConnectionPool (Prelude.Maybe Prelude.Natural)
virtualGatewayHttpConnectionPool_maxPendingRequests :: Lens' VirtualGatewayHttpConnectionPool (Maybe Natural)
virtualGatewayHttpConnectionPool_maxPendingRequests = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewayHttpConnectionPool' {Maybe Natural
maxPendingRequests :: Maybe Natural
$sel:maxPendingRequests:VirtualGatewayHttpConnectionPool' :: VirtualGatewayHttpConnectionPool -> Maybe Natural
maxPendingRequests} -> Maybe Natural
maxPendingRequests) (\s :: VirtualGatewayHttpConnectionPool
s@VirtualGatewayHttpConnectionPool' {} Maybe Natural
a -> VirtualGatewayHttpConnectionPool
s {$sel:maxPendingRequests:VirtualGatewayHttpConnectionPool' :: Maybe Natural
maxPendingRequests = Maybe Natural
a} :: VirtualGatewayHttpConnectionPool)

-- | Maximum number of outbound TCP connections Envoy can establish
-- concurrently with all hosts in upstream cluster.
virtualGatewayHttpConnectionPool_maxConnections :: Lens.Lens' VirtualGatewayHttpConnectionPool Prelude.Natural
virtualGatewayHttpConnectionPool_maxConnections :: Lens' VirtualGatewayHttpConnectionPool Natural
virtualGatewayHttpConnectionPool_maxConnections = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VirtualGatewayHttpConnectionPool' {Natural
maxConnections :: Natural
$sel:maxConnections:VirtualGatewayHttpConnectionPool' :: VirtualGatewayHttpConnectionPool -> Natural
maxConnections} -> Natural
maxConnections) (\s :: VirtualGatewayHttpConnectionPool
s@VirtualGatewayHttpConnectionPool' {} Natural
a -> VirtualGatewayHttpConnectionPool
s {$sel:maxConnections:VirtualGatewayHttpConnectionPool' :: Natural
maxConnections = Natural
a} :: VirtualGatewayHttpConnectionPool)

instance
  Data.FromJSON
    VirtualGatewayHttpConnectionPool
  where
  parseJSON :: Value -> Parser VirtualGatewayHttpConnectionPool
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"VirtualGatewayHttpConnectionPool"
      ( \Object
x ->
          Maybe Natural -> Natural -> VirtualGatewayHttpConnectionPool
VirtualGatewayHttpConnectionPool'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"maxPendingRequests")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"maxConnections")
      )

instance
  Prelude.Hashable
    VirtualGatewayHttpConnectionPool
  where
  hashWithSalt :: Int -> VirtualGatewayHttpConnectionPool -> Int
hashWithSalt
    Int
_salt
    VirtualGatewayHttpConnectionPool' {Natural
Maybe Natural
maxConnections :: Natural
maxPendingRequests :: Maybe Natural
$sel:maxConnections:VirtualGatewayHttpConnectionPool' :: VirtualGatewayHttpConnectionPool -> Natural
$sel:maxPendingRequests:VirtualGatewayHttpConnectionPool' :: VirtualGatewayHttpConnectionPool -> Maybe Natural
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxPendingRequests
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
maxConnections

instance
  Prelude.NFData
    VirtualGatewayHttpConnectionPool
  where
  rnf :: VirtualGatewayHttpConnectionPool -> ()
rnf VirtualGatewayHttpConnectionPool' {Natural
Maybe Natural
maxConnections :: Natural
maxPendingRequests :: Maybe Natural
$sel:maxConnections:VirtualGatewayHttpConnectionPool' :: VirtualGatewayHttpConnectionPool -> Natural
$sel:maxPendingRequests:VirtualGatewayHttpConnectionPool' :: VirtualGatewayHttpConnectionPool -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxPendingRequests
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
maxConnections

instance Data.ToJSON VirtualGatewayHttpConnectionPool where
  toJSON :: VirtualGatewayHttpConnectionPool -> Value
toJSON VirtualGatewayHttpConnectionPool' {Natural
Maybe Natural
maxConnections :: Natural
maxPendingRequests :: Maybe Natural
$sel:maxConnections:VirtualGatewayHttpConnectionPool' :: VirtualGatewayHttpConnectionPool -> Natural
$sel:maxPendingRequests:VirtualGatewayHttpConnectionPool' :: VirtualGatewayHttpConnectionPool -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"maxPendingRequests" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxPendingRequests,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"maxConnections" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
maxConnections)
          ]
      )