{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.AppMesh.Types.VirtualGatewayHttpConnectionPool where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(VirtualGatewayHttpConnectionPool
 -> VirtualGatewayHttpConnectionPool -> Bool)
-> (VirtualGatewayHttpConnectionPool
    -> VirtualGatewayHttpConnectionPool -> Bool)
-> Eq VirtualGatewayHttpConnectionPool
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]
(Int -> ReadS VirtualGatewayHttpConnectionPool)
-> ReadS [VirtualGatewayHttpConnectionPool]
-> ReadPrec VirtualGatewayHttpConnectionPool
-> ReadPrec [VirtualGatewayHttpConnectionPool]
-> Read 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
(Int -> VirtualGatewayHttpConnectionPool -> ShowS)
-> (VirtualGatewayHttpConnectionPool -> String)
-> ([VirtualGatewayHttpConnectionPool] -> ShowS)
-> Show VirtualGatewayHttpConnectionPool
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.
 VirtualGatewayHttpConnectionPool
 -> Rep VirtualGatewayHttpConnectionPool x)
-> (forall x.
    Rep VirtualGatewayHttpConnectionPool x
    -> VirtualGatewayHttpConnectionPool)
-> Generic VirtualGatewayHttpConnectionPool
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' :: Maybe Natural -> Natural -> VirtualGatewayHttpConnectionPool
VirtualGatewayHttpConnectionPool'
    { $sel:maxPendingRequests:VirtualGatewayHttpConnectionPool' :: Maybe Natural
maxPendingRequests =
        Maybe Natural
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 :: (Maybe Natural -> f (Maybe Natural))
-> VirtualGatewayHttpConnectionPool
-> f VirtualGatewayHttpConnectionPool
virtualGatewayHttpConnectionPool_maxPendingRequests = (VirtualGatewayHttpConnectionPool -> Maybe Natural)
-> (VirtualGatewayHttpConnectionPool
    -> Maybe Natural -> VirtualGatewayHttpConnectionPool)
-> Lens
     VirtualGatewayHttpConnectionPool
     VirtualGatewayHttpConnectionPool
     (Maybe Natural)
     (Maybe Natural)
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 :: (Natural -> f Natural)
-> VirtualGatewayHttpConnectionPool
-> f VirtualGatewayHttpConnectionPool
virtualGatewayHttpConnectionPool_maxConnections = (VirtualGatewayHttpConnectionPool -> Natural)
-> (VirtualGatewayHttpConnectionPool
    -> Natural -> VirtualGatewayHttpConnectionPool)
-> Lens
     VirtualGatewayHttpConnectionPool
     VirtualGatewayHttpConnectionPool
     Natural
     Natural
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
  Core.FromJSON
    VirtualGatewayHttpConnectionPool
  where
  parseJSON :: Value -> Parser VirtualGatewayHttpConnectionPool
parseJSON =
    String
-> (Object -> Parser VirtualGatewayHttpConnectionPool)
-> Value
-> Parser VirtualGatewayHttpConnectionPool
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"VirtualGatewayHttpConnectionPool"
      ( \Object
x ->
          Maybe Natural -> Natural -> VirtualGatewayHttpConnectionPool
VirtualGatewayHttpConnectionPool'
            (Maybe Natural -> Natural -> VirtualGatewayHttpConnectionPool)
-> Parser (Maybe Natural)
-> Parser (Natural -> VirtualGatewayHttpConnectionPool)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"maxPendingRequests")
            Parser (Natural -> VirtualGatewayHttpConnectionPool)
-> Parser Natural -> Parser VirtualGatewayHttpConnectionPool
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"maxConnections")
      )

instance
  Prelude.Hashable
    VirtualGatewayHttpConnectionPool

instance
  Prelude.NFData
    VirtualGatewayHttpConnectionPool

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"maxPendingRequests" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
maxPendingRequests,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"maxConnections" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
maxConnections)
          ]
      )