{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-missing-fields #-}
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Agent_Client(emitZipkinBatch,emitBatch) where
import qualified Data.IORef as R
import Prelude (($), (.), (>>=), (==), (++))
import qualified Prelude as P
import qualified Control.Exception as X
import qualified Control.Monad as M ( liftM, ap, when )
import Data.Functor ( (<$>) )
import qualified Data.ByteString.Lazy as LBS
import qualified Data.Hashable as H
import qualified Data.Int as I
import qualified Data.Maybe as M (catMaybes)
import qualified Data.Text.Lazy.Encoding as E ( decodeUtf8, encodeUtf8 )
import qualified Data.Text.Lazy as LT
import qualified GHC.Generics as G (Generic)
import qualified Data.Typeable as TY ( Typeable )
import qualified Data.HashMap.Strict as Map
import qualified Data.HashSet as Set
import qualified Data.Vector as Vector
import qualified Test.QuickCheck.Arbitrary as QC ( Arbitrary(..) )
import qualified Test.QuickCheck as QC ( elements )
import qualified Thrift as T
import qualified Thrift.Types as T
import qualified Thrift.Arbitraries as T
import qualified Jaeger_Types
import qualified Zipkincore_Types
import Agent_Types
import Agent
seqid :: IO (IORef Int32)
seqid = Int32 -> IO (IORef Int32)
forall a. a -> IO (IORef a)
R.newIORef Int32
0
emitZipkinBatch :: (a, p) -> Vector Span -> IO ()
emitZipkinBatch (a
ip,p
op) Vector Span
arg_spans = do
p -> Vector Span -> IO ()
forall p. Protocol p => p -> Vector Span -> IO ()
send_emitZipkinBatch p
op Vector Span
arg_spans
send_emitZipkinBatch :: p -> Vector Span -> IO ()
send_emitZipkinBatch p
op Vector Span
arg_spans = do
IORef Int32
seq <- IO (IORef Int32)
seqid
Int32
seqn <- IORef Int32 -> IO Int32
forall a. IORef a -> IO a
R.readIORef IORef Int32
seq
p -> (Text, MessageType, Int32) -> IO () -> IO ()
forall a.
Protocol a =>
a -> (Text, MessageType, Int32) -> IO () -> IO ()
T.writeMessage p
op (Text
"emitZipkinBatch", MessageType
T.M_ONEWAY, Int32
seqn) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
p -> EmitZipkinBatch_args -> IO ()
forall p. Protocol p => p -> EmitZipkinBatch_args -> IO ()
write_EmitZipkinBatch_args p
op (EmitZipkinBatch_args :: Vector Span -> EmitZipkinBatch_args
EmitZipkinBatch_args{emitZipkinBatch_args_spans :: Vector Span
emitZipkinBatch_args_spans=Vector Span
arg_spans})
emitBatch :: (a, p) -> Batch -> IO ()
emitBatch (a
ip,p
op) Batch
arg_batch = do
p -> Batch -> IO ()
forall p. Protocol p => p -> Batch -> IO ()
send_emitBatch p
op Batch
arg_batch
send_emitBatch :: p -> Batch -> IO ()
send_emitBatch p
op Batch
arg_batch = do
IORef Int32
seq <- IO (IORef Int32)
seqid
Int32
seqn <- IORef Int32 -> IO Int32
forall a. IORef a -> IO a
R.readIORef IORef Int32
seq
p -> (Text, MessageType, Int32) -> IO () -> IO ()
forall a.
Protocol a =>
a -> (Text, MessageType, Int32) -> IO () -> IO ()
T.writeMessage p
op (Text
"emitBatch", MessageType
T.M_ONEWAY, Int32
seqn) (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$
p -> EmitBatch_args -> IO ()
forall p. Protocol p => p -> EmitBatch_args -> IO ()
write_EmitBatch_args p
op (EmitBatch_args :: Batch -> EmitBatch_args
EmitBatch_args{emitBatch_args_batch :: Batch
emitBatch_args_batch=Batch
arg_batch})