{-# LANGUAGE DataKinds #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE RankNTypes #-} module Utxorpc.Sync (SyncHandlers (..), serviceHandlers) where import Control.Monad.IO.Class (MonadIO) import Network.GRPC.HTTP2.ProtoLens (RPC (RPC)) import Network.GRPC.Server (ServerStreamHandler, ServiceHandler, UnaryHandler) import Proto.Utxorpc.V1alpha.Sync.Sync import Utxorpc.Logged (UtxorpcServiceLogger, loggedSStream, loggedUnary) data SyncHandlers m a = SyncHandlers { forall (m :: * -> *) a. SyncHandlers m a -> UnaryHandler m FetchBlockRequest FetchBlockResponse fetchBlock :: UnaryHandler m FetchBlockRequest FetchBlockResponse, forall (m :: * -> *) a. SyncHandlers m a -> UnaryHandler m DumpHistoryRequest DumpHistoryResponse dumpHistory :: UnaryHandler m DumpHistoryRequest DumpHistoryResponse, forall (m :: * -> *) a. SyncHandlers m a -> ServerStreamHandler m FollowTipRequest FollowTipResponse a followTip :: ServerStreamHandler m FollowTipRequest FollowTipResponse a, forall (m :: * -> *) a. SyncHandlers m a -> UnaryHandler m ReadTipRequest ReadTipResponse readTip :: UnaryHandler m ReadTipRequest ReadTipResponse } serviceHandlers :: (MonadIO m) => Maybe (UtxorpcServiceLogger m) -> (forall x. m x -> IO x) -> SyncHandlers m b -> [ServiceHandler] serviceHandlers :: forall (m :: * -> *) b. MonadIO m => Maybe (UtxorpcServiceLogger m) -> (forall x. m x -> IO x) -> SyncHandlers m b -> [ServiceHandler] serviceHandlers Maybe (UtxorpcServiceLogger m) logger forall x. m x -> IO x f SyncHandlers {UnaryHandler m FetchBlockRequest FetchBlockResponse fetchBlock :: forall (m :: * -> *) a. SyncHandlers m a -> UnaryHandler m FetchBlockRequest FetchBlockResponse fetchBlock :: UnaryHandler m FetchBlockRequest FetchBlockResponse fetchBlock, UnaryHandler m DumpHistoryRequest DumpHistoryResponse dumpHistory :: forall (m :: * -> *) a. SyncHandlers m a -> UnaryHandler m DumpHistoryRequest DumpHistoryResponse dumpHistory :: UnaryHandler m DumpHistoryRequest DumpHistoryResponse dumpHistory, ServerStreamHandler m FollowTipRequest FollowTipResponse b followTip :: forall (m :: * -> *) a. SyncHandlers m a -> ServerStreamHandler m FollowTipRequest FollowTipResponse a followTip :: ServerStreamHandler m FollowTipRequest FollowTipResponse b followTip, UnaryHandler m ReadTipRequest ReadTipResponse readTip :: forall (m :: * -> *) a. SyncHandlers m a -> UnaryHandler m ReadTipRequest ReadTipResponse readTip :: UnaryHandler m ReadTipRequest ReadTipResponse readTip} = [ServiceHandler fetchBlockSH, ServiceHandler dumpHistorySH, ServiceHandler followTipSH, ServiceHandler readTipSH] where fetchBlockSH :: ServiceHandler fetchBlockSH = (forall x. m x -> IO x) -> RPC SyncService "fetchBlock" -> UnaryHandler m FetchBlockRequest FetchBlockResponse -> Maybe (UtxorpcServiceLogger m) -> ServiceHandler forall (m :: * -> *) r i o. (MonadIO m, GRPCInput r i, GRPCOutput r o, Show i, Show o) => (forall x. m x -> IO x) -> r -> UnaryHandler m i o -> Maybe (UtxorpcServiceLogger m) -> ServiceHandler loggedUnary m x -> IO x forall x. m x -> IO x f (RPC SyncService "fetchBlock" forall s (m :: Symbol). RPC s m RPC :: RPC SyncService "fetchBlock") UnaryHandler m FetchBlockRequest FetchBlockResponse fetchBlock Maybe (UtxorpcServiceLogger m) logger dumpHistorySH :: ServiceHandler dumpHistorySH = (forall x. m x -> IO x) -> RPC SyncService "dumpHistory" -> UnaryHandler m DumpHistoryRequest DumpHistoryResponse -> Maybe (UtxorpcServiceLogger m) -> ServiceHandler forall (m :: * -> *) r i o. (MonadIO m, GRPCInput r i, GRPCOutput r o, Show i, Show o) => (forall x. m x -> IO x) -> r -> UnaryHandler m i o -> Maybe (UtxorpcServiceLogger m) -> ServiceHandler loggedUnary m x -> IO x forall x. m x -> IO x f (RPC SyncService "dumpHistory" forall s (m :: Symbol). RPC s m RPC :: RPC SyncService "dumpHistory") UnaryHandler m DumpHistoryRequest DumpHistoryResponse dumpHistory Maybe (UtxorpcServiceLogger m) logger followTipSH :: ServiceHandler followTipSH = (forall x. m x -> IO x) -> RPC SyncService "followTip" -> ServerStreamHandler m FollowTipRequest FollowTipResponse 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 SyncService "followTip" forall s (m :: Symbol). RPC s m RPC :: RPC SyncService "followTip") ServerStreamHandler m FollowTipRequest FollowTipResponse b followTip Maybe (UtxorpcServiceLogger m) logger readTipSH :: ServiceHandler readTipSH = (forall x. m x -> IO x) -> RPC SyncService "readTip" -> UnaryHandler m ReadTipRequest ReadTipResponse -> Maybe (UtxorpcServiceLogger m) -> ServiceHandler forall (m :: * -> *) r i o. (MonadIO m, GRPCInput r i, GRPCOutput r o, Show i, Show o) => (forall x. m x -> IO x) -> r -> UnaryHandler m i o -> Maybe (UtxorpcServiceLogger m) -> ServiceHandler loggedUnary m x -> IO x forall x. m x -> IO x f (RPC SyncService "readTip" forall s (m :: Symbol). RPC s m RPC :: RPC SyncService "readTip") UnaryHandler m ReadTipRequest ReadTipResponse readTip Maybe (UtxorpcServiceLogger m) logger