{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Network.Monitoring.Riemann.TCPClient where
import Control.Monad.IO.Class (MonadIO, liftIO)
import qualified Data.Sequence as Seq
import Network.Monitoring.Riemann.Client (Client, close, sendEvent)
import qualified Network.Monitoring.Riemann.TCP as TCP
import Network.Monitoring.Riemann.TCP (Port, TCPConnection)
import Network.Socket (HostName)
newtype TCPClient =
TCPClient TCPConnection
tcpClient :: HostName -> Port -> IO TCPClient
tcpClient h p = do
c <- TCP.tcpConnection h p
pure $ TCPClient c
instance MonadIO m => Client m TCPClient where
sendEvent (TCPClient connection) event =
liftIO $ TCP.sendEvents connection $ Seq.singleton event
close _ = liftIO $ print "close"