{-# LANGUAGE DataKinds #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE RankNTypes #-} module Utxorpc.Watch (WatchHandlers (..), serviceHandlers) where import Control.Monad.IO.Class (MonadIO) import Network.GRPC.HTTP2.ProtoLens (RPC (RPC)) import Network.GRPC.Server (ServerStreamHandler, ServiceHandler) import Proto.Utxorpc.V1alpha.Watch.Watch import Utxorpc.Logged (UtxorpcServiceLogger, loggedSStream) newtype WatchHandlers m a = WatchHandlers { forall (m :: * -> *) a. WatchHandlers m a -> ServerStreamHandler m WatchTxRequest WatchTxResponse a watchTx :: ServerStreamHandler m WatchTxRequest WatchTxResponse a } serviceHandlers :: (MonadIO m) => Maybe (UtxorpcServiceLogger m) -> (forall x. m x -> IO x) -> WatchHandlers m b -> [ServiceHandler] serviceHandlers :: forall (m :: * -> *) b. MonadIO m => Maybe (UtxorpcServiceLogger m) -> (forall x. m x -> IO x) -> WatchHandlers m b -> [ServiceHandler] serviceHandlers Maybe (UtxorpcServiceLogger m) logger forall x. m x -> IO x f WatchHandlers {ServerStreamHandler m WatchTxRequest WatchTxResponse b watchTx :: forall (m :: * -> *) a. WatchHandlers m a -> ServerStreamHandler m WatchTxRequest WatchTxResponse a watchTx :: ServerStreamHandler m WatchTxRequest WatchTxResponse b watchTx} = [ServiceHandler watchTxSH] where watchTxSH :: ServiceHandler watchTxSH = (forall x. m x -> IO x) -> RPC WatchService "watchTx" -> ServerStreamHandler m WatchTxRequest WatchTxResponse b -> Maybe (UtxorpcServiceLogger m) -> ServiceHandler forall (m :: * -> *) r i o a. (MonadIO m, GRPCInput r i, GRPCOutput r o, Show i, Show o) => (forall x. m x -> IO x) -> r -> ServerStreamHandler m i o a -> Maybe (UtxorpcServiceLogger m) -> ServiceHandler loggedSStream m x -> IO x forall x. m x -> IO x f (RPC WatchService "watchTx" forall s (m :: Symbol). RPC s m RPC :: RPC WatchService "watchTx") ServerStreamHandler m WatchTxRequest WatchTxResponse b watchTx Maybe (UtxorpcServiceLogger m) logger