mirror of
https://github.com/haskell-nix/hnix-store.git
synced 2024-09-11 18:05:56 +03:00
remote: add ReplySError, RemoteStoreError_SerializerReply
This commit is contained in:
parent
218689d610
commit
de15745a64
@ -130,7 +130,7 @@ doReq = \case
|
||||
|
||||
processOutput
|
||||
sockGetS
|
||||
(mapErrorS RemoteStoreError_SerializerGet
|
||||
(mapErrorS RemoteStoreError_SerializerReply
|
||||
$ getReply @a
|
||||
)
|
||||
|
||||
@ -139,13 +139,18 @@ class StoreReply a where
|
||||
:: ( HasStoreDir r
|
||||
, HasProtoVersion r
|
||||
)
|
||||
=> NixSerializer r SError a
|
||||
=> NixSerializer r ReplySError a
|
||||
|
||||
instance StoreReply Bool where
|
||||
getReply = bool
|
||||
getReply = mapPrimE bool
|
||||
|
||||
instance StoreReply StorePath where
|
||||
getReply = storePath
|
||||
getReply = mapPrimE storePath
|
||||
|
||||
mapPrimE
|
||||
:: NixSerializer r SError a
|
||||
-> NixSerializer r ReplySError a
|
||||
mapPrimE = mapErrorS ReplySError_Prim
|
||||
|
||||
-- | Add `NarSource` to the store
|
||||
addToStore
|
||||
|
@ -29,7 +29,7 @@ import Data.Word (Word64)
|
||||
import Network.Socket (Socket)
|
||||
import System.Nix.Nar (NarSource)
|
||||
import System.Nix.StorePath (HasStoreDir(..), StoreDir)
|
||||
import System.Nix.Store.Remote.Serializer (HandshakeSError, LoggerSError, RequestSError, SError)
|
||||
import System.Nix.Store.Remote.Serializer (HandshakeSError, LoggerSError, RequestSError, ReplySError, SError)
|
||||
import System.Nix.Store.Remote.Types.Logger (Logger)
|
||||
import System.Nix.Store.Remote.Types.ProtoVersion (HasProtoVersion(..), ProtoVersion)
|
||||
import System.Nix.Store.Remote.Types.StoreConfig (HasStoreSocket(..), StoreConfig)
|
||||
@ -64,6 +64,7 @@ data RemoteStoreError
|
||||
| RemoteStoreError_SerializerLogger LoggerSError
|
||||
| RemoteStoreError_SerializerPut SError
|
||||
| RemoteStoreError_SerializerRequest RequestSError
|
||||
| RemoteStoreError_SerializerReply ReplySError
|
||||
| RemoteStoreError_IOException SomeException
|
||||
| RemoteStoreError_LoggerLeftovers String ByteString -- when there are bytes left over after incremental logger parser is done, (Done x leftover), first param is show x
|
||||
| RemoteStoreError_LoggerParserFail String ByteString -- when incremental parser returns ((Fail msg leftover) :: Result)
|
||||
|
@ -72,9 +72,12 @@ module System.Nix.Store.Remote.Serializer
|
||||
, trustedFlag
|
||||
-- * Worker protocol
|
||||
, storeText
|
||||
, RequestSError(..)
|
||||
, workerOp
|
||||
-- ** Request
|
||||
, RequestSError(..)
|
||||
, storeRequest
|
||||
-- ** Reply
|
||||
, ReplySError(..)
|
||||
) where
|
||||
|
||||
import Control.Monad.Except (MonadError, throwError, )
|
||||
@ -974,6 +977,11 @@ storeText = Serializer
|
||||
putS text storeTextText
|
||||
}
|
||||
|
||||
workerOp :: NixSerializer r SError WorkerOp
|
||||
workerOp = enum
|
||||
|
||||
-- * Request
|
||||
|
||||
data RequestSError
|
||||
= RequestSError_NotYetImplemented WorkerOp
|
||||
| RequestSError_ReservedOp WorkerOp
|
||||
@ -982,9 +990,6 @@ data RequestSError
|
||||
| RequestSError_PrimWorkerOp SError
|
||||
deriving (Eq, Ord, Generic, Show)
|
||||
|
||||
workerOp :: NixSerializer r SError WorkerOp
|
||||
workerOp = enum
|
||||
|
||||
storeRequest
|
||||
:: ( HasProtoVersion r
|
||||
, HasStoreDir r
|
||||
@ -1265,3 +1270,8 @@ storeRequest = Serializer
|
||||
-> m a
|
||||
reserved = throwError . RequestSError_ReservedOp
|
||||
|
||||
-- * Reply
|
||||
|
||||
data ReplySError
|
||||
= ReplySError_Prim SError
|
||||
deriving (Eq, Ord, Generic, Show)
|
||||
|
Loading…
Reference in New Issue
Block a user