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

-- |
-- Create a value of 'VirtualNodeHttpConnectionPool' 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', 'virtualNodeHttpConnectionPool_maxPendingRequests' - Number of overflowing requests after @max_connections@ Envoy will queue
-- to upstream cluster.
--
-- 'maxConnections', 'virtualNodeHttpConnectionPool_maxConnections' - Maximum number of outbound TCP connections Envoy can establish
-- concurrently with all hosts in upstream cluster.
newVirtualNodeHttpConnectionPool ::
  -- | 'maxConnections'
  Prelude.Natural ->
  VirtualNodeHttpConnectionPool
newVirtualNodeHttpConnectionPool :: Natural -> VirtualNodeHttpConnectionPool
newVirtualNodeHttpConnectionPool Natural
pMaxConnections_ =
  VirtualNodeHttpConnectionPool' :: Maybe Natural -> Natural -> VirtualNodeHttpConnectionPool
VirtualNodeHttpConnectionPool'
    { $sel:maxPendingRequests:VirtualNodeHttpConnectionPool' :: Maybe Natural
maxPendingRequests =
        Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:maxConnections:VirtualNodeHttpConnectionPool' :: Natural
maxConnections = Natural
pMaxConnections_
    }

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

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

instance Core.FromJSON VirtualNodeHttpConnectionPool where
  parseJSON :: Value -> Parser VirtualNodeHttpConnectionPool
parseJSON =
    String
-> (Object -> Parser VirtualNodeHttpConnectionPool)
-> Value
-> Parser VirtualNodeHttpConnectionPool
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"VirtualNodeHttpConnectionPool"
      ( \Object
x ->
          Maybe Natural -> Natural -> VirtualNodeHttpConnectionPool
VirtualNodeHttpConnectionPool'
            (Maybe Natural -> Natural -> VirtualNodeHttpConnectionPool)
-> Parser (Maybe Natural)
-> Parser (Natural -> VirtualNodeHttpConnectionPool)
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 -> VirtualNodeHttpConnectionPool)
-> Parser Natural -> Parser VirtualNodeHttpConnectionPool
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
    VirtualNodeHttpConnectionPool

instance Prelude.NFData VirtualNodeHttpConnectionPool

instance Core.ToJSON VirtualNodeHttpConnectionPool where
  toJSON :: VirtualNodeHttpConnectionPool -> Value
toJSON VirtualNodeHttpConnectionPool' {Natural
Maybe Natural
maxConnections :: Natural
maxPendingRequests :: Maybe Natural
$sel:maxConnections:VirtualNodeHttpConnectionPool' :: VirtualNodeHttpConnectionPool -> Natural
$sel:maxPendingRequests:VirtualNodeHttpConnectionPool' :: VirtualNodeHttpConnectionPool -> 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)
          ]
      )