--------------------------------------------------------------------------------
-- |
-- Module : Database.EventStore.Internal.EndPoint
-- Copyright : (C) 2016 Yorick Laupa
-- License : (see the file LICENSE)
--
-- Maintainer : Yorick Laupa <yo.eight@gmail.com>
-- Stability : provisional
-- Portability : non-portable
--
--------------------------------------------------------------------------------
module Database.EventStore.Internal.EndPoint where

--------------------------------------------------------------------------------
import Prelude (String)

--------------------------------------------------------------------------------
import Database.EventStore.Internal.Prelude

--------------------------------------------------------------------------------
-- | Gathers both an IPv4 and a port.
data EndPoint =
    EndPoint
    { EndPoint -> String
endPointIp   :: !String
    , EndPoint -> Int
endPointPort :: !Int
    } deriving EndPoint -> EndPoint -> Bool
(EndPoint -> EndPoint -> Bool)
-> (EndPoint -> EndPoint -> Bool) -> Eq EndPoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EndPoint -> EndPoint -> Bool
$c/= :: EndPoint -> EndPoint -> Bool
== :: EndPoint -> EndPoint -> Bool
$c== :: EndPoint -> EndPoint -> Bool
Eq

--------------------------------------------------------------------------------
instance Show EndPoint where
    show :: EndPoint -> String
show (EndPoint String
h Int
p) = String
h String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
":" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
p

--------------------------------------------------------------------------------
emptyEndPoint :: EndPoint
emptyEndPoint :: EndPoint
emptyEndPoint = String -> Int -> EndPoint
EndPoint String
"" Int
0

--------------------------------------------------------------------------------
data NodeEndPoints =
    NodeEndPoints
    { NodeEndPoints -> EndPoint
tcpEndPoint :: !EndPoint
    , NodeEndPoints -> Maybe EndPoint
secureEndPoint :: !(Maybe EndPoint)
    } deriving Int -> NodeEndPoints -> ShowS
[NodeEndPoints] -> ShowS
NodeEndPoints -> String
(Int -> NodeEndPoints -> ShowS)
-> (NodeEndPoints -> String)
-> ([NodeEndPoints] -> ShowS)
-> Show NodeEndPoints
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NodeEndPoints] -> ShowS
$cshowList :: [NodeEndPoints] -> ShowS
show :: NodeEndPoints -> String
$cshow :: NodeEndPoints -> String
showsPrec :: Int -> NodeEndPoints -> ShowS
$cshowsPrec :: Int -> NodeEndPoints -> ShowS
Show