\subsection{Cardano.BM.Data.BackendKind} \label{code:Cardano.BM.Data.BackendKind} %if style == newcode \begin{code} {-# LANGUAGE LambdaCase #-} module Cardano.BM.Data.BackendKind ( BackendKind (..) ) where import Control.Applicative (Alternative ((<|>))) import Data.Aeson (FromJSON (..), ToJSON (..), Value (..), (.=), (.:), object, withText, withObject) import Data.Aeson.Types (Parser) import Data.Text (Text) \end{code} %endif \subsubsection{BackendKind}\label{code:BackendKind}\index{BackendKind} \label{code:AggregationBK}\index{BackendKind!AggregationBK} \label{code:EditorBK}\index{BackendKind!EditorBK} \label{code:EKGViewBK}\index{BackendKind!EKGViewBK} \label{code:GraylogBK}\index{BackendKind!GraylogBK} \label{code:KatipBK}\index{BackendKind!KatipBK} \label{code:LogBufferBK}\index{BackendKind!LogBufferBK} \label{code:MonitoringBK}\index{BackendKind!MonitoringBK} \label{code:SwitchboardBK}\index{BackendKind!SwitchboardBK} \label{code:TraceAcceptorBK}\index{BackendKind!TraceAcceptorBK} \label{code:TraceForwarderBK}\index{BackendKind!TraceForwarderBK} \label{code:UserDefinedBK}\index{BackendKind!UserDefinedBK} This identifies the backends that can be attached to the |Switchboard|. \begin{code} data BackendKind = AggregationBK | EditorBK | EKGViewBK | GraylogBK | KatipBK | LogBufferBK | MonitoringBK | TraceAcceptorBK | TraceForwarderBK | UserDefinedBK Text | SwitchboardBK deriving (BackendKind -> BackendKind -> Bool (BackendKind -> BackendKind -> Bool) -> (BackendKind -> BackendKind -> Bool) -> Eq BackendKind forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a /= :: BackendKind -> BackendKind -> Bool $c/= :: BackendKind -> BackendKind -> Bool == :: BackendKind -> BackendKind -> Bool $c== :: BackendKind -> BackendKind -> Bool Eq, Eq BackendKind Eq BackendKind -> (BackendKind -> BackendKind -> Ordering) -> (BackendKind -> BackendKind -> Bool) -> (BackendKind -> BackendKind -> Bool) -> (BackendKind -> BackendKind -> Bool) -> (BackendKind -> BackendKind -> Bool) -> (BackendKind -> BackendKind -> BackendKind) -> (BackendKind -> BackendKind -> BackendKind) -> Ord BackendKind BackendKind -> BackendKind -> Bool BackendKind -> BackendKind -> Ordering BackendKind -> BackendKind -> BackendKind forall a. Eq a -> (a -> a -> Ordering) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> Bool) -> (a -> a -> a) -> (a -> a -> a) -> Ord a min :: BackendKind -> BackendKind -> BackendKind $cmin :: BackendKind -> BackendKind -> BackendKind max :: BackendKind -> BackendKind -> BackendKind $cmax :: BackendKind -> BackendKind -> BackendKind >= :: BackendKind -> BackendKind -> Bool $c>= :: BackendKind -> BackendKind -> Bool > :: BackendKind -> BackendKind -> Bool $c> :: BackendKind -> BackendKind -> Bool <= :: BackendKind -> BackendKind -> Bool $c<= :: BackendKind -> BackendKind -> Bool < :: BackendKind -> BackendKind -> Bool $c< :: BackendKind -> BackendKind -> Bool compare :: BackendKind -> BackendKind -> Ordering $ccompare :: BackendKind -> BackendKind -> Ordering $cp1Ord :: Eq BackendKind Ord, Int -> BackendKind -> ShowS [BackendKind] -> ShowS BackendKind -> String (Int -> BackendKind -> ShowS) -> (BackendKind -> String) -> ([BackendKind] -> ShowS) -> Show BackendKind forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a showList :: [BackendKind] -> ShowS $cshowList :: [BackendKind] -> ShowS show :: BackendKind -> String $cshow :: BackendKind -> String showsPrec :: Int -> BackendKind -> ShowS $cshowsPrec :: Int -> BackendKind -> ShowS Show, ReadPrec [BackendKind] ReadPrec BackendKind Int -> ReadS BackendKind ReadS [BackendKind] (Int -> ReadS BackendKind) -> ReadS [BackendKind] -> ReadPrec BackendKind -> ReadPrec [BackendKind] -> Read BackendKind forall a. (Int -> ReadS a) -> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a readListPrec :: ReadPrec [BackendKind] $creadListPrec :: ReadPrec [BackendKind] readPrec :: ReadPrec BackendKind $creadPrec :: ReadPrec BackendKind readList :: ReadS [BackendKind] $creadList :: ReadS [BackendKind] readsPrec :: Int -> ReadS BackendKind $creadsPrec :: Int -> ReadS BackendKind Read) instance ToJSON BackendKind where toJSON :: BackendKind -> Value toJSON BackendKind AggregationBK = Text -> Value String Text "AggregationBK" toJSON BackendKind EditorBK = Text -> Value String Text "EditorBK" toJSON BackendKind EKGViewBK = Text -> Value String Text "EKGViewBK" toJSON BackendKind GraylogBK = Text -> Value String Text "GraylogBK" toJSON BackendKind KatipBK = Text -> Value String Text "KatipBK" toJSON BackendKind LogBufferBK = Text -> Value String Text "LogBufferBK" toJSON BackendKind MonitoringBK = Text -> Value String Text "MonitoringBK" toJSON BackendKind TraceForwarderBK = Text -> Value String Text "TraceForwarderBK" toJSON BackendKind TraceAcceptorBK = Text -> Value String Text "TraceAcceptorBK" toJSON (UserDefinedBK Text name) = [Pair] -> Value object [ Text "kind" Text -> Value -> Pair forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv .= Text -> Value String Text "UserDefinedBK" , Text "name" Text -> Value -> Pair forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv .= Text -> Value forall a. ToJSON a => a -> Value toJSON Text name ] toJSON BackendKind SwitchboardBK = Text -> Value String Text "SwitchboardBK" instance FromJSON BackendKind where parseJSON :: Value -> Parser BackendKind parseJSON Value v = String -> (Object -> Parser BackendKind) -> Value -> Parser BackendKind forall a. String -> (Object -> Parser a) -> Value -> Parser a withObject String "BackendKind" (\Object value -> do Text c <- Object value Object -> Text -> Parser Text forall a. FromJSON a => Object -> Text -> Parser a .: Text "kind" :: Parser Text case Text c of Text "UserDefinedBK" -> Text -> BackendKind UserDefinedBK (Text -> BackendKind) -> Parser Text -> Parser BackendKind forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Object value Object -> Text -> Parser Text forall a. FromJSON a => Object -> Text -> Parser a .: Text "name" Text _ -> String -> Parser BackendKind forall (m :: * -> *) a. MonadFail m => String -> m a fail String "not expected kind" ) Value v Parser BackendKind -> Parser BackendKind -> Parser BackendKind forall (f :: * -> *) a. Alternative f => f a -> f a -> f a <|> String -> (Text -> Parser BackendKind) -> Value -> Parser BackendKind forall a. String -> (Text -> Parser a) -> Value -> Parser a withText String "BackendKind" (\case Text "AggregationBK" -> BackendKind -> Parser BackendKind forall (f :: * -> *) a. Applicative f => a -> f a pure BackendKind AggregationBK Text "EditorBK" -> BackendKind -> Parser BackendKind forall (f :: * -> *) a. Applicative f => a -> f a pure BackendKind EditorBK Text "EKGViewBK" -> BackendKind -> Parser BackendKind forall (f :: * -> *) a. Applicative f => a -> f a pure BackendKind EKGViewBK Text "GraylogBK" -> BackendKind -> Parser BackendKind forall (f :: * -> *) a. Applicative f => a -> f a pure BackendKind GraylogBK Text "KatipBK" -> BackendKind -> Parser BackendKind forall (f :: * -> *) a. Applicative f => a -> f a pure BackendKind KatipBK Text "LogBufferBK" -> BackendKind -> Parser BackendKind forall (f :: * -> *) a. Applicative f => a -> f a pure BackendKind LogBufferBK Text "MonitoringBK" -> BackendKind -> Parser BackendKind forall (f :: * -> *) a. Applicative f => a -> f a pure BackendKind MonitoringBK Text "TraceAcceptorBK" -> BackendKind -> Parser BackendKind forall (f :: * -> *) a. Applicative f => a -> f a pure BackendKind TraceAcceptorBK Text "TraceForwarderBK" -> BackendKind -> Parser BackendKind forall (f :: * -> *) a. Applicative f => a -> f a pure BackendKind TraceForwarderBK Text "SwitchboardBK" -> BackendKind -> Parser BackendKind forall (f :: * -> *) a. Applicative f => a -> f a pure BackendKind SwitchboardBK Text _ -> String -> Parser BackendKind forall (m :: * -> *) a. MonadFail m => String -> m a fail String "not expected BackendKind" ) Value v \end{code}